@d-zero/eslint-config 5.0.0-alpha.5 → 5.0.0-alpha.50

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 +134 -16
  4. package/index.js +18 -46
  5. package/package.json +13 -13
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
+ npm install -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,21 @@ 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,
62
+ 'unicorn/prefer-global-this': 0,
39
63
  'unicorn/prefer-query-selector': 0,
64
+ 'unicorn/prefer-string-raw': 0,
40
65
  'unicorn/prefer-ternary': 0,
41
66
  'unicorn/prevent-abbreviations': 0,
42
67
 
43
68
  // import
69
+ 'import/no-extraneous-dependencies': 2,
44
70
  'import/no-named-as-default': 0,
45
71
  'import/no-unresolved': 0,
46
- 'import/no-extraneous-dependencies': 2,
47
72
  'import/order': [
48
73
  2,
49
74
  {
@@ -62,19 +87,114 @@ module.exports = {
62
87
  },
63
88
  ],
64
89
 
65
- // sort-class-members
90
+ // Sort Class members
66
91
  'sort-class-members/sort-class-members': [
67
92
  1,
68
93
  {
69
94
  order: [
95
+ '[public-properties]',
96
+ '[public-readonly-properties]',
97
+ '[public-properties-function]',
98
+ '[private-properties]',
99
+ '[private-properties-function]',
100
+ '[accessor-pairs]',
101
+ '[getters]',
102
+ '[setters]',
103
+ 'constructor',
104
+ '[public-methods]',
105
+ '[private-methods]',
106
+ '[protedted-methods]',
70
107
  '[static-properties]',
71
108
  '[static-methods]',
72
- '[properties]',
73
- '[conventional-private-properties]',
74
- 'constructor',
75
- '[methods]',
76
- '[conventional-private-methods]',
109
+ '[everything-else]',
77
110
  ],
111
+ groups: {
112
+ 'public-properties': [
113
+ {
114
+ type: 'property',
115
+ kind: 'nonAccessor',
116
+ static: false,
117
+ private: false,
118
+ override: false,
119
+ readonly: false,
120
+ sort: 'alphabetical',
121
+ },
122
+ ],
123
+ 'public-readonly-properties': [
124
+ {
125
+ type: 'property',
126
+ kind: 'nonAccessor',
127
+ static: false,
128
+ private: false,
129
+ override: false,
130
+ readonly: true,
131
+ sort: 'alphabetical',
132
+ },
133
+ ],
134
+ 'public-properties-function': [
135
+ {
136
+ type: 'property',
137
+ propertyType: 'ArrowFunctionExpression',
138
+ kind: 'nonAccessor',
139
+ static: false,
140
+ private: false,
141
+ accessibility: 'public',
142
+ override: false,
143
+ sort: 'alphabetical',
144
+ },
145
+ ],
146
+ 'private-properties': [
147
+ {
148
+ type: 'property',
149
+ kind: 'nonAccessor',
150
+ static: false,
151
+ private: true,
152
+ override: false,
153
+ sort: 'alphabetical',
154
+ },
155
+ ],
156
+ 'private-properties-function': [
157
+ {
158
+ type: 'property',
159
+ propertyType: 'ArrowFunctionExpression',
160
+ kind: 'nonAccessor',
161
+ static: false,
162
+ private: true,
163
+ accessibility: 'public',
164
+ override: false,
165
+ sort: 'alphabetical',
166
+ },
167
+ ],
168
+ 'public-methods': [
169
+ {
170
+ type: 'method',
171
+ kind: 'nonAccessor',
172
+ static: false,
173
+ private: false,
174
+ override: false,
175
+ sort: 'alphabetical',
176
+ },
177
+ ],
178
+ 'private-methods': [
179
+ {
180
+ name: '/#.+/',
181
+ type: 'method',
182
+ kind: 'nonAccessor',
183
+ static: false,
184
+ private: true,
185
+ override: false,
186
+ sort: 'alphabetical',
187
+ },
188
+ ],
189
+ 'protedted-methods': [
190
+ {
191
+ name: '/_.+/',
192
+ type: 'method',
193
+ static: false,
194
+ sort: 'alphabetical',
195
+ },
196
+ ],
197
+ },
78
198
  accessorPairPositioning: 'getThenSet',
79
199
  },
80
200
  ],
@@ -89,13 +209,11 @@ module.exports = {
89
209
  },
90
210
  overrides: [
91
211
  {
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}'],
212
+ files: [
213
+ '*.{test,spec}.{js,mjs,json}',
214
+ '*.config.{js,mjs,json}',
215
+ '.*rc.{js,mjs,json}',
216
+ ],
99
217
  rules: {
100
218
  'import/no-extraneous-dependencies': 0,
101
219
  },
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.5",
3
+ "version": "5.0.0-alpha.50",
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": "8.12.2",
31
+ "@typescript-eslint/parser": "8.12.2",
32
+ "eslint": "8.57.1",
30
33
  "eslint-plugin-eslint-comments": "3.2.0",
31
- "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"
34
+ "eslint-plugin-import": "2.31.0",
35
+ "eslint-plugin-jsdoc": "50.4.3",
36
+ "eslint-plugin-regexp": "2.6.0",
37
+ "eslint-plugin-sort-class-members": "1.21.0",
38
+ "eslint-plugin-unicorn": "56.0.0"
39
39
  },
40
- "gitHead": "acd0dda9a721e7de76f4893add2c5dcb3ffa6270"
40
+ "gitHead": "3a4066e697bbacc9c8c55decd27c784818dd76c8"
41
41
  }