Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(recommended): new set of opinionated rules
- Loading branch information
Showing
13 changed files
with
695 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const recommendedReactHooksConfiguration = require('./recommended-react-hooks'); | ||
|
||
module.exports = { | ||
...recommendedReactHooksConfiguration, | ||
extends: [ | ||
...recommendedReactHooksConfiguration.extends.splice(0, 4), | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
...recommendedReactHooksConfiguration.extends, | ||
], | ||
}; |
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,12 @@ | ||
'use strict'; | ||
|
||
const recommendedReactConfiguration = require('./recommended-react'); | ||
|
||
module.exports = { | ||
...recommendedReactConfiguration, | ||
extends: [ | ||
...recommendedReactConfiguration.extends.splice(0, 1), | ||
'airbnb/hooks', | ||
...recommendedReactConfiguration.extends, | ||
], | ||
}; |
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,12 @@ | ||
'use strict'; | ||
|
||
const recommendedReactConfiguration = require('./recommended-react'); | ||
|
||
module.exports = { | ||
...recommendedReactConfiguration, | ||
extends: [ | ||
...recommendedReactConfiguration.extends.splice(0, 3), | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
...recommendedReactConfiguration.extends, | ||
], | ||
}; |
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,19 @@ | ||
'use strict'; | ||
|
||
const recommendedConfiguration = require('./recommended'); | ||
|
||
module.exports = { | ||
...recommendedConfiguration, | ||
extends: ['airbnb', ...recommendedConfiguration.extends.splice(1, 4), 'prettier/react'], | ||
rules: { | ||
...recommendedConfiguration.rules, | ||
'import/extensions': [ | ||
...recommendedConfiguration.rules['import/extensions'].splice(0, 2), | ||
{ | ||
...recommendedConfiguration.rules['import/extensions'][0], | ||
jsx: 'never', | ||
tsx: 'never', | ||
}, | ||
], | ||
}, | ||
}; |
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,12 @@ | ||
'use strict'; | ||
|
||
const recommendedConfiguration = require('./recommended'); | ||
|
||
module.exports = { | ||
...recommendedConfiguration, | ||
extends: [ | ||
...recommendedConfiguration.extends.splice(0, 3), | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
...recommendedConfiguration.extends, | ||
], | ||
}; |
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,46 @@ | ||
'use strict'; | ||
|
||
const airbnbConfiguration = require('./airbnb'); | ||
|
||
module.exports = { | ||
...airbnbConfiguration, | ||
rules: { | ||
...airbnbConfiguration.rules, | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'warn', | ||
{ | ||
allowExpressions: true, | ||
allowHigherOrderFunctions: true, | ||
allowTypedFunctionExpressions: true, | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'import/exports-last': 'error', | ||
'import/group-exports': 'error', | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: [ | ||
'**/__{mocks,tests}__/**/*.{js,ts}', | ||
'**/*.{spec,test}.{js,ts}', | ||
'**/*.{config,setup}.{js,ts}', | ||
], | ||
}, | ||
], | ||
'import/no-default-export': 'error', | ||
'import/no-deprecated': 'warn', | ||
'import/order': [ | ||
'error', | ||
{ | ||
alphabetize: { | ||
caseInsensitive: true, | ||
order: 'asc', | ||
}, | ||
groups: ['object', 'builtin', 'external', 'internal', 'parent', 'sibling', 'index'], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'import/prefer-default-export': 'off', | ||
'prettier/prettier': 'warn', | ||
}, | ||
}; |
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,92 @@ | ||
const recommendedReactHooksSemanticsConfiguration = require('../recommended-react-hooks-semantics'); | ||
|
||
describe('Airbnb (React + Hooks)', () => { | ||
describe('with semantics rules', () => { | ||
test('configuration is exported correctly', () => { | ||
expect(recommendedReactHooksSemanticsConfiguration).toEqual({ | ||
extends: [ | ||
'airbnb', | ||
'airbnb/hooks', | ||
'plugin:import/typescript', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
'plugin:prettier/recommended', | ||
'prettier/@typescript-eslint', | ||
'prettier/react', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { project: './tsconfig.json' }, | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'warn', | ||
{ | ||
allowExpressions: true, | ||
allowHigherOrderFunctions: true, | ||
allowTypedFunctionExpressions: true, | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'no-undef': 'off', | ||
'import/exports-last': 'error', | ||
'import/extensions': [ | ||
'error', | ||
'ignorePackages', | ||
{ | ||
js: 'never', | ||
jsx: 'never', | ||
mjs: 'never', | ||
ts: 'never', | ||
tsx: 'never', | ||
}, | ||
], | ||
'import/group-exports': 'error', | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: [ | ||
'**/__{mocks,tests}__/**/*.{js,ts}', | ||
'**/*.{spec,test}.{js,ts}', | ||
'**/*.{config,setup}.{js,ts}', | ||
], | ||
}, | ||
], | ||
'import/no-default-export': 'error', | ||
'import/no-deprecated': 'warn', | ||
'import/order': [ | ||
'error', | ||
{ | ||
alphabetize: { | ||
caseInsensitive: true, | ||
order: 'asc', | ||
}, | ||
groups: [ | ||
'object', | ||
'builtin', | ||
'external', | ||
'internal', | ||
'parent', | ||
'sibling', | ||
'index', | ||
], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'import/prefer-default-export': 'off', | ||
'prettier/prettier': 'warn', | ||
}, | ||
settings: { | ||
'import/ignore': [ | ||
'node_modules', | ||
'\\.d\\.ts$', | ||
'\\.(coffee|scss|css|less|hbs|svg|json)$', | ||
], | ||
'import/resolver': { | ||
typescript: { | ||
alwaysTryTypes: false, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); |
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,89 @@ | ||
const recommendedReactHooksConfiguration = require('../recommended-react-hooks'); | ||
|
||
describe('Airbnb (React + Hooks)', () => { | ||
test('configuration is exported correctly', () => { | ||
expect(recommendedReactHooksConfiguration).toEqual({ | ||
extends: [ | ||
'airbnb', | ||
'airbnb/hooks', | ||
'plugin:import/typescript', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
'prettier/@typescript-eslint', | ||
'prettier/react', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { project: './tsconfig.json' }, | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': [ | ||
'warn', | ||
{ | ||
allowExpressions: true, | ||
allowHigherOrderFunctions: true, | ||
allowTypedFunctionExpressions: true, | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'no-undef': 'off', | ||
'import/exports-last': 'error', | ||
'import/extensions': [ | ||
'error', | ||
'ignorePackages', | ||
{ | ||
js: 'never', | ||
mjs: 'never', | ||
ts: 'never', | ||
jsx: 'never', | ||
tsx: 'never', | ||
}, | ||
], | ||
'import/group-exports': 'error', | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: [ | ||
'**/__{mocks,tests}__/**/*.{js,ts}', | ||
'**/*.{spec,test}.{js,ts}', | ||
'**/*.{config,setup}.{js,ts}', | ||
], | ||
}, | ||
], | ||
'import/no-default-export': 'error', | ||
'import/no-deprecated': 'warn', | ||
'import/order': [ | ||
'error', | ||
{ | ||
alphabetize: { | ||
caseInsensitive: true, | ||
order: 'asc', | ||
}, | ||
groups: [ | ||
'object', | ||
'builtin', | ||
'external', | ||
'internal', | ||
'parent', | ||
'sibling', | ||
'index', | ||
], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'import/prefer-default-export': 'off', | ||
'prettier/prettier': 'warn', | ||
}, | ||
settings: { | ||
'import/ignore': [ | ||
'node_modules', | ||
'\\.d\\.ts$', | ||
'\\.(coffee|scss|css|less|hbs|svg|json)$', | ||
], | ||
'import/resolver': { | ||
typescript: { | ||
alwaysTryTypes: false, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.