@shopgate/eslint-config 7.30.0-alpha.10 → 7.30.0-alpha.11

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 CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@shopgate/eslint-config",
3
- "version": "7.30.0-alpha.10",
3
+ "version": "7.30.0-alpha.11",
4
4
  "description": "Eslint configuration for the Shopgate Connect projects.",
5
5
  "author": "Shopgate <support@shopgate.com>",
6
6
  "license": "Apache-2.0",
7
7
  "main": "./ruleset/index.js",
8
8
  "dependencies": {
9
- "babel-eslint": "^10.0.2",
10
- "eslint-config-airbnb": "~17.1.0",
11
- "eslint-import-resolver-babel-module": "^5.1.0",
9
+ "eslint-config-airbnb": "^19.0.4",
10
+ "eslint-import-resolver-babel-module": "^5.3.2",
11
+ "eslint-import-resolver-exports": "^1.0.0-beta.5",
12
12
  "eslint-plugin-cypress": "^2.6.1",
13
- "eslint-plugin-eslint-comments": "^3.1.2",
13
+ "eslint-plugin-eslint-comments": "^3.2.0",
14
14
  "eslint-plugin-extra-rules": "~0.0.0-development",
15
- "eslint-plugin-import": "~2.18.0",
16
- "eslint-plugin-json": "^1.3.2",
17
- "eslint-plugin-jsx-a11y": "~6.2.3",
18
- "eslint-plugin-react": "~7.14.2",
19
- "eslint-plugin-react-hooks": "~1.5.0",
20
- "eslint-plugin-tss-unused-classes": "1.0.3"
15
+ "eslint-plugin-import": "^2.32.0",
16
+ "eslint-plugin-json": "^3.1.0",
17
+ "eslint-plugin-jsx-a11y": "^6.10.2",
18
+ "eslint-plugin-react": "^7.37.5",
19
+ "eslint-plugin-react-hooks": "^4.6.0",
20
+ "eslint-plugin-tss-unused-classes": "^1.0.3"
21
21
  },
22
22
  "devDependencies": {
23
- "eslint": "~5.12.0"
23
+ "eslint": "^8.57.1"
24
24
  },
25
25
  "peerDependencies": {
26
- "eslint": "~5.12.0"
26
+ "eslint": "^8.57.1"
27
27
  }
28
28
  }
package/ruleset/main.js CHANGED
@@ -1,6 +1,5 @@
1
1
  module.exports = {
2
2
  extends: 'airbnb',
3
- parser: 'babel-eslint',
4
3
  env: {
5
4
  browser: true,
6
5
  node: true,
@@ -9,18 +8,13 @@ module.exports = {
9
8
  'cypress/globals': true,
10
9
  },
11
10
  parserOptions: {
12
- ecmaVersion: 6,
11
+ ecmaVersion: 2022,
13
12
  sourceType: 'module',
13
+ ecmaFeatures: {
14
+ jsx: true,
15
+ },
14
16
  },
15
17
  rules: {
16
- // Added this according to: https://eslint.org/docs/rules/camelcase#allow
17
- camelcase: ['error', {
18
- allow: [
19
- 'UNSAFE_componentWillMount',
20
- 'UNSAFE_componentWillReceiveProps',
21
- 'UNSAFE_componentWillUpdate',
22
- ],
23
- }],
24
18
  'capitalized-comments': 0,
25
19
  'comma-dangle': ['error', {
26
20
  arrays: 'always-multiline',
@@ -95,12 +89,86 @@ module.exports = {
95
89
  }],
96
90
  'operator-linebreak': 0,
97
91
  'implicit-arrow-linebreak': 0,
92
+
93
+ // ## Fixes of Airbnb rules for our use cases
94
+
95
+ // Error on inconsistent line breaks in function parentheses
96
+ 'function-paren-newline': ['error', 'consistent'],
97
+ 'no-restricted-exports': [
98
+ 'warn',
99
+ {
100
+ // Allow export { default } from '...';
101
+ restrictDefaultExports: { defaultFrom: false },
102
+ },
103
+ ],
104
+ // Just warn about non-camelcase variables since sometimes they are required (e.g., API data)
105
+ camelcase: 'warn',
106
+ // Just warn about class methods that don't use 'this' to avoid heavy refactoring
107
+ 'class-methods-use-this': 'warn',
108
+ // Just warn about unexpected side effects by using async functions as Promise executors
109
+ 'no-async-promise-executor': 'warn',
110
+ // Just warn about circular dependencies since they are hard to avoid completely
111
+ 'import/no-cycle': 'warn',
112
+
113
+ // Omit parentheses when there is only one argument to an arrow function
114
+ 'arrow-parens': [
115
+ 'error',
116
+ 'as-needed',
117
+ { requireForBlockBody: true },
118
+ ],
119
+
120
+ // ## ESLint complain makes sense - revisit at the next refactoring
121
+
122
+ // In functions parameters with default values should be last - violated e.g. in reducers where
123
+ // state = initialState is the first parameter, but the action parameter has no default value.
124
+ 'default-param-last': 'warn',
125
+ // In switch statements, require 'default' case to be last
126
+ 'default-case-last': 'warn',
127
+ // Return values of Promise executor functions don't make sense
128
+ 'no-promise-executor-return': 'warn',
129
+ // Prefer Object spread over Object.assign
130
+ 'prefer-object-spread': 'warn',
131
+ // Catch blocks that only rethrow the caught error are redundant
132
+ 'no-useless-catch': 'warn',
133
+ // Prefer regex literals over RegExp constructor
134
+ 'prefer-regex-literals': 'warn',
135
+
136
+ // ## Autofixable - can be removed when ESLint update pull request is merged
137
+ indent: 'warn',
138
+ semi: ['warn', 'always'],
98
139
  },
140
+ // Overrides for files that are tests or mocks
141
+ overrides: [
142
+ {
143
+ files: [
144
+ '**/*.spec.js',
145
+ '**/*.spec.jsx',
146
+ '**/*.test.js',
147
+ '**/*.test.jsx',
148
+ '**/*.mock.js',
149
+ '**/*.mock.jsx',
150
+ '**/spec.js',
151
+ '**/spec.jsx',
152
+ '**/mock.js',
153
+ '**/mock.jsx',
154
+ ],
155
+ rules: {
156
+ // Allow more than one class per file in test files
157
+ 'max-classes-per-file': 'off',
158
+ // Allow non-camelcase names in test files (e.g., snake_case from API)
159
+ camelcase: 'off',
160
+ },
161
+ },
162
+ ],
99
163
  settings: {
100
164
  'import/extensions': [
101
165
  '.js',
102
166
  '.json',
103
167
  '.jsx',
104
168
  ],
169
+ 'import/resolver': {
170
+ exports: {},
171
+ node: {},
172
+ },
105
173
  },
106
174
  };
package/ruleset/react.js CHANGED
@@ -1,55 +1,86 @@
1
1
  module.exports = {
2
- plugins: [
3
- 'react-hooks',
4
- ],
2
+ plugins: ['react-hooks'],
5
3
  rules: {
6
- 'react/sort-prop-types': [2, {
7
- callbacksLast: false,
8
- ignoreCase: true,
9
- requiredFirst: true,
10
- }],
11
- 'react/destructuring-assignment': 0,
12
- 'react/jsx-wrap-multilines': 0,
13
- 'jsx-a11y/label-has-for': 0,
14
- 'react-hooks/rules-of-hooks': 1,
15
- 'react-hooks/exhaustive-deps': 1,
4
+ 'react/sort-prop-types': [
5
+ 'error',
6
+ {
7
+ callbacksLast: false,
8
+ ignoreCase: true,
9
+ requiredFirst: true,
10
+ },
11
+ ],
12
+ 'react/destructuring-assignment': 'off',
13
+ 'react/jsx-wrap-multilines': 'off',
14
+ 'jsx-a11y/label-has-for': 'off',
15
+ 'react-hooks/rules-of-hooks': 'warn',
16
+ 'react-hooks/exhaustive-deps': 'warn',
16
17
  // Added this according to: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md#rule-options
17
- 'react/sort-comp': ['error', {
18
- order: [
19
- 'static-methods',
20
- 'lifecycle',
21
- 'everything-else',
22
- 'render',
23
- ],
24
- groups: {
25
- lifecycle: [
26
- 'displayName',
27
- 'propTypes',
28
- 'contextTypes',
29
- 'childContextTypes',
30
- 'mixins',
31
- 'statics',
32
- 'defaultProps',
33
- 'constructor',
34
- 'getDefaultProps',
35
- 'state',
36
- 'getInitialState',
37
- 'getChildContext',
38
- 'getDerivedStateFromProps',
39
- 'componentWillMount',
40
- 'UNSAFE_componentWillMount',
41
- 'componentDidMount',
42
- 'componentWillReceiveProps',
43
- 'UNSAFE_componentWillReceiveProps',
44
- 'shouldComponentUpdate',
45
- 'componentWillUpdate',
46
- 'UNSAFE_componentWillUpdate',
47
- 'getSnapshotBeforeUpdate',
48
- 'componentDidUpdate',
49
- 'componentDidCatch',
50
- 'componentWillUnmount',
18
+ 'react/sort-comp': [
19
+ 'error',
20
+ {
21
+ order: [
22
+ 'static-variables',
23
+ 'static-methods',
24
+ 'lifecycle',
25
+ 'everything-else',
26
+ 'render',
51
27
  ],
28
+ groups: {
29
+ lifecycle: [
30
+ 'displayName',
31
+ 'propTypes',
32
+ 'defaultProps',
33
+ 'contextTypes',
34
+ 'childContextTypes',
35
+ 'mixins',
36
+ 'statics',
37
+ 'constructor',
38
+ 'getDefaultProps',
39
+ 'state',
40
+ 'getInitialState',
41
+ 'getChildContext',
42
+ 'getDerivedStateFromProps',
43
+ 'componentWillMount',
44
+ 'UNSAFE_componentWillMount',
45
+ 'componentDidMount',
46
+ 'componentWillReceiveProps',
47
+ 'UNSAFE_componentWillReceiveProps',
48
+ 'shouldComponentUpdate',
49
+ 'componentWillUpdate',
50
+ 'UNSAFE_componentWillUpdate',
51
+ 'getSnapshotBeforeUpdate',
52
+ 'componentDidUpdate',
53
+ 'componentDidCatch',
54
+ 'componentWillUnmount',
55
+ ],
56
+ },
52
57
  },
53
- }],
58
+ ],
59
+
60
+ // ## Fixes of Airbnb rules for our use cases
61
+
62
+ 'react/no-unknown-property': ['error', { ignore: ['test-id'] }],
63
+ // Warn about unstable nested components, but allow them as props to other components
64
+ 'react/no-unstable-nested-components': ['warn', { allowAsProps: true }],
65
+ // Don't care about placement of static properties in React components
66
+ 'react/static-property-placement': 'off',
67
+ // Allow prop spreading
68
+ 'react/jsx-props-no-spreading': 'off',
69
+ // Allow function components to be defined using arrow functions
70
+ 'react/function-component-definition': 'off',
71
+ // Warn about usage of .bind() or array functions in JSX props
72
+ 'react/jsx-no-bind': 'warn',
73
+
74
+ // ## TBD
75
+ 'react/jsx-curly-newline': ['warn', 'consistent'],
76
+
77
+ // ## ESLint complain makes sense - revisit at the next refactoring
78
+
79
+ 'react/state-in-constructor': 'warn',
80
+
81
+ // ## Autofixable - can be removed when ESLint update pull request is merged
82
+ 'react/jsx-curly-brace-presence': 'warn',
83
+ 'react/jsx-indent-props': 'warn',
84
+ 'react/jsx-fragments': 'warn',
54
85
  },
55
86
  };