@petbee/eslint-config 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.mjs CHANGED
@@ -10,12 +10,14 @@ import importsConfig from './rules/imports.js'
10
10
  import nestjsConfig from './rules/nestjs.js'
11
11
  import nodeConfig from './rules/node.js'
12
12
  import prettierConfig from './rules/prettier.js'
13
+ import reactConfig from './rules/react.js'
13
14
  import styleConfig from './rules/style.js'
14
15
  import testsConfig from './rules/tests.js'
15
16
  import typescriptConfig from './rules/typescript.js'
16
17
  import variablesConfig from './rules/variables.js'
17
18
 
18
19
  const hasTypescript = hasPackage('typescript')
20
+ const hasReact = hasPackage('react')
19
21
 
20
22
  const ignoreConfig = {
21
23
  ignores: ['coverage', 'dist', '**/dist/', 'node_modules', '**/node_modules'],
@@ -33,6 +35,7 @@ const eslintFlatConfig = [
33
35
  ...getFlat(bestPracticesConfig),
34
36
  ...getFlat(importsConfig),
35
37
  ...getFlat(testsConfig),
38
+ ...(hasReact ? getFlat(reactConfig) : []),
36
39
  ]
37
40
 
38
41
  const nestjsEslintFlatConfig = nestjsConfig.flat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "13a8a59332c6aa1b447f5d830041e7ed00d3e7a2"
84
+ "gitHead": "033cab1e3f57a1b92490ef1326415d33a21b0ec9"
85
85
  }
package/rules/react.js CHANGED
@@ -1,23 +1,52 @@
1
+ const reactPlugin = require('eslint-plugin-react')
2
+ const reactHooksPlugin = require('eslint-plugin-react-hooks')
3
+
4
+ const reactRules = {
5
+ // Allow non-camelCase naming in React projects (e.g., components, hooks, CSS modules)
6
+ '@typescript-eslint/naming-convention': 'off',
7
+ // Enforce consistent usage of function component definition
8
+ // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
9
+ 'react/function-component-definition': [
10
+ 'error',
11
+ {
12
+ namedComponents: 'arrow-function',
13
+ unnamedComponents: 'arrow-function',
14
+ },
15
+ ],
16
+ // Prevent missing React when using JSX (React 17+ JSX transform)
17
+ 'react/react-in-jsx-scope': 'off',
18
+ // Enforce rules of hooks
19
+ 'react-hooks/rules-of-hooks': 'error',
20
+ // Verify the list of the dependencies for Hooks like useEffect and similar
21
+ 'react-hooks/exhaustive-deps': 'warn',
22
+ }
23
+
24
+ // Legacy config for ESLint < 9
1
25
  module.exports = {
2
26
  plugins: ['react'],
3
27
  extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
4
- rules: {
5
- // Allow non-camelCase naming in React projects (e.g., components, hooks, CSS modules)
6
- '@typescript-eslint/naming-convention': 'off',
7
- // Enforce consistent usage of function component definition
8
- // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
9
- 'react/function-component-definition': [
10
- 'error',
11
- {
12
- namedComponents: 'arrow-function',
13
- unnamedComponents: 'arrow-function',
28
+ rules: reactRules,
29
+ }
30
+
31
+ // Flat config for ESLint v9+
32
+ module.exports.flat = [
33
+ {
34
+ files: ['**/*.{jsx,tsx}'],
35
+ plugins: {
36
+ react: reactPlugin,
37
+ 'react-hooks': reactHooksPlugin,
38
+ },
39
+ languageOptions: {
40
+ parserOptions: {
41
+ ecmaFeatures: {
42
+ jsx: true,
43
+ },
14
44
  },
15
- ],
16
- // Prevent missing React when using JSX (React 17+ JSX transform)
17
- 'react/react-in-jsx-scope': 'off',
18
- // Enforce rules of hooks
19
- 'react-hooks/rules-of-hooks': 'error',
20
- // Verify the list of the dependencies for Hooks like useEffect and similar
21
- 'react-hooks/exhaustive-deps': 'warn',
45
+ },
46
+ rules: {
47
+ ...reactPlugin.configs.recommended.rules,
48
+ ...reactHooksPlugin.configs.recommended.rules,
49
+ ...reactRules,
50
+ },
22
51
  },
23
- }
52
+ ]
@@ -2,15 +2,15 @@ const { hasPackage } = require('../lib/utils')
2
2
  const { hasTypescript, tsParserOptions, tsCommonRules } = require('./shared-config.js')
3
3
 
4
4
  const hasNestJs = hasPackage('@nestjs/core')
5
- const hasReact = hasPackage('react')
6
5
  const hasNext = hasPackage('next') || hasPackage('nextjs')
7
6
 
8
7
  // Load framework-specific rules
9
- const reactRules = hasReact ? require('./react.js').rules : {}
10
8
  const nextjsRules = hasNext ? require('./nextjs.js').rules : {}
11
9
  // Note: Don't require nestjs.js here to avoid circular dependency.
12
10
  // NestJS handles its own flat config completely.
11
+ // React rules are now handled separately in index.mjs
13
12
  const nestjsRules = {}
13
+ const reactRules = {}
14
14
 
15
15
  const tsConfigOptions = [
16
16
  {