Skip to content

Commit

Permalink
Add eslint-plugin-react-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
leroykorterink committed Nov 7, 2024
1 parent 1aff390 commit b66651b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-storybook": "^0.11.0",
"eslint-plugin-unicorn": "^56.0.0",
"typescript-eslint": "^8.13.0"
Expand Down
19 changes: 14 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import eslint from '@eslint/js';
import eslintPluginImport from 'eslint-plugin-import';
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
import eslintPluginReact from 'eslint-plugin-react';
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import eslintPluginStorybook from 'eslint-plugin-storybook';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import typescriptEslint from 'typescript-eslint';
Expand Down Expand Up @@ -50,6 +51,14 @@ const react = [
files: ['**/*.jsx', '**/*.tsx'],
name: '@mediamonks/eslint-config / eslint-plugin-react / recommended configuration',
},
{
plugins: {
'react-hooks': eslintPluginReactHooks,
},
...eslintPluginReactHooks.configs.recommended,
files: ['**/*.jsx', '**/*.tsx'],
name: '@mediamonks/eslint-config / eslint-plugin-react-hooks / recommended configuration',
},
{
...eslintPluginImport.flatConfigs.react,
files: ['**/*.jsx', '**/*.tsx'],
Expand All @@ -60,15 +69,15 @@ const react = [
name: `@mediamonks/eslint-config / eslint-plugin-storybook / ${config.name}`,
})),
{
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
rules: {
'react/jsx-no-literals': 'off',
},
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
name: `@mediamonks/eslint-config / react storybook overrides`,
},
{
...reactRecommended,
files: ['**/*.jsx', '**/*.tsx'],
files: ['**/*.js', '**/*.mjs', '**/*.cjs', '**/*.jsx', '**/*.tsx'],
name: '@mediamonks/eslint-config / react recommended configuration',
},
];
Expand Down Expand Up @@ -97,12 +106,12 @@ const typescript = [
const typescriptReact = [
{
...eslintPluginImport.flatConfigs.react,
files: ['**/*.tsx'],
files: ['**/*.ts', '**/*.tsx'],
name: '@mediamonks/eslint-config / eslint-plugin-import / .tsx configuration',
},
{
...typescriptReactRecommended,
files: ['**/*.tsx', '**/*.styles.ts'],
files: ['**/*.ts', '**/*.tsx'],
name: '@mediamonks/eslint-config / typescript react recommended configuration',
},
];
Expand All @@ -121,5 +130,5 @@ export const configs = {
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
typescript: [...javascript, ...typescript, overrides],
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
typescriptReact: [...javascript, ...react, ...typescript, ...typescriptReact, overrides],
typescriptReact: [...javascript, ...typescript, ...typescriptReact, ...react, overrides],
};
5 changes: 5 additions & 0 deletions src/react.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import eslintPluginReact from 'eslint-plugin-react';

/** @type {import('eslint').Linter.Config} */
export const recommended = {
plugins: {
react: eslintPluginReact,
},
rules: {
/**
* Unicorn plugin
Expand Down

0 comments on commit b66651b

Please sign in to comment.