Skip to content

Commit

Permalink
✨ (codestyle) import sort for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeFitz committed May 11, 2021
1 parent 0796556 commit 933d14a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
28 changes: 25 additions & 3 deletions packages/codestyle/.eslintrc.react-native.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module.exports = {
extends: ['prettier'],
extends: ['prettier', 'plugin:import/errors', 'plugin:import/warnings'],
overrides: [
{
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
plugins: ['@typescript-eslint', 'react', 'react-hooks', 'import'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand Down Expand Up @@ -38,11 +41,30 @@ module.exports = {
},
],
parser: '@babel/eslint-parser',
plugins: ['react', 'react-hooks'],
plugins: ['react', 'react-hooks', 'import'],
// 0 off, 1 warn, 2 error
rules: {
complexity: [2, 10],
'handle-callback-err': 2,
'import/default': 0, // @todo
'import/named': 0, // @todo
'import/namespace': 0, // @todo
'import/no-unresolved': 0, // @todo
'import/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
pathGroups: [
{
pattern: '~**/**',
group: 'sibling',
position: 'before',
},
],
},
],
'max-len': [
2,
{
Expand Down
26 changes: 24 additions & 2 deletions packages/codestyle/.eslintrc.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = {
jest: true,
node: true,
},
extends: ['prettier'],
extends: ['prettier', 'plugin:import/errors', 'plugin:import/warnings'],
overrides: [
{
files: ['**/*.ts?(x)'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'import'],
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand All @@ -26,6 +26,9 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
// Set ESLint rule to "never" if TypeScript overrides
rules: {
Expand Down Expand Up @@ -60,6 +63,25 @@ module.exports = {
root: true,
// http://eslint.org/docs/rules/
rules: {
'import/default': 0, // @todo
'import/named': 0, // @todo
'import/namespace': 0, // @todo
'import/no-unresolved': 0, // @todo
'import/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
pathGroups: [
{
pattern: '~**/**',
group: 'sibling',
position: 'before',
},
],
},
],
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
},
Expand Down
1 change: 1 addition & 0 deletions packages/codestyle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"eslint": "7.25.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.23.2",
"eslint-plugin-react-hooks": "4.2.0",
Expand Down

0 comments on commit 933d14a

Please sign in to comment.