Skip to content

Commit

Permalink
feat: migrate to eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Feb 29, 2024
1 parent c30ec99 commit 684e383
Show file tree
Hide file tree
Showing 6 changed files with 539 additions and 159 deletions.
17 changes: 17 additions & 0 deletions configs/jsx-a11y.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pluginJSX from 'eslint-plugin-jsx-a11y';

export default {
plugins: {
'jsx-a11y': pluginJSX,
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true
},
},
},
rules: {
...pluginJSX.configs.recommended.rules,
},
}
11 changes: 11 additions & 0 deletions configs/react-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pluginReactHooks from 'eslint-plugin-react-hooks';

export default {
plugins: {
'react-hooks': pluginReactHooks,
},
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
}
30 changes: 30 additions & 0 deletions configs/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pluginReact from 'eslint-plugin-react';

export default {
plugins: {
folders: pluginReact,
},
rules: {
'react/no-deprecated': ['warn'],
'react/no-did-mount-set-state': ['warn'],
'react/no-did-update-set-state': ['warn'],
'react/no-unused-prop-types': ['warn'],
'react/no-unused-state': ['warn'],
'react/no-redundant-should-component-update': ['warn'],
'react/button-has-type': ['error'],
'react/jsx-boolean-value': ['error', 'never', { always: ['personal'] }],
'react/destructuring-assignment': ['error'],
'react/jsx-closing-tag-location': ['error'],
'react/jsx-curly-newline': ['error'],
'react/jsx-fragments': ['error'],
'react/jsx-handler-names': ['error'],
'react/jsx-key': ['error'],
'react/jsx-no-constructed-context-values': ['error'],
'react/no-direct-mutation-state': ['error'],
'react/jsx-no-useless-fragment': ['error'],
'react/jsx-uses-react': ['error'],
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-access-state-in-setstate': ['error'],
'react/no-array-index-key': ['error'],
},
}
46 changes: 17 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
module.exports = {
extends: ['@lomray/eslint-config'],
plugins: ['react', 'react-hooks'],
rules: {
'react/react-in-jsx-scope': 'off',
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'off',
'react/no-deprecated': ['warn'],
'react/no-did-mount-set-state': ['warn'],
'react/no-did-update-set-state': ['warn'],
'react/no-unused-prop-types': ['warn'],
'react/no-unused-state': ['warn'],
'react/no-redundant-should-component-update': ['warn'],
'react/button-has-type': ['error'],
'react/jsx-boolean-value': ['error', 'never', { always: ['personal'] }],
'react/destructuring-assignment': ['error'],
'react/jsx-closing-tag-location': ['error'],
'react/jsx-curly-newline': ['error'],
'react/jsx-fragments': ['error'],
'react/jsx-handler-names': ['error'],
'react/jsx-key': ['error'],
'react/jsx-no-constructed-context-values': ['error'],
'react/no-direct-mutation-state': ['error'],
'react/jsx-no-useless-fragment': ['error'],
'react/jsx-uses-react': ['error'],
'react/no-multi-comp': ['error', { ignoreStateless: true }],
'react/no-access-state-in-setstate': ['error'],
'react/no-array-index-key': ['error'],
},
import baseConfig from '@lomray/eslint-config';
import react from './configs/react';
import reactHooks from './configs/react-hooks';
import jsx from './configs/jsx-a11y';

const current = [
react,
reactHooks,
jsx,
];

export default {
recommended: [
baseConfig,
...current,
],
react: current,
};
Loading

0 comments on commit 684e383

Please sign in to comment.