@w0s/eslint-config 6.0.2 → 7.0.0-rc.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 CHANGED
@@ -5,22 +5,17 @@
5
5
 
6
6
  ESLint configuration file used on my personal website ([w0s.jp](https://github.com/SaekiTominaga/w0s.jp)).
7
7
 
8
- ## `extends`
8
+ ## Base rules & plugins
9
9
 
10
10
  - [eslint:recommended](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#using-eslintrecommended)
11
- - [eslint-config-airbnb-base](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)
12
- - [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import)
13
- - [plugin:jsdoc/recommended](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/src/index.js)
11
+ - [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import)
12
+ - [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc):recommended
14
13
 
15
- ### TypeScript file
14
+ ### TypeScript
16
15
 
17
- - [plugin:@typescript-eslint/strict-type-checked](https://typescript-eslint.io/users/configs/#strict-type-checked)
18
- - [plugin:@typescript-eslint/stylistic-type-checked](https://typescript-eslint.io/users/configs/#stylistic-type-checked)
19
- - [plugin:jsdoc/recommended-typescript](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/src/index.js)
20
-
21
- ## `plugins`
22
-
23
- - [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
16
+ - [@typescript-eslint/eslint-plugin:strict-type-checked](https://typescript-eslint.io/users/configs/#strict-type-checked)
17
+ - [@typescript-eslint/eslint-plugin:stylistic-type-checked](https://typescript-eslint.io/users/configs/#stylistic-type-checked)
18
+ - [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc/):recommended-typescript
24
19
 
25
20
  ## Usage
26
21
 
package/eslint.config.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // @ts-check
2
2
 
3
- import { FlatCompat } from '@eslint/eslintrc';
4
- import eslintJs from '@eslint/js';
5
3
  import pluginJsdoc from 'eslint-plugin-jsdoc';
4
+ import globals from 'globals';
6
5
  import tseslint from 'typescript-eslint';
6
+ import { FlatCompat } from '@eslint/eslintrc';
7
+ import eslintJs from '@eslint/js';
7
8
  import pluginTypeScript from '@typescript-eslint/eslint-plugin';
8
9
  import parserTypeScript from '@typescript-eslint/parser';
9
10
  import configEslintLayoutFormatting from './rules/eslint/layout&formatting.js';
@@ -16,21 +17,35 @@ const compat = new FlatCompat();
16
17
 
17
18
  /** @type {import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray} */
18
19
  export default tseslint.config(
20
+ {
21
+ plugins: {
22
+ pluginJsdoc,
23
+ },
24
+ },
25
+
19
26
  eslintJs.configs.recommended,
20
- ...compat.config({ extends: 'eslint-config-airbnb-base' }),
21
27
  configEslintPossibleProblems,
22
28
  configEslintSuggestions,
23
29
  configEslintLayoutFormatting,
24
- configImport,
25
- ...tseslint.configs.recommended,
30
+
31
+ /* Plugins */
32
+ // @ts-expect-error: ts(2345)
33
+ ...compat.plugins('eslint-plugin-import'),
34
+ ...compat.config({
35
+ plugins: ['eslint-plugin-import'],
36
+ extends: 'plugin:import/recommended',
37
+ }),
26
38
  pluginJsdoc.configs['flat/recommended'],
39
+ configImport,
27
40
  configJsdoc,
41
+
42
+ /* TypeScript */
43
+ ...tseslint.configs.recommended,
44
+
28
45
  {
46
+ files: ['**/*.js', '**/*.mjs'],
29
47
  languageOptions: {
30
- ecmaVersion: 'latest', // TODO: デフォルト値は latest だが、明示的に指定しないと Top-level await で Parsing error が発生する
31
- },
32
- plugins: {
33
- pluginJsdoc,
48
+ globals: globals.nodeBuiltin,
34
49
  },
35
50
  },
36
51
  {
@@ -46,6 +61,7 @@ export default tseslint.config(
46
61
  ...pluginTypeScript.configs['stylistic-type-checked'].rules,
47
62
  ...pluginJsdoc.configs['flat/recommended-typescript'].rules,
48
63
  'dot-notation': 'off',
64
+ 'import/no-unresolved': 'off',
49
65
  '@typescript-eslint/dot-notation': 'off',
50
66
  '@typescript-eslint/no-extraneous-class': 'off',
51
67
  '@typescript-eslint/no-non-null-assertion': 'off',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w0s/eslint-config",
3
- "version": "6.0.2",
3
+ "version": "7.0.0-rc.1",
4
4
  "description": "ESLint configuration file used on w0s.jp",
5
5
  "keywords": [
6
6
  "eslint",
@@ -20,15 +20,17 @@
20
20
  "url": "git+https://github.com/SaekiTominaga/config.git"
21
21
  },
22
22
  "scripts": {
23
- "test": "node __tests__/index.test.js"
23
+ "test": "node __tests__/index.test.js",
24
+ "lint": "eslint eslint.config.js --rule {'import/no-unresolved':'off'}"
24
25
  },
25
26
  "dependencies": {
26
27
  "@eslint/eslintrc": "^3.1.0",
27
28
  "@eslint/js": "^8.57.0",
28
29
  "@typescript-eslint/eslint-plugin": "^7.17.0",
29
30
  "@typescript-eslint/parser": "^7.17.0",
30
- "eslint-config-airbnb-base": "^15.0.0",
31
+ "eslint-plugin-import": "^2.29.1",
31
32
  "eslint-plugin-jsdoc": "^48.8.3",
33
+ "globals": "^15.8.0",
32
34
  "typescript-eslint": "^7.17.0"
33
35
  },
34
36
  "devDependencies": {
@@ -3,34 +3,6 @@
3
3
  /** @type {import("eslint").Linter.FlatConfig} */
4
4
  export default {
5
5
  rules: {
6
- 'comma-dangle': ['error', 'always-multiline'],
7
- 'function-paren-newline': 'off',
8
- 'implicit-arrow-linebreak': 'off',
9
- indent: [
10
- 'error',
11
- 'tab',
12
- {
13
- SwitchCase: 1,
14
- },
15
- ],
16
- 'max-len': 'off',
17
- 'newline-per-chained-call': 'off',
18
- 'no-tabs': [
19
- 'error',
20
- {
21
- allowIndentationTabs: true,
22
- },
23
- ],
24
- 'object-curly-newline': 'off',
25
- 'operator-linebreak': [
26
- 'error',
27
- 'after',
28
- {
29
- overrides: {
30
- '?': 'before',
31
- ':': 'before',
32
- },
33
- },
34
- ],
6
+ 'unicode-bom': 'error',
35
7
  },
36
8
  };
@@ -3,7 +3,16 @@
3
3
  /** @type {import("eslint").Linter.FlatConfig} */
4
4
  export default {
5
5
  rules: {
6
- 'no-await-in-loop': 'error',
6
+ 'array-callback-return': [
7
+ 'error',
8
+ {
9
+ allowImplicit: true,
10
+ },
11
+ ], // eslint-config-airbnb-base@15.0.0; best-practices
12
+ 'no-await-in-loop': 'error', // eslint-config-airbnb-base@15.0.0; errors
13
+ 'no-cond-assign': ['error', 'always'], // eslint-config-airbnb-base@15.0.0; errors
14
+ 'no-console': 'warn', // eslint-config-airbnb-base@15.0.0; errors
15
+ 'no-constructor-return': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
7
16
  'no-irregular-whitespace': [
8
17
  'error',
9
18
  {
@@ -12,5 +21,21 @@ export default {
12
21
  skipTemplates: true,
13
22
  },
14
23
  ],
24
+ 'no-promise-executor-return': 'error', // eslint-config-airbnb-base@15.0.0; errors
25
+ 'no-self-compare': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
26
+ 'no-template-curly-in-string': 'error', // eslint-config-airbnb-base@15.0.0; errors
27
+ 'no-unmodified-loop-condition': 'error',
28
+ 'no-unsafe-optional-chaining': [
29
+ 'error',
30
+ {
31
+ disallowArithmeticOperators: true,
32
+ },
33
+ ], // eslint-config-airbnb-base@15.0.0; errors
34
+ 'valid-typeof': [
35
+ 'error',
36
+ {
37
+ requireStringLiterals: true,
38
+ },
39
+ ], // eslint-config-airbnb-base@15.0.0; errors
15
40
  },
16
41
  };
@@ -3,35 +3,146 @@
3
3
  /** @type {import("eslint").Linter.FlatConfig} */
4
4
  export default {
5
5
  rules: {
6
- curly: 'error',
7
- eqeqeq: 'error',
8
- 'no-continue': 'error',
9
- 'no-else-return': [
6
+ 'arrow-body-style': 'error', // eslint-config-airbnb-base@15.0.0; es6
7
+ 'block-scoped-var': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
8
+ camelcase: [
10
9
  'error',
11
10
  {
12
- allowElseIf: true,
11
+ properties: 'never',
13
12
  },
14
- ],
13
+ ], // eslint-config-airbnb-base@15.0.0; style
14
+ 'class-methods-use-this': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
15
+ 'consistent-return': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
16
+ curly: 'error',
17
+ 'default-case': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
18
+ 'default-case-last': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
19
+ 'default-param-last': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
20
+ 'dot-notation': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
21
+ eqeqeq: 'error',
22
+ 'func-names': 'warn', // eslint-config-airbnb-base@15.0.0; style
23
+ 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
24
+ 'guard-for-in': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
25
+ 'max-classes-per-file': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
26
+ 'new-cap': 'error',
27
+ 'no-alert': 'warn', // eslint-config-airbnb-base@15.0.0; best-practices
28
+ 'no-array-constructor': 'error', // eslint-config-airbnb-base@15.0.0; style
29
+ 'no-bitwise': 'error', // eslint-config-airbnb-base@15.0.0; style
30
+ 'no-caller': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
31
+ 'no-continue': 'error', // eslint-config-airbnb-base@15.0.0; style
32
+ 'no-else-return': 'error',
15
33
  'no-empty': [
16
34
  'error',
17
35
  {
18
36
  allowEmptyCatch: true,
19
37
  },
20
- ],
38
+ ], // ✅
39
+ 'no-empty-function': 'error',
40
+ 'no-empty-static-block': 'error',
41
+ 'no-eval': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
42
+ 'no-extend-native': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
43
+ 'no-extra-bind': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
44
+ 'no-extra-label': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
21
45
  'no-implicit-coercion': 'error',
46
+ 'no-implicit-globals': 'error',
47
+ 'no-implied-eval': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
22
48
  'no-invalid-this': 'error',
49
+ 'no-iterator': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
50
+ 'no-label-var': 'error', // eslint-config-airbnb-base@15.0.0; variables
51
+ 'no-labels': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
52
+ 'no-lone-blocks': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
53
+ 'no-lonely-if': 'error', // eslint-config-airbnb-base@15.0.0; style
54
+ 'no-loop-func': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
55
+ 'no-multi-assign': 'error', // eslint-config-airbnb-base@15.0.0; style
56
+ 'no-multi-str': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
57
+ 'no-nested-ternary': 'error', // eslint-config-airbnb-base@15.0.0; style
58
+ 'no-new': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
59
+ 'no-new-func': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
60
+ 'no-new-wrappers': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
61
+ 'no-object-constructor': 'error',
62
+ 'no-octal-escape': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
23
63
  'no-param-reassign': [
24
64
  'error',
25
65
  {
26
66
  props: false,
27
67
  },
28
68
  ],
29
- 'no-restricted-globals': 'off',
30
- 'no-restricted-syntax': 'off',
31
- 'no-return-assign': 'error',
69
+ 'no-plusplus': 'error', // eslint-config-airbnb-base@15.0.0; style
70
+ 'no-proto': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
71
+ 'no-restricted-globals': ['error', 'isFinite', 'isNaN'], // eslint-config-airbnb-base@15.0.0; variables
72
+ 'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], // eslint-config-airbnb-base@15.0.0; style
73
+ 'no-return-assign': ['error', 'always'], // eslint-config-airbnb-base@15.0.0; best-practices
74
+ 'no-script-url': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
75
+ 'no-sequences': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
76
+ 'no-shadow': 'error', // eslint-config-airbnb-base@15.0.0; variables
77
+ 'no-throw-literal': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
78
+ 'no-undef-init': 'error', // eslint-config-airbnb-base@15.0.0; variables
79
+ 'no-underscore-dangle': 'error', // eslint-config-airbnb-base@15.0.0; style
80
+ 'no-unneeded-ternary': [
81
+ 'error',
82
+ {
83
+ defaultAssignment: false,
84
+ },
85
+ ], // eslint-config-airbnb-base@15.0.0; style
86
+ 'no-unused-expressions': [
87
+ 'error',
88
+ {
89
+ allowShortCircuit: false,
90
+ allowTernary: false,
91
+ allowTaggedTemplates: false,
92
+ },
93
+ ], // eslint-config-airbnb-base@15.0.0; best-practices
94
+ 'no-unused-vars': 'error',
95
+ 'no-use-before-define': 'error', // eslint-config-airbnb-base@15.0.0; variables
96
+ 'no-useless-computed-key': 'error', // eslint-config-airbnb-base@15.0.0; es6
97
+ 'no-useless-constructor': 'error', // eslint-config-airbnb-base@15.0.0; es6
98
+ 'no-useless-rename': 'error', // eslint-config-airbnb-base@15.0.0; es6
32
99
  'no-useless-call': 'error',
100
+ 'no-useless-concat': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
101
+ 'no-useless-return': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
102
+ 'no-var': 'error', // eslint-config-airbnb-base@15.0.0; es6
103
+ 'no-void': 'error', // eslint-config-airbnb-base@15.0.0; best-practices
33
104
  'object-shorthand': ['error', 'methods'],
34
- 'prefer-const': 'error',
35
- strict: ['error', 'safe'],
105
+ 'one-var': ['error', 'never'], // eslint-config-airbnb-base@15.0.0; style
106
+ 'operator-assignment': ['error', 'always'], // eslint-config-airbnb-base@15.0.0; style
107
+ 'prefer-arrow-callback': 'error', // eslint-config-airbnb-base@15.0.0; es6
108
+ 'prefer-const': [
109
+ 'error',
110
+ {
111
+ destructuring: 'any',
112
+ ignoreReadBeforeAssign: true,
113
+ },
114
+ ], // eslint-config-airbnb-base@15.0.0; es6
115
+ 'prefer-destructuring': [
116
+ 'error',
117
+ {
118
+ VariableDeclarator: {
119
+ array: false,
120
+ object: true,
121
+ },
122
+ AssignmentExpression: {
123
+ array: true,
124
+ object: false,
125
+ },
126
+ },
127
+ ], // eslint-config-airbnb-base@15.0.0; es6
128
+ 'prefer-exponentiation-operator': 'error', // eslint-config-airbnb-base@15.0.0; style
129
+ 'prefer-numeric-literals': 'error', // eslint-config-airbnb-base@15.0.0; es6
130
+ 'prefer-object-has-own': 'error',
131
+ 'prefer-object-spread': 'error', // eslint-config-airbnb-base@15.0.0; style
132
+ 'prefer-promise-reject-errors': 'error',
133
+ 'prefer-regex-literals': [
134
+ 'error',
135
+ {
136
+ disallowRedundantWrapping: true,
137
+ },
138
+ ], // eslint-config-airbnb-base@15.0.0; best-practices
139
+ 'prefer-rest-params': 'error', // eslint-config-airbnb-base@15.0.0; es6
140
+ 'prefer-spread': 'error', // eslint-config-airbnb-base@15.0.0; es6
141
+ 'prefer-template': 'error', // eslint-config-airbnb-base@15.0.0; es6
142
+ radix: 'error', // eslint-config-airbnb-base@15.0.0; best-practices
143
+ 'require-await': 'error',
144
+ strict: 'error',
145
+ 'symbol-description': 'error', // eslint-config-airbnb-base@15.0.0; es6
146
+ yoda: 'error', // eslint-config-airbnb-base@15.0.0; best-practices
36
147
  },
37
148
  };
package/rules/import.js CHANGED
@@ -3,7 +3,64 @@
3
3
  /** @type {import("eslint").Linter.FlatConfig} */
4
4
  export default {
5
5
  rules: {
6
- 'import/no-unresolved': 'off',
7
- 'import/extensions': 'off',
6
+ /* Helpful warnings */
7
+ // ✅ import/export
8
+ // import/no-deprecated TODO: parserPath or languageOptions.parser is required!
9
+ 'import/no-empty-named-blocks': 'error',
10
+ 'import/no-extraneous-dependencies': [
11
+ 'error',
12
+ {
13
+ devDependencies: false,
14
+ optionalDependencies: false,
15
+ peerDependencies: false,
16
+ bundledDependencies: false,
17
+ },
18
+ ],
19
+ 'import/no-mutable-exports': 'error',
20
+ 'import/no-named-as-default': 'off', // ✅ TODO: parserPath or languageOptions.parser is required!
21
+ 'import/no-named-as-default-member': 'off', // ✅ TODO: parserPath or languageOptions.parser is required!
22
+ // import/no-unused-modules
23
+
24
+ /* Module systems */
25
+ // import/no-amd
26
+ // import/no-commonjs
27
+ // import/no-import-module-exports
28
+ // import/no-nodejs-modules
29
+ // import/unambiguous
30
+
31
+ /* Static analysis */
32
+ 'import/default': 'off', // ✅ TODO: parserPath or languageOptions.parser is required!
33
+ // ✅ import/named
34
+ 'import/namespace': 'off', // ✅ TODO: parserPath or languageOptions.parser is required!
35
+ 'import/no-absolute-path': 'error',
36
+ // import/no-cycle ⚠ This rule is comparatively computationally expensive
37
+ // import/no-dynamic-require
38
+ // import/no-internal-modules
39
+ // import/no-relative-packages
40
+ // import/no-relative-parent-imports
41
+ // import/no-restricted-paths
42
+ 'import/no-self-import': 'error',
43
+ // ✅ import/no-unresolved
44
+ 'import/no-useless-path-segments': 'error',
45
+ 'import/no-webpack-loader-syntax': 'error',
46
+
47
+ /* Style guide */
48
+ // import/consistent-type-specifier-style
49
+ // import/dynamic-import-chunkname
50
+ // import/exports-last
51
+ 'import/extensions': ['error', 'ignorePackages'],
52
+ 'import/first': 'error',
53
+ // import/group-exports
54
+ // import/max-dependencies
55
+ 'import/newline-after-import': 'error',
56
+ // import/no-anonymous-default-export
57
+ // import/no-default-export
58
+ // ✅ import/no-duplicates
59
+ 'import/no-named-default': 'error',
60
+ // import/no-named-export
61
+ // import/no-namespace
62
+ 'import/no-unassigned-import': 'error',
63
+ 'import/order': 'error',
64
+ 'import/prefer-default-export': 'error',
8
65
  },
9
66
  };
package/rules/jsdoc.js CHANGED
@@ -3,6 +3,12 @@
3
3
  /** @type {import("eslint").Linter.FlatConfig} */
4
4
  export default {
5
5
  rules: {
6
- 'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }], // Recommended
6
+ 'jsdoc/tag-lines': [
7
+ 'warn',
8
+ 'any',
9
+ {
10
+ startLines: 1,
11
+ },
12
+ ], // Recommended
7
13
  },
8
14
  };