@d-zero/eslint-config 5.0.0-alpha.3 → 5.0.0-alpha.30

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 +131 -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,
@@ -36,14 +57,15 @@ module.exports = {
36
57
  'unicorn/no-array-callback-reference': 0,
37
58
  'unicorn/no-nested-ternary': 0,
38
59
  'unicorn/no-null': 0,
60
+ 'unicorn/no-process-exit': 0,
39
61
  'unicorn/prefer-query-selector': 0,
40
62
  'unicorn/prefer-ternary': 0,
41
63
  'unicorn/prevent-abbreviations': 0,
42
64
 
43
65
  // import
66
+ 'import/no-extraneous-dependencies': 2,
44
67
  'import/no-named-as-default': 0,
45
68
  'import/no-unresolved': 0,
46
- 'import/no-extraneous-dependencies': 2,
47
69
  'import/order': [
48
70
  2,
49
71
  {
@@ -62,19 +84,114 @@ module.exports = {
62
84
  },
63
85
  ],
64
86
 
65
- // sort-class-members
87
+ // Sort Class members
66
88
  'sort-class-members/sort-class-members': [
67
89
  1,
68
90
  {
69
91
  order: [
92
+ '[public-properties]',
93
+ '[public-readonly-properties]',
94
+ '[public-properties-function]',
95
+ '[private-properties]',
96
+ '[private-properties-function]',
97
+ '[accessor-pairs]',
98
+ '[getters]',
99
+ '[setters]',
100
+ 'constructor',
101
+ '[public-methods]',
102
+ '[private-methods]',
103
+ '[protedted-methods]',
70
104
  '[static-properties]',
71
105
  '[static-methods]',
72
- '[properties]',
73
- '[conventional-private-properties]',
74
- 'constructor',
75
- '[methods]',
76
- '[conventional-private-methods]',
106
+ '[everything-else]',
77
107
  ],
108
+ groups: {
109
+ 'public-properties': [
110
+ {
111
+ type: 'property',
112
+ kind: 'nonAccessor',
113
+ static: false,
114
+ private: false,
115
+ override: false,
116
+ readonly: false,
117
+ sort: 'alphabetical',
118
+ },
119
+ ],
120
+ 'public-readonly-properties': [
121
+ {
122
+ type: 'property',
123
+ kind: 'nonAccessor',
124
+ static: false,
125
+ private: false,
126
+ override: false,
127
+ readonly: true,
128
+ sort: 'alphabetical',
129
+ },
130
+ ],
131
+ 'public-properties-function': [
132
+ {
133
+ type: 'property',
134
+ propertyType: 'ArrowFunctionExpression',
135
+ kind: 'nonAccessor',
136
+ static: false,
137
+ private: false,
138
+ accessibility: 'public',
139
+ override: false,
140
+ sort: 'alphabetical',
141
+ },
142
+ ],
143
+ 'private-properties': [
144
+ {
145
+ type: 'property',
146
+ kind: 'nonAccessor',
147
+ static: false,
148
+ private: true,
149
+ override: false,
150
+ sort: 'alphabetical',
151
+ },
152
+ ],
153
+ 'private-properties-function': [
154
+ {
155
+ type: 'property',
156
+ propertyType: 'ArrowFunctionExpression',
157
+ kind: 'nonAccessor',
158
+ static: false,
159
+ private: true,
160
+ accessibility: 'public',
161
+ override: false,
162
+ sort: 'alphabetical',
163
+ },
164
+ ],
165
+ 'public-methods': [
166
+ {
167
+ type: 'method',
168
+ kind: 'nonAccessor',
169
+ static: false,
170
+ private: false,
171
+ override: false,
172
+ sort: 'alphabetical',
173
+ },
174
+ ],
175
+ 'private-methods': [
176
+ {
177
+ name: '/#.+/',
178
+ type: 'method',
179
+ kind: 'nonAccessor',
180
+ static: false,
181
+ private: true,
182
+ override: false,
183
+ sort: 'alphabetical',
184
+ },
185
+ ],
186
+ 'protedted-methods': [
187
+ {
188
+ name: '/_.+/',
189
+ type: 'method',
190
+ static: false,
191
+ sort: 'alphabetical',
192
+ },
193
+ ],
194
+ },
78
195
  accessorPairPositioning: 'getThenSet',
79
196
  },
80
197
  ],
@@ -89,13 +206,11 @@ module.exports = {
89
206
  },
90
207
  overrides: [
91
208
  {
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}'],
209
+ files: [
210
+ '*.{test,spec}.{js,mjs,json}',
211
+ '*.config.{js,mjs,json}',
212
+ '.*rc.{js,mjs,json}',
213
+ ],
99
214
  rules: {
100
215
  'import/no-extraneous-dependencies': 0,
101
216
  },
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.3",
3
+ "version": "5.0.0-alpha.30",
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.19.1",
28
- "@typescript-eslint/parser": "6.19.1",
29
- "eslint": "8.56.0",
30
+ "@typescript-eslint/eslint-plugin": "7.10.0",
31
+ "@typescript-eslint/parser": "7.10.0",
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.2.5",
36
+ "eslint-plugin-regexp": "2.5.0",
37
+ "eslint-plugin-sort-class-members": "1.20.0",
38
+ "eslint-plugin-unicorn": "51.0.1"
39
39
  },
40
- "gitHead": "5defdbdfc5b5afe08035e476f289cbad0c7d2e27"
40
+ "gitHead": "2903f129bcd0a81e03598410c6a65daddcce642e"
41
41
  }