@voiceflow/eslint-config 7.9.1 → 7.10.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/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # ESLint Config
2
+
3
+ Shared configuration for [`eslint`](https://eslint.org/).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add --exact -D eslint @voiceflow/eslint-config
9
+ ```
package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "@voiceflow/eslint-config",
3
- "version": "7.9.1",
3
+ "version": "7.10.1",
4
+ "exports": {
5
+ ".": "./src/index.js",
6
+ "./node": "./src/node.js"
7
+ },
4
8
  "main": "src/index.js",
5
9
  "files": [
6
10
  "src"
@@ -14,28 +18,29 @@
14
18
  "test:dependencies": "yarn g:depcruise --ignore-known"
15
19
  },
16
20
  "dependencies": {
17
- "@typescript-eslint/eslint-plugin": "8.10.0",
18
- "@typescript-eslint/parser": "8.10.0",
21
+ "@typescript-eslint/eslint-plugin": "8.21.0",
22
+ "@typescript-eslint/parser": "8.21.0",
19
23
  "eslint-config-airbnb-base": "15.0.0",
20
- "eslint-config-prettier": "9.1.0",
24
+ "eslint-config-prettier": "10.0.1",
21
25
  "eslint-formatter-junit": "8.40.0",
22
26
  "eslint-formatter-stylish": "8.40.0",
23
- "eslint-import-resolver-typescript": "3.6.3",
27
+ "eslint-import-resolver-typescript": "3.7.0",
24
28
  "eslint-plugin-eslint-comments": "3.2.0",
25
29
  "eslint-plugin-import": "2.31.0",
26
- "eslint-plugin-jsdoc": "50.4.3",
27
- "eslint-plugin-no-secrets": "1.0.2",
30
+ "eslint-plugin-jsdoc": "50.6.2",
31
+ "eslint-plugin-mdx": "3.1.5",
32
+ "eslint-plugin-no-secrets": "2.1.1",
28
33
  "eslint-plugin-prefer-arrow": "1.2.3",
29
- "eslint-plugin-prettier": "5.2.1",
30
- "eslint-plugin-promise": "7.1.0",
34
+ "eslint-plugin-prettier": "5.2.3",
35
+ "eslint-plugin-promise": "7.2.1",
31
36
  "eslint-plugin-simple-import-sort": "12.1.1",
32
- "eslint-plugin-sonarjs": "2.0.4",
33
- "eslint-plugin-unicorn": "56.0.0",
37
+ "eslint-plugin-sonarjs": "3.0.1",
38
+ "eslint-plugin-unicorn": "56.0.1",
34
39
  "eslint-plugin-you-dont-need-lodash-underscore": "6.14.0",
35
- "globals": "15.11.0"
40
+ "globals": "15.14.0"
36
41
  },
37
42
  "devDependencies": {
38
- "@voiceflow/dependency-cruiser-config": "1.8.7"
43
+ "@voiceflow/dependency-cruiser-config": "1.8.8"
39
44
  },
40
45
  "engines": {
41
46
  "node": "20"
@@ -43,5 +48,5 @@
43
48
  "volta": {
44
49
  "extends": "../../package.json"
45
50
  },
46
- "gitHead": "d3370234f64841e096a7a9ae3f6a6025471e6584"
51
+ "gitHead": "36ec89339d9f8332aa2b1715b8da66a9b821a1fe"
47
52
  }
package/src/base.js CHANGED
@@ -10,9 +10,12 @@ module.exports = [
10
10
  '**/dist/**',
11
11
  '**/node_modules/**',
12
12
  '**/sonar/**',
13
+ '**/generated/**',
13
14
  '**/.yarn/**',
14
15
  '**/.yalc/**',
15
16
  '**/.turbo/**',
17
+ '**/.vercel/**',
18
+ '**/*.json',
16
19
  ],
17
20
  },
18
21
  ...airbnb,
package/src/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  const base = require('./base');
2
2
  const typescript = require('./presets/typescript');
3
+ const mdx = require('./presets/mdx');
3
4
  const nest = require('./presets/nest');
4
5
  const utility = require('./presets/utility');
5
6
 
6
7
  /** @type {import('eslint').Linter.Config[]} */
7
- module.exports = [...base, typescript, ...nest, utility];
8
+ module.exports = [...base, ...typescript, ...mdx, ...nest, ...utility];
package/src/node.js ADDED
@@ -0,0 +1,14 @@
1
+ const baseConfig = require('.');
2
+ const globals = require('globals');
3
+
4
+ /** @type {import('eslint').Linter.Config[]} */
5
+ module.exports = [
6
+ ...baseConfig,
7
+ {
8
+ languageOptions: {
9
+ globals: {
10
+ ...globals.node,
11
+ },
12
+ },
13
+ },
14
+ ];
@@ -63,6 +63,17 @@ module.exports = [
63
63
  'quote-props': ['error', 'as-needed'],
64
64
  'prefer-arrow-callback': 'error',
65
65
  'lines-between-class-members': 'error',
66
+ 'no-restricted-imports': [
67
+ 'error',
68
+ {
69
+ paths: [
70
+ {
71
+ name: '@/main',
72
+ message: "Importing '@/main' directly is not allowed due to cyclic dependencies.",
73
+ },
74
+ ],
75
+ },
76
+ ],
66
77
 
67
78
  'prefer-arrow/prefer-arrow-functions': [
68
79
  'error',
@@ -99,17 +110,21 @@ module.exports = [
99
110
  camelcase: 'off',
100
111
  'no-underscore-dangle': 'off',
101
112
  'no-restricted-syntax': 'off',
113
+ 'sonarjs/new-cap': 'off',
102
114
  'sonarjs/no-unreachable': 'off',
103
115
  'sonarjs/no-commented-code': 'off',
104
116
  'sonarjs/no-hardcoded-credentials': 'off', // covered by no-secrets
117
+ 'sonarjs/no-hardcoded-passwords': 'off', // covered by no-secrets
105
118
  'sonarjs/use-type-alias': 'off', // too rigid to be useful
106
119
  'sonarjs/no-unstable-nested-components': 'off', // too rigid to be useful
107
120
  'sonarjs/prefer-function-type': 'off', // too rigid to be useful
108
121
  'sonarjs/assertions-in-tests': 'off', // too rigid to be useful
109
122
  'sonarjs/no-empty-test-file': 'off', // too rigid to be useful
123
+ 'sonarjs/no-unused-vars': 'off', // too rigid to be useful
110
124
  'sonarjs/no-nested-conditional': 'off', // covered by no-nested-ternary
111
125
  'sonarjs/sonar-no-unused-vars': 'off', // covered by other rules
112
126
  'sonarjs/no-empty-function': 'off', // covered by other rules
127
+ 'sonarjs/no-control-regex': 'off', // covered by other rules
113
128
  'sonarjs/constructor-for-side-effects': 'off', // covered by other rules
114
129
  'sonarjs/sonar-max-params': 'off', // covered by other rules
115
130
  },
@@ -37,6 +37,7 @@ module.exports = [
37
37
  'sort-imports': 'off',
38
38
  'import/order': 'off',
39
39
  'import/no-amd': 'off',
40
+ 'import/no-cycle': 'off',
40
41
  'import/no-named-as-default': 'off',
41
42
  'import/newline-after-import': 'off',
42
43
  'import/extensions': 'off',
@@ -0,0 +1,24 @@
1
+ const mdx = require('eslint-plugin-mdx');
2
+
3
+ /** @type {import('eslint').Linter.Config[]} */
4
+ module.exports = [
5
+ {
6
+ ...mdx.flat,
7
+ files: ['**/*.mdx'],
8
+ processor: mdx.createRemarkProcessor({ lintCodeBlocks: true }),
9
+ rules: {
10
+ ...mdx.flat.rules,
11
+ 'no-secrets/no-secrets': 'off',
12
+ 'react/jsx-no-undef': 'off',
13
+ 'no-unused-vars': 'off',
14
+ 'max-len': 'off',
15
+ },
16
+ },
17
+ {
18
+ ...mdx.flatCodeBlocks,
19
+ rules: {
20
+ ...mdx.flatCodeBlocks.rules,
21
+ '@typescript-eslint/no-unused-vars': 'off',
22
+ },
23
+ },
24
+ ];
@@ -1,75 +1,86 @@
1
1
  const typescript = require('@typescript-eslint/eslint-plugin');
2
2
  const typescriptParser = require('@typescript-eslint/parser');
3
3
 
4
- /** @type {import('eslint').Linter.Config} */
5
- module.exports = {
6
- files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
4
+ /** @type {import('eslint').Linter.Config[]} */
5
+ module.exports = [
6
+ {
7
+ files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
7
8
 
8
- plugins: {
9
- '@typescript-eslint': typescript,
10
- },
9
+ plugins: {
10
+ '@typescript-eslint': typescript,
11
+ },
11
12
 
12
- languageOptions: {
13
- parser: typescriptParser,
14
- },
13
+ languageOptions: {
14
+ parser: typescriptParser,
15
+ },
15
16
 
16
- rules: {
17
- ...typescript.configs.recommended.rules,
17
+ rules: {
18
+ ...typescript.configs.recommended.rules,
18
19
 
19
- // error
20
- '@typescript-eslint/no-empty-interface': [
21
- 'error',
22
- {
23
- // Allow `interface T extends U {}`
24
- allowSingleExtends: true,
25
- },
26
- ],
27
- '@typescript-eslint/no-empty-object-type': [
28
- 'error',
29
- {
30
- // Allow `interface T extends U {}`
31
- allowInterfaces: 'with-single-extends',
32
- },
33
- ],
34
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
35
- '@typescript-eslint/no-unused-vars': [
36
- 'error',
37
- { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true },
38
- ],
39
- '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
20
+ // error
21
+ '@typescript-eslint/no-empty-interface': [
22
+ 'error',
23
+ {
24
+ // Allow `interface T extends U {}`
25
+ allowSingleExtends: true,
26
+ },
27
+ ],
28
+ '@typescript-eslint/no-empty-object-type': [
29
+ 'error',
30
+ {
31
+ // Allow `interface T extends U {}`
32
+ allowInterfaces: 'with-single-extends',
33
+ },
34
+ ],
35
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
36
+ '@typescript-eslint/no-unused-vars': [
37
+ 'error',
38
+ { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true },
39
+ ],
40
+ '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
40
41
 
41
- // off
42
- 'no-undef': 'off',
43
- 'no-shadow': 'off',
44
- 'no-redeclare': 'off',
45
- 'no-unused-vars': 'off',
46
- 'no-use-before-define': 'off',
47
- 'no-dupe-class-members': 'off',
48
- 'no-useless-constructor': 'off',
49
- 'no-empty-function': ['error', { allow: ['constructors'] }],
42
+ // off
43
+ 'no-undef': 'off',
44
+ 'no-shadow': 'off',
45
+ 'no-redeclare': 'off',
46
+ 'no-unused-vars': 'off',
47
+ 'no-use-before-define': 'off',
48
+ 'no-dupe-class-members': 'off',
49
+ 'no-useless-constructor': 'off',
50
+ 'no-empty-function': ['error', { allow: ['constructors'] }],
50
51
 
51
- '@typescript-eslint/explicit-module-boundary-types': 'off',
52
- '@typescript-eslint/no-non-null-assertion': 'off',
53
- '@typescript-eslint/no-explicit-any': 'off',
52
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
53
+ '@typescript-eslint/no-non-null-assertion': 'off',
54
+ '@typescript-eslint/no-explicit-any': 'off',
54
55
 
55
- 'import/no-unresolved': 'off',
56
- 'import/export': 'off',
57
- 'import/named': 'off',
56
+ 'sonarjs/no-redeclare': 'off',
58
57
 
59
- // incompatible with eslint 9
60
- 'import/no-named-as-default-member': 'off',
61
- },
58
+ 'import/no-unresolved': 'off',
59
+ 'import/export': 'off',
60
+ 'import/named': 'off',
62
61
 
63
- settings: {
64
- 'import/parsers': {
65
- '@typescript-eslint/parser': ['.ts', '.tsx'],
62
+ // incompatible with eslint 9
63
+ 'import/no-named-as-default-member': 'off',
66
64
  },
67
- 'import/resolver': {
68
- typescript: {
69
- alwaysTryTypes: true,
70
65
 
71
- project: 'tsconfig.json',
66
+ settings: {
67
+ 'import/parsers': {
68
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
69
+ },
70
+ 'import/resolver': {
71
+ typescript: {
72
+ alwaysTryTypes: true,
73
+
74
+ project: 'tsconfig.json',
75
+ },
72
76
  },
73
77
  },
74
78
  },
75
- };
79
+ {
80
+ files: ['**/*.tsx'],
81
+
82
+ rules: {
83
+ '@typescript-eslint/no-unnecessary-type-constraint': 'off',
84
+ },
85
+ },
86
+ ];
@@ -1,27 +1,42 @@
1
1
  const EXTENSIONS = `{${['js', 'jsx', 'cjs', 'mjs', 'ts', 'tsx', 'cts', 'mts'].join(',')}}`;
2
2
 
3
- /** @type {import('eslint').Linter.Config} */
4
- module.exports = {
5
- files: [
6
- `**/*.test.${EXTENSIONS}`,
7
- `**/*.it.${EXTENSIONS}`,
8
- `**/*.spec.${EXTENSIONS}`,
9
- `**/*.story.${EXTENSIONS}`,
10
- 'config/**',
11
- 'cypress/**',
12
- '.storybook/**',
13
- 'test/**',
14
- 'tests/**',
15
- '__*__/**',
16
- ],
3
+ /** @type {import('eslint').Linter.Config[]} */
4
+ module.exports = [
5
+ {
6
+ files: [
7
+ `**/*.test.${EXTENSIONS}`,
8
+ `**/*.it.${EXTENSIONS}`,
9
+ `**/*.spec.${EXTENSIONS}`,
10
+ `**/*.story.${EXTENSIONS}`,
11
+ `**/*.config.${EXTENSIONS}`,
12
+ 'config/**',
13
+ 'cypress/**',
14
+ '.storybook/**',
15
+ 'test/**',
16
+ 'tests/**',
17
+ '**/__*__/**',
18
+ ],
17
19
 
18
- rules: {
19
- // Strings may end up being duplicated in test files
20
- 'sonarjs/no-duplicate-string': 'off',
21
- 'promise/catch-or-return': 'off',
22
- 'promise/always-return': 'off',
23
- 'promise/no-nesting': 'off',
24
- 'sonarjs/no-clear-text-protocols': 'off',
25
- 'sonarjs/no-nested-functions': 'off',
20
+ rules: {
21
+ // Strings may end up being duplicated in test files
22
+ 'sonarjs/no-duplicate-string': 'off',
23
+ 'promise/catch-or-return': 'off',
24
+ 'promise/always-return': 'off',
25
+ 'promise/no-nesting': 'off',
26
+ 'sonarjs/no-clear-text-protocols': 'off',
27
+ 'sonarjs/no-nested-functions': 'off',
28
+ 'sonarjs/pseudo-random': 'off',
29
+ 'sonarjs/no-useless-react-setstate': 'off',
30
+ 'max-classes-per-file': 'off',
31
+ 'no-restricted-imports': 'off',
32
+ 'no-empty-function': 'off',
33
+ },
26
34
  },
27
- };
35
+ {
36
+ files: [`**/*.config.${EXTENSIONS}`],
37
+
38
+ rules: {
39
+ 'no-restricted-exports': 'off',
40
+ },
41
+ },
42
+ ];