@bigcommerce/eslint-config 2.8.1 → 2.9.1

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/configs/base.js CHANGED
@@ -8,9 +8,55 @@ module.exports = {
8
8
  ecmaVersion: 'latest',
9
9
  sourceType: 'module',
10
10
  },
11
- plugins: ['import', 'gettext', 'switch-case'],
11
+ plugins: ['import', 'gettext', 'switch-case', '@stylistic'],
12
12
  reportUnusedDisableDirectives: true,
13
13
  rules: {
14
+ '@stylistic/padding-line-between-statements': [
15
+ 'warn',
16
+ {
17
+ blankLine: 'always',
18
+ next: 'return',
19
+ prev: '*',
20
+ },
21
+ {
22
+ blankLine: 'always',
23
+ next: ['block', 'block-like', 'class', 'const', 'let', 'var', 'interface'],
24
+ prev: '*',
25
+ },
26
+ {
27
+ blankLine: 'always',
28
+ next: '*',
29
+ prev: ['block', 'block-like', 'class', 'const', 'let', 'var', 'interface'],
30
+ },
31
+ {
32
+ blankLine: 'any',
33
+ next: ['const', 'let', 'var'],
34
+ prev: ['const', 'let', 'var'],
35
+ },
36
+ {
37
+ blankLine: 'any',
38
+ next: ['case'],
39
+ prev: ['case'],
40
+ },
41
+ {
42
+ blankLine: 'always',
43
+ next: '*',
44
+ prev: 'directive',
45
+ },
46
+ {
47
+ blankLine: 'any',
48
+ next: 'directive',
49
+ prev: 'directive',
50
+ },
51
+ ],
52
+ '@stylistic/spaced-comment': [
53
+ 'warn',
54
+ 'always',
55
+ {
56
+ block: { balanced: true, exceptions: ['-', '+'], markers: ['=', '!'] },
57
+ line: { exceptions: ['-', '+'], markers: ['=', '!'] },
58
+ },
59
+ ],
14
60
  'array-callback-return': 'error',
15
61
  'arrow-body-style': ['error', 'as-needed', { requireReturnForObjectLiteral: false }],
16
62
  'block-scoped-var': 'error',
@@ -24,7 +70,6 @@ module.exports = {
24
70
  'func-names': 'error',
25
71
  'getter-return': ['error', { allowImplicit: true }],
26
72
  'gettext/no-variable-string': 'error',
27
- 'global-require': 'error',
28
73
  'guard-for-in': 'error',
29
74
  'import/default': 'off',
30
75
  'import/dynamic-import-chunkname': 'error',
@@ -41,6 +86,7 @@ module.exports = {
41
86
  'import/newline-after-import': 'warn',
42
87
  'import/no-absolute-path': 'error',
43
88
  'import/no-amd': 'error',
89
+ 'import/no-duplicates': ['warn', { 'prefer-inline': true }],
44
90
  'import/no-dynamic-require': 'error',
45
91
  'import/no-extraneous-dependencies': 'error',
46
92
  'import/no-mutable-exports': 'error',
@@ -55,7 +101,6 @@ module.exports = {
55
101
  'newlines-between': 'always',
56
102
  },
57
103
  ],
58
- 'lines-around-directive': ['error', { after: 'always', before: 'always' }],
59
104
  'max-classes-per-file': ['error', 1],
60
105
  'new-cap': [
61
106
  'error',
@@ -70,7 +115,6 @@ module.exports = {
70
115
  'no-array-constructor': 'error',
71
116
  'no-await-in-loop': 'error',
72
117
  'no-bitwise': 'error',
73
- 'no-buffer-constructor': 'error',
74
118
  'no-caller': 'error',
75
119
  'no-cond-assign': ['error', 'always'],
76
120
  'no-console': 'warn',
@@ -95,12 +139,10 @@ module.exports = {
95
139
  'no-nested-ternary': 'error',
96
140
  'no-new': 'error',
97
141
  'no-new-func': 'error',
98
- 'no-new-object': 'error',
99
- 'no-new-require': 'error',
100
142
  'no-new-wrappers': 'error',
143
+ 'no-object-constructor': 'error',
101
144
  'no-octal-escape': 'error',
102
145
  'no-param-reassign': ['error', { props: false }],
103
- 'no-path-concat': 'error',
104
146
  'no-plusplus': 'error',
105
147
  'no-proto': 'error',
106
148
  'no-prototype-builtins': 'off',
@@ -251,7 +293,6 @@ module.exports = {
251
293
  },
252
294
  ],
253
295
  'no-return-assign': ['error', 'except-parens'],
254
- 'no-return-await': 'error',
255
296
  'no-script-url': 'error',
256
297
  'no-self-compare': 'error',
257
298
  'no-sequences': 'error',
@@ -276,34 +317,6 @@ module.exports = {
276
317
  'object-shorthand': ['error', 'always', { avoidQuotes: true, ignoreConstructors: false }],
277
318
  'one-var': ['error', 'never'],
278
319
  'operator-assignment': ['error', 'always'],
279
- 'padding-line-between-statements': [
280
- 'warn',
281
- {
282
- blankLine: 'always',
283
- next: 'return',
284
- prev: '*',
285
- },
286
- {
287
- blankLine: 'always',
288
- next: ['block', 'block-like', 'class', 'const', 'let', 'var'],
289
- prev: '*',
290
- },
291
- {
292
- blankLine: 'always',
293
- next: '*',
294
- prev: ['block', 'block-like', 'class', 'const', 'let', 'var'],
295
- },
296
- {
297
- blankLine: 'any',
298
- next: ['const', 'let', 'var'],
299
- prev: ['const', 'let', 'var'],
300
- },
301
- {
302
- blankLine: 'any',
303
- next: ['case'],
304
- prev: ['case'],
305
- },
306
- ],
307
320
  'prefer-arrow-callback': ['error', { allowNamedFunctions: false, allowUnboundThis: true }],
308
321
  'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: true }],
309
322
  'prefer-numeric-literals': 'error',
@@ -311,14 +324,6 @@ module.exports = {
311
324
  'prefer-template': 'error',
312
325
  radix: 'error',
313
326
  'sort-imports': ['error', { ignoreCase: true, ignoreDeclarationSort: true }],
314
- 'spaced-comment': [
315
- 'warn',
316
- 'always',
317
- {
318
- block: { balanced: true, exceptions: ['-', '+'], markers: ['=', '!'] },
319
- line: { exceptions: ['-', '+'], markers: ['=', '!'] },
320
- },
321
- ],
322
327
  strict: 'error',
323
328
  'switch-case/newline-between-switch-case': ['warn', 'always', { fallthrough: 'never' }],
324
329
  'symbol-description': 'error',
package/configs/jest.js CHANGED
@@ -13,9 +13,9 @@ module.exports = {
13
13
  },
14
14
  ],
15
15
  'jest-formatting/padding-around-all': 'warn',
16
+ 'jest/no-conditional-in-test': 'error',
16
17
  'jest/no-done-callback': 'off',
17
18
  'jest/no-duplicate-hooks': 'off',
18
- 'jest/no-if': 'error',
19
19
  'jest/no-restricted-matchers': [
20
20
  'error',
21
21
  {
@@ -1,13 +1,13 @@
1
- const { basename, dirname } = require('path');
2
- const { resolveConfigFile } = require('prettier');
1
+ const path = require('path');
3
2
 
4
3
  const defaultConfig = require('../prettier.config');
5
4
 
6
5
  function getRules() {
7
- const prettierConfigFile = resolveConfigFile.sync(process.cwd());
8
- const hasLocalConfig = prettierConfigFile ? dirname(prettierConfigFile) === process.cwd() : false;
6
+ const pkgPath = path.resolve(process.cwd(), 'package.json');
7
+ // eslint-disable-next-line import/no-dynamic-require
8
+ const pkg = require(pkgPath);
9
9
 
10
- if (!hasLocalConfig) {
10
+ if (pkg.prettier !== '@bigcommerce/eslint-config/prettier') {
11
11
  throw new Error(`
12
12
  =================================================================================
13
13
  Please add "prettier": "@bigcommerce/eslint-config/prettier" to your package.json
@@ -15,15 +15,6 @@ function getRules() {
15
15
  `);
16
16
  }
17
17
 
18
- if (basename(prettierConfigFile) !== 'package.json') {
19
- throw new Error(`
20
- =================================================================================
21
- Please add "prettier": "@bigcommerce/eslint-config/prettier" to your package.json
22
- and remove any other prettier config file
23
- =================================================================================
24
- `);
25
- }
26
-
27
18
  return {
28
19
  curly: ['error', 'all'],
29
20
  'prettier/prettier': ['warn', defaultConfig, { usePrettierrc: false }],
@@ -2,10 +2,9 @@ const { join } = require('path');
2
2
 
3
3
  module.exports = {
4
4
  extends: [
5
- 'plugin:@typescript-eslint/eslint-recommended',
6
- 'plugin:@typescript-eslint/recommended',
7
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
8
5
  'plugin:import/typescript',
6
+ 'plugin:@typescript-eslint/stylistic-type-checked',
7
+ 'plugin:@typescript-eslint/strict-type-checked',
9
8
  'plugin:@bigcommerce/recommended',
10
9
  ],
11
10
  parser: '@typescript-eslint/parser',
@@ -95,7 +94,7 @@ module.exports = {
95
94
  selector: ['objectLiteralProperty', 'typeProperty'],
96
95
  },
97
96
  ],
98
- '@typescript-eslint/no-duplicate-imports': 'error',
97
+ '@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
99
98
  '@typescript-eslint/no-explicit-any': 'error',
100
99
  '@typescript-eslint/no-misused-promises': [
101
100
  'error',
@@ -112,7 +111,6 @@ module.exports = {
112
111
  },
113
112
  ],
114
113
  '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
115
- '@typescript-eslint/no-throw-literal': ['error'],
116
114
  '@typescript-eslint/no-unnecessary-condition': 'error',
117
115
  '@typescript-eslint/no-unnecessary-type-assertion': 'error',
118
116
  '@typescript-eslint/no-unused-expressions': 'error',
@@ -126,37 +124,10 @@ module.exports = {
126
124
  ],
127
125
  '@typescript-eslint/no-use-before-define': ['error', 'nofunc'],
128
126
  '@typescript-eslint/no-useless-constructor': 'error',
129
- '@typescript-eslint/padding-line-between-statements': [
130
- 'warn',
131
- {
132
- blankLine: 'always',
133
- next: 'return',
134
- prev: '*',
135
- },
136
- {
137
- blankLine: 'always',
138
- next: ['block', 'block-like', 'class', 'const', 'let', 'var', 'interface'],
139
- prev: '*',
140
- },
141
- {
142
- blankLine: 'always',
143
- next: '*',
144
- prev: ['block', 'block-like', 'class', 'const', 'let', 'var', 'interface'],
145
- },
146
- {
147
- blankLine: 'any',
148
- next: ['const', 'let', 'var'],
149
- prev: ['const', 'let', 'var'],
150
- },
151
- {
152
- blankLine: 'any',
153
- next: ['case'],
154
- prev: ['case'],
155
- },
156
- ],
157
127
  '@typescript-eslint/prefer-for-of': 'error',
158
128
  '@typescript-eslint/prefer-function-type': 'error',
159
129
  '@typescript-eslint/require-await': 'error',
130
+ '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
160
131
  '@typescript-eslint/return-await': 'error',
161
132
  '@typescript-eslint/unbound-method': 'off',
162
133
  '@typescript-eslint/unified-signatures': 'error',
@@ -169,12 +140,11 @@ module.exports = {
169
140
  'import/named': 'off',
170
141
  'no-duplicate-imports': 'off',
171
142
  'no-shadow': 'off',
172
- 'no-throw-literal': 'error',
143
+ 'no-throw-literal': 'off',
173
144
  'no-unused-expressions': 'off',
174
145
  'no-unused-vars': 'off',
175
146
  'no-use-before-define': 'off',
176
147
  'no-useless-constructor': 'off',
177
- 'padding-line-between-statements': 'off',
178
148
  'sort-keys': 'off',
179
149
  },
180
150
  settings: {
@@ -191,7 +161,7 @@ module.exports = {
191
161
  {
192
162
  files: ['**/*.d.ts'],
193
163
  rules: {
194
- 'spaced-comment': [
164
+ '@stylistic/spaced-comment': [
195
165
  'warn',
196
166
  'always',
197
167
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcommerce/eslint-config",
3
- "version": "2.8.1",
3
+ "version": "2.9.1",
4
4
  "description": "Default ESLint configuration used at BigCommerce",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -20,26 +20,27 @@
20
20
  "directory": "packages/eslint-config"
21
21
  },
22
22
  "dependencies": {
23
- "@bigcommerce/eslint-plugin": "^1.2.0",
23
+ "@bigcommerce/eslint-plugin": "^1.3.1",
24
24
  "@rushstack/eslint-patch": "^1.1.3",
25
- "@typescript-eslint/eslint-plugin": "^5.56.0",
26
- "@typescript-eslint/parser": "^5.56.0",
27
- "eslint-config-prettier": "^8.5.0",
25
+ "@stylistic/eslint-plugin": "^2.1.0",
26
+ "@typescript-eslint/eslint-plugin": "^8.4.0",
27
+ "@typescript-eslint/parser": "^8.4.0",
28
+ "eslint-config-prettier": "^9.1.0",
28
29
  "eslint-import-resolver-typescript": "^3.5.2",
29
30
  "eslint-plugin-gettext": "^1.2.0",
30
31
  "eslint-plugin-import": "^2.26.0",
31
- "eslint-plugin-jest": "^26.1.5",
32
+ "eslint-plugin-jest": "^28.4.0",
32
33
  "eslint-plugin-jest-formatting": "^3.1.0",
33
- "eslint-plugin-jsdoc": "^48.0.2",
34
+ "eslint-plugin-jsdoc": "^50.2.2",
34
35
  "eslint-plugin-jsx-a11y": "^6.5.1",
35
- "eslint-plugin-prettier": "^4.0.0",
36
+ "eslint-plugin-prettier": "^5.2.1",
36
37
  "eslint-plugin-react": "^7.29.4",
37
38
  "eslint-plugin-react-hooks": "^4.5.0",
38
39
  "eslint-plugin-switch-case": "^1.1.2",
39
- "prettier": "^2.6.2"
40
+ "prettier": "^3.3.3"
40
41
  },
41
42
  "devDependencies": {
42
- "react": "^17.0.2"
43
+ "react": "^18.3.1"
43
44
  },
44
45
  "peerDependencies": {
45
46
  "eslint": "^8.0.0",
@@ -50,5 +51,5 @@
50
51
  "optional": true
51
52
  }
52
53
  },
53
- "gitHead": "82f17771052b6e19064e1b6daf68e65106881d1b"
54
+ "gitHead": "73ecca900b0e7c1459b1cc4089465d4b49cacc3c"
54
55
  }