-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,353 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,127 @@ | ||
'use strict'; | ||
|
||
const nodeFiles = [ | ||
'.eslintrc.js', | ||
'.lintstagedrc.js', | ||
'.prettierrc.js', | ||
'.template-lintrc.{js,ts}', | ||
'ember-cli-build.{js,ts}', | ||
'testem.{js,ts}', | ||
'blueprints/*/index.{js,ts}', | ||
'config/**/*.{js,ts}', | ||
'lib/*/index.{js,ts}', | ||
'server/**/*.{js,ts}', | ||
]; | ||
|
||
const browserFiles = [ | ||
'addon/**/*.{js,ts}', | ||
'addon-test-support/**/*.{js,ts}', | ||
'app/**/*.{js,ts}', | ||
'test-support/**/*.{js,ts}', | ||
'types/**/*.{js,ts}', | ||
]; | ||
|
||
const browserTestFiles = ['tests/**/*.{js,ts}']; | ||
|
||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
legacyDecorators: true | ||
} | ||
project: ['./tsconfig.json', './tsconfig-node.json'], | ||
}, | ||
plugins: [ | ||
'ember' | ||
], | ||
plugins: ['@typescript-eslint', 'ember', 'prettier'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:ember/recommended' | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
'plugin:ember/recommended', | ||
'standard', | ||
|
||
'prettier/@typescript-eslint', | ||
'prettier/standard', | ||
|
||
// This one should come last | ||
'plugin:prettier/recommended', | ||
], | ||
env: { | ||
browser: true | ||
browser: true, | ||
}, | ||
rules: { | ||
'ember/no-jquery': 'error' | ||
'@typescript-eslint/ban-ts-ignore': 'off', // Can't fully get rid of it due to TS quirks and issues with third-party depenecies | ||
'@typescript-eslint/camelcase': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args | ||
'@typescript-eslint/class-name-casing': 'off', // Allow two levels of separation, e. g. ProductWizard_SidebarConfig_ListWithHeader_Component_Args | ||
'@typescript-eslint/no-empty-function': 'off', // Noop is a valid technique. | ||
'@typescript-eslint/no-empty-interface': 'off', // Required for simplified typing of Mirage and Ember Data | ||
'@typescript-eslint/no-non-null-assertion': 'off', // When I do it, I mean it. | ||
'@typescript-eslint/no-unsafe-assignment': 'off', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-call': 'off', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-member-access': 'off', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-return': 'off', // Reenabled for TS files only | ||
'@typescript-eslint/no-unused-expressions': 'off', // Reenabled for non-tests only (Chai needs this disabled) | ||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
'@typescript-eslint/no-var-requires': 'off', // Reenabled for non-Node files only | ||
|
||
// As this rule would freak out on JS files (by design!), | ||
// it has to be enabled only for .ts in the overrides section, | ||
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md#configuring-in-a-mixed-jsts-codebase | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
|
||
camelcase: 'off', // Have to keep this off for the TS equivalent to take precedence | ||
'no-console': ['error', { allow: ['debug', 'error', 'info', 'warn'] }], | ||
'no-unused-expressions': 'off', | ||
'no-useless-constructor': 'off', // This rule crashes ESLint unless disabled | ||
|
||
'node/no-unpublished-require': 'off', // Reenabled for non-Node files only | ||
|
||
'prefer-const': 'error', // Only use `let` when you are actually mutating the variable | ||
'prettier/prettier': 'error', | ||
}, | ||
overrides: [ | ||
// node files | ||
{ | ||
files: [ | ||
'.eslintrc.js', | ||
'.template-lintrc.js', | ||
'ember-cli-build.js', | ||
'index.js', | ||
'testem.js', | ||
'blueprints/*/index.js', | ||
'config/**/*.js', | ||
'tests/dummy/config/**/*.js' | ||
], | ||
excludedFiles: [ | ||
'addon/**', | ||
'addon-test-support/**', | ||
'app/**', | ||
'tests/dummy/app/**' | ||
], | ||
files: nodeFiles, | ||
parserOptions: { | ||
sourceType: 'script' | ||
sourceType: 'script', | ||
}, | ||
env: { | ||
browser: false, | ||
node: true | ||
node: true, | ||
}, | ||
plugins: ['node'], | ||
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { | ||
rules: { | ||
...require('eslint-plugin-node').configs.recommended.rules, // eslint-disable-line node/no-unpublished-require | ||
// add your custom rules and overrides for node files here | ||
}) | ||
} | ||
] | ||
'node/no-unsupported-features/es-syntax': ['error', { version: '>=12.0.0' }], | ||
}, | ||
}, | ||
{ | ||
// browser files, including tests | ||
files: [...browserFiles, ...browserTestFiles], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'error', // Reenabled for non-Node files only | ||
'node/no-unpublished-require': 'error', // Reenabled for non-Node files only | ||
}, | ||
}, | ||
{ | ||
/// non-tests | ||
files: [...nodeFiles, ...browserFiles], | ||
rules: { | ||
'@typescript-eslint/no-unused-expressions': 'error', // Reenabled for non-tests only (Chai needs this disabled) | ||
}, | ||
}, | ||
{ | ||
// TS files | ||
files: ['*.ts'], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'error', // We want to be strict with types | ||
'@typescript-eslint/no-unsafe-assignment': 'error', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-call': 'error', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-member-access': 'error', // Reenabled for TS files only | ||
'@typescript-eslint/no-unsafe-return': 'error', // Reenabled for TS files only | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
// Run TSC on all the codebase. | ||
// Can't run TSC on individual files because we have two envs: Node and browser, | ||
// and TSC does not support providing a config and a path to a specific file at the same time. | ||
// Thus, two separate configs are used: one for Node, one for browser. | ||
// The function allows running the command globally, rather than once per each staged file. | ||
'{addon,addon-test-support,app,mirage,test-support,tests,types}/**/*.ts': () => 'yarn lint:ts -p tsconfig.json', | ||
'{*,.*,blueprints/*/*,config/**/*,lib/*/index,server/**/*}.{js,ts}': () => 'yarn lint:ts -p tsconfig-node.json', | ||
|
||
// Run ESLint, typescript-eslint and Prettier on staged files only | ||
'**/*.{js,ts}': ['yarn lint:eslint --fix'], | ||
|
||
// Template lint | ||
'**/*.hbs': ['yarn ember-template-lint'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
arrowParens: 'always', // It's convenient that you don't have to add them by hand when you need to add more args or a type | ||
singleQuote: true, // Enabled to align with EmberJS Prettier config | ||
printWidth: 100, // Per team's agreement | ||
trailingComma: 'es5', // Trailing commas makes editing easier, diffs cleaner. `es5` option aligns with EmberJS Prettier config | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
extends: 'octane' | ||
extends: 'recommended' | ||
}; |
Oops, something went wrong.