Skip to content

Commit

Permalink
chore: improve react configuration (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nr9 authored Sep 25, 2024
1 parent a5fd41c commit d6547a1
Showing 1 changed file with 50 additions and 20 deletions.
70 changes: 50 additions & 20 deletions rules/react.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,10 @@ export const react = [
...globals.browser,
},
},

settings: {
react: {
version: 'detect',
},
},

},
{
files: ['**/*.{ts,tsx}'],
rules: {
'react/jsx-props-no-spreading': 'off',
'react/prop-types': 'off',
'react/require-default-props': 'off',

'react/function-component-definition': [
'warn',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],

'unicorn/filename-case': ['error', { cases: { camelCase: true, pascalCase: true } }],
},
},
Expand All @@ -42,6 +26,13 @@ export const react = [
'unicorn/filename-case': ['error', { cases: { kebabCase: true } }],
},
},
{
settings: {
react: {
version: 'detect',
},
},
},
reactPlugin.configs.flat['jsx-runtime'],
{
plugins: {
Expand All @@ -56,7 +47,46 @@ export const react = [
'react-refresh': eslintPluginReactRefresh,
},
rules: {
'react-refresh/only-export-components': 'warn',
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
},
{
rules: {
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false } }],

'react/jsx-props-no-spreading': 'off',
'react/prop-types': 'off',
'react/require-default-props': 'off',

'react/function-component-definition': [
'warn',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],

// from eslint-config-airbnb/rules
'react/jsx-pascal-case': [
'error',
{
allowAllCaps: true,
ignore: [],
},
],

'react/jsx-no-useless-fragment': 'error',
'react/no-invalid-html-attribute': 'error',
'react/jsx-no-constructed-context-values': 'error',
'react/no-unstable-nested-components': 'error',
'react/button-has-type': [
'error',
{
button: true,
submit: true,
reset: false,
},
],
},
},
]

0 comments on commit d6547a1

Please sign in to comment.