@petbee/eslint-config 3.0.5 → 3.0.6
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/package.json +2 -2
- package/rules/react.js +32 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/eslint-config",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
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": "
|
|
84
|
+
"gitHead": "a1aadd4aa610eb4a90c5cb823786abf68ac93d0d"
|
|
85
85
|
}
|
package/rules/react.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const { hasPackage } = require('../lib/utils')
|
|
2
|
+
|
|
3
|
+
const hasReact = hasPackage('react')
|
|
3
4
|
|
|
4
5
|
const reactRules = {
|
|
5
6
|
// Allow non-camelCase naming in React projects (e.g., components, hooks, CSS modules)
|
|
@@ -28,25 +29,35 @@ module.exports = {
|
|
|
28
29
|
rules: reactRules,
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
// Flat config for ESLint v9+
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
// Flat config for ESLint v9+ - only created if React is available
|
|
33
|
+
let flatConfig = []
|
|
34
|
+
|
|
35
|
+
if (hasReact) {
|
|
36
|
+
// If React is available, require React plugins. If they're missing, this will fail (expected behavior)
|
|
37
|
+
const reactPlugin = require('eslint-plugin-react')
|
|
38
|
+
const reactHooksPlugin = require('eslint-plugin-react-hooks')
|
|
39
|
+
|
|
40
|
+
flatConfig = [
|
|
41
|
+
{
|
|
42
|
+
files: ['**/*.{jsx,tsx}'],
|
|
43
|
+
plugins: {
|
|
44
|
+
react: reactPlugin,
|
|
45
|
+
'react-hooks': reactHooksPlugin,
|
|
46
|
+
},
|
|
47
|
+
languageOptions: {
|
|
48
|
+
parserOptions: {
|
|
49
|
+
ecmaFeatures: {
|
|
50
|
+
jsx: true,
|
|
51
|
+
},
|
|
43
52
|
},
|
|
44
53
|
},
|
|
54
|
+
rules: {
|
|
55
|
+
...reactPlugin.configs.recommended.rules,
|
|
56
|
+
...reactHooksPlugin.configs.recommended.rules,
|
|
57
|
+
...reactRules,
|
|
58
|
+
},
|
|
45
59
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
]
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports.flat = flatConfig
|