-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathreact.factory.js
More file actions
77 lines (71 loc) · 1.8 KB
/
react.factory.js
File metadata and controls
77 lines (71 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const OFF = 0;
const WARNING = 1;
const commonParserOptions = {
ecmaFeatures: {
jsx: true,
},
},
commonConfig = {
rules: {
'react/display-name': OFF,
'react/no-multi-comp': [WARNING, { ignoreStateless: true }],
'react/no-unused-prop-types': OFF,
'react/prop-types': OFF,
'react/require-default-props': OFF,
},
settings: {
react: {
version: 'detect',
},
},
};
function createFlatReactConfig() {
const nodeConfig = require('./node.flat.js');
const reactPlugin = require('eslint-plugin-react');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
const globals = require('globals');
const { fixupConfigRules, fixupPluginRules } = require('@eslint/compat');
const reactHooksRules = reactHooksPlugin.configs['recommended-latest'].rules;
return [
...nodeConfig,
...fixupConfigRules(reactPlugin.configs.flat.recommended),
{
...commonConfig,
languageOptions: {
globals: globals.browser,
parserOptions: commonParserOptions,
},
plugins: {
react: fixupPluginRules(reactPlugin),
'react-hooks': fixupPluginRules(reactHooksPlugin),
},
rules: {
...reactHooksRules,
...commonConfig.rules,
},
},
];
}
function createLegacyReactConfig() {
const reactHooksPlugin = require('eslint-plugin-react-hooks');
return {
...commonConfig,
extends: [
require.resolve('./node.js'),
'plugin:react/recommended',
],
env: {
browser: true,
},
plugins: ['react', 'react-hooks'],
parserOptions: commonParserOptions,
rules: {
...reactHooksPlugin.configs['recommended-latest'].rules,
...commonConfig.rules,
},
};
}
module.exports = {
createFlatReactConfig,
createLegacyReactConfig,
};