@d-zero/eslint-config 5.0.0-alpha.4 → 5.0.0-alpha.40

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.
Files changed (5) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -2
  3. package/base.js +132 -16
  4. package/index.js +18 -46
  5. package/package.json +12 -12
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 D-ZERO Co., Ltd.
3
+ Copyright (c) 2024 D-ZERO Co., Ltd.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,4 +1,41 @@
1
1
  # `@d-zero/eslint-config`
2
2
 
3
- - 使用: 🆗 使用可
4
- - 解説: 🚧 準備中
3
+ ## 個別インストール
4
+
5
+ ```sh
6
+ yarn add -D @d-zero/eslint-config
7
+ ```
8
+
9
+ ## 使い方
10
+
11
+ `.eslintrc`を作成し、[`extends`](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files)機能を使って読み込みます。
12
+
13
+ ```json
14
+ {
15
+ "extends": ["@d-zero/eslint-config"]
16
+ }
17
+ ```
18
+
19
+ ### 拡張
20
+
21
+ プロジェクトに合わせて設定を追加します。
22
+
23
+ ```json
24
+ {
25
+ "extends": ["@d-zero/eslint-config"],
26
+ "rules": {
27
+ // 例: console.logを許可する
28
+ "no-console": 0
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## JavaScriptのみ
34
+
35
+ :warning: TypeScriptを利用**しない**場合は、`@d-zero/eslint-config`の代わりに`@d-zero/eslint-config/base`を利用します。
36
+
37
+ ```json
38
+ {
39
+ "extends": ["@d-zero/eslint-config/base"]
40
+ }
41
+ ```
package/base.js CHANGED
@@ -22,10 +22,31 @@ module.exports = {
22
22
  },
23
23
  rules: {
24
24
  // Standard
25
- 'no-var': 2,
26
- 'no-unused-vars': 0,
27
25
  'no-console': 'warn',
28
26
  'no-mixed-spaces-and-tabs': 0,
27
+ 'no-restricted-syntax': [
28
+ 2,
29
+ {
30
+ selector:
31
+ ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
32
+ message: 'Use #private instead',
33
+ },
34
+ {
35
+ selector:
36
+ ':matches(PropertyDefinition, MethodDefinition)[accessibility="public"]',
37
+ message: 'Remove public keyword',
38
+ },
39
+ {
40
+ selector: 'MethodDefinition[key.name=/^_/]:not([accessibility="protected"])',
41
+ message: 'Add protected keyword',
42
+ },
43
+ {
44
+ selector: 'MethodDefinition:not([key.name=/^_/])[accessibility="protected"]',
45
+ message: 'Start with `_` if you want to use protected',
46
+ },
47
+ ],
48
+ 'no-unused-vars': 0,
49
+ 'no-var': 2,
29
50
  'prefer-const': 2,
30
51
  'prefer-rest-params': 2,
31
52
  'prefer-spread': 2,
@@ -33,17 +54,19 @@ module.exports = {
33
54
  // Unicorn
34
55
  'unicorn/consistent-destructuring': 0,
35
56
  'unicorn/consistent-function-scoping': 0,
57
+ 'unicorn/no-anonymous-default-export': 0,
36
58
  'unicorn/no-array-callback-reference': 0,
37
59
  'unicorn/no-nested-ternary': 0,
38
60
  'unicorn/no-null': 0,
61
+ 'unicorn/no-process-exit': 0,
39
62
  'unicorn/prefer-query-selector': 0,
40
63
  'unicorn/prefer-ternary': 0,
41
64
  'unicorn/prevent-abbreviations': 0,
42
65
 
43
66
  // import
67
+ 'import/no-extraneous-dependencies': 2,
44
68
  'import/no-named-as-default': 0,
45
69
  'import/no-unresolved': 0,
46
- 'import/no-extraneous-dependencies': 2,
47
70
  'import/order': [
48
71
  2,
49
72
  {
@@ -62,19 +85,114 @@ module.exports = {
62
85
  },
63
86
  ],
64
87
 
65
- // sort-class-members
88
+ // Sort Class members
66
89
  'sort-class-members/sort-class-members': [
67
90
  1,
68
91
  {
69
92
  order: [
93
+ '[public-properties]',
94
+ '[public-readonly-properties]',
95
+ '[public-properties-function]',
96
+ '[private-properties]',
97
+ '[private-properties-function]',
98
+ '[accessor-pairs]',
99
+ '[getters]',
100
+ '[setters]',
101
+ 'constructor',
102
+ '[public-methods]',
103
+ '[private-methods]',
104
+ '[protedted-methods]',
70
105
  '[static-properties]',
71
106
  '[static-methods]',
72
- '[properties]',
73
- '[conventional-private-properties]',
74
- 'constructor',
75
- '[methods]',
76
- '[conventional-private-methods]',
107
+ '[everything-else]',
77
108
  ],
109
+ groups: {
110
+ 'public-properties': [
111
+ {
112
+ type: 'property',
113
+ kind: 'nonAccessor',
114
+ static: false,
115
+ private: false,
116
+ override: false,
117
+ readonly: false,
118
+ sort: 'alphabetical',
119
+ },
120
+ ],
121
+ 'public-readonly-properties': [
122
+ {
123
+ type: 'property',
124
+ kind: 'nonAccessor',
125
+ static: false,
126
+ private: false,
127
+ override: false,
128
+ readonly: true,
129
+ sort: 'alphabetical',
130
+ },
131
+ ],
132
+ 'public-properties-function': [
133
+ {
134
+ type: 'property',
135
+ propertyType: 'ArrowFunctionExpression',
136
+ kind: 'nonAccessor',
137
+ static: false,
138
+ private: false,
139
+ accessibility: 'public',
140
+ override: false,
141
+ sort: 'alphabetical',
142
+ },
143
+ ],
144
+ 'private-properties': [
145
+ {
146
+ type: 'property',
147
+ kind: 'nonAccessor',
148
+ static: false,
149
+ private: true,
150
+ override: false,
151
+ sort: 'alphabetical',
152
+ },
153
+ ],
154
+ 'private-properties-function': [
155
+ {
156
+ type: 'property',
157
+ propertyType: 'ArrowFunctionExpression',
158
+ kind: 'nonAccessor',
159
+ static: false,
160
+ private: true,
161
+ accessibility: 'public',
162
+ override: false,
163
+ sort: 'alphabetical',
164
+ },
165
+ ],
166
+ 'public-methods': [
167
+ {
168
+ type: 'method',
169
+ kind: 'nonAccessor',
170
+ static: false,
171
+ private: false,
172
+ override: false,
173
+ sort: 'alphabetical',
174
+ },
175
+ ],
176
+ 'private-methods': [
177
+ {
178
+ name: '/#.+/',
179
+ type: 'method',
180
+ kind: 'nonAccessor',
181
+ static: false,
182
+ private: true,
183
+ override: false,
184
+ sort: 'alphabetical',
185
+ },
186
+ ],
187
+ 'protedted-methods': [
188
+ {
189
+ name: '/_.+/',
190
+ type: 'method',
191
+ static: false,
192
+ sort: 'alphabetical',
193
+ },
194
+ ],
195
+ },
78
196
  accessorPairPositioning: 'getThenSet',
79
197
  },
80
198
  ],
@@ -89,13 +207,11 @@ module.exports = {
89
207
  },
90
208
  overrides: [
91
209
  {
92
- files: '**/*.spec.*',
93
- rules: {
94
- 'import/no-extraneous-dependencies': 0,
95
- },
96
- },
97
- {
98
- files: ['*.config.{js,mjs,json,ts}', '.*rc.{js,mjs,json,ts}'],
210
+ files: [
211
+ '*.{test,spec}.{js,mjs,json}',
212
+ '*.config.{js,mjs,json}',
213
+ '.*rc.{js,mjs,json}',
214
+ ],
99
215
  rules: {
100
216
  'import/no-extraneous-dependencies': 0,
101
217
  },
package/index.js CHANGED
@@ -6,8 +6,9 @@ const base = require('./base');
6
6
  module.exports = {
7
7
  ...base,
8
8
  overrides: [
9
+ ...base.overrides,
9
10
  {
10
- files: '**/*.{ts,tsx}',
11
+ files: ['*.{ts,tsx}', '**/*.{ts,tsx}'],
11
12
  extends: ['plugin:import/typescript', 'plugin:@typescript-eslint/recommended'],
12
13
  plugins: ['@typescript-eslint', ...base.plugins],
13
14
  parser: '@typescript-eslint/parser',
@@ -24,55 +25,26 @@ module.exports = {
24
25
  rules: {
25
26
  ...base.rules,
26
27
  // @typescript-eslint
27
- '@typescript-eslint/no-unused-vars': 2,
28
- '@typescript-eslint/no-array-constructor': 2,
29
28
  '@typescript-eslint/adjacent-overload-signatures': 2,
29
+ '@typescript-eslint/ban-ts-comment': 0,
30
+ '@typescript-eslint/consistent-type-imports': 1,
31
+ '@typescript-eslint/member-ordering': 0,
32
+ '@typescript-eslint/no-array-constructor': 2,
33
+ '@typescript-eslint/no-explicit-any': [1, { fixToUnknown: true }],
34
+ '@typescript-eslint/no-floating-promises': 2,
30
35
  '@typescript-eslint/no-namespace': [2, { allowDeclarations: true }],
31
- '@typescript-eslint/prefer-namespace-keyword': 2,
32
- '@typescript-eslint/no-var-requires': 2,
33
36
  '@typescript-eslint/no-unnecessary-type-assertion': 2,
34
- '@typescript-eslint/restrict-plus-operands': 0,
35
- '@typescript-eslint/consistent-type-imports': 1,
37
+ '@typescript-eslint/no-unused-vars': 2,
38
+ '@typescript-eslint/no-var-requires': 2,
39
+ '@typescript-eslint/prefer-namespace-keyword': 2,
36
40
  '@typescript-eslint/require-await': 2,
37
- '@typescript-eslint/no-floating-promises': 2,
38
- '@typescript-eslint/member-ordering': [
39
- 'warn',
40
- {
41
- default: 'never',
42
- classes: {
43
- memberTypes: [
44
- 'public-static-field',
45
- 'protected-static-field',
46
- 'private-static-field',
47
- 'public-static-method',
48
- 'protected-static-method',
49
- 'public-static-get',
50
- 'protected-static-get',
51
- 'private-static-get',
52
- 'public-instance-field',
53
- 'protected-instance-field',
54
- 'private-instance-field',
55
- 'public-abstract-field',
56
- 'protected-abstract-field',
57
- 'public-constructor',
58
- 'protected-constructor',
59
- 'private-constructor',
60
- ['public-abstract-get', 'public-abstract-set'],
61
- ['protected-abstract-get', 'protected-abstract-set'],
62
- ['public-instance-get', 'public-instance-set'],
63
- ['protected-instance-get', 'protected-instance-set'],
64
- ['private-instance-get', 'private-instance-set'],
65
- 'public-abstract-method',
66
- 'protected-abstract-method',
67
- 'public-instance-method',
68
- 'protected-instance-method',
69
- 'private-instance-method',
70
- 'private-static-method',
71
- ],
72
- order: 'alphabetically',
73
- },
74
- },
75
- ],
41
+ '@typescript-eslint/restrict-plus-operands': 0,
42
+ },
43
+ },
44
+ {
45
+ files: ['*.{test,spec}.{ts,mts,tsx}'],
46
+ rules: {
47
+ 'import/no-extraneous-dependencies': 0,
76
48
  },
77
49
  },
78
50
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/eslint-config",
3
- "version": "5.0.0-alpha.4",
3
+ "version": "5.0.0-alpha.40",
4
4
  "description": "Configurations of ESLint",
5
5
  "repository": "https://github.com/d-zero-dev/linters.git",
6
6
  "author": "D-ZERO Co., Ltd.",
@@ -9,6 +9,9 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
+ "engines": {
13
+ "node": ">=22.0.0"
14
+ },
12
15
  "files": [
13
16
  "index.js",
14
17
  "base.js"
@@ -24,18 +27,15 @@
24
27
  }
25
28
  },
26
29
  "dependencies": {
27
- "@typescript-eslint/eslint-plugin": "6.20.0",
28
- "@typescript-eslint/parser": "6.20.0",
29
- "eslint": "8.56.0",
30
+ "@typescript-eslint/eslint-plugin": "7.16.1",
31
+ "@typescript-eslint/parser": "7.16.1",
32
+ "eslint": "8.57.0",
30
33
  "eslint-plugin-eslint-comments": "3.2.0",
31
34
  "eslint-plugin-import": "2.29.1",
32
- "eslint-plugin-jsdoc": "48.0.4",
33
- "eslint-plugin-regexp": "2.2.0",
34
- "eslint-plugin-sort-class-members": "1.19.0",
35
- "eslint-plugin-unicorn": "50.0.1"
36
- },
37
- "peerDependencies": {
38
- "@d-zero/tsconfig": ">= 5"
35
+ "eslint-plugin-jsdoc": "48.7.0",
36
+ "eslint-plugin-regexp": "2.6.0",
37
+ "eslint-plugin-sort-class-members": "1.20.0",
38
+ "eslint-plugin-unicorn": "54.0.0"
39
39
  },
40
- "gitHead": "de8f9c035cfb70bbf4cc5b203869dc39427c9d3a"
40
+ "gitHead": "7c0ce7713b288098b230e149502cd1fe910b4468"
41
41
  }