@hyperupcall/eslint-config 1.4.1 → 2.0.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/.editorconfig +8 -0
- package/.gitattributes +1 -0
- package/.lefthook.yaml +1 -0
- package/README.md +2 -2
- package/eslint.config.js +1 -0
- package/example/eslint.config.js +240 -0
- package/example/package.json +25 -0
- package/example/pnpm-lock.yaml +4410 -0
- package/example/testdata/test.css +0 -0
- package/example/testdata/test.js +36 -0
- package/example/testdata/test.json +1 -0
- package/example/testdata/test.md +0 -0
- package/index.d.ts +2 -0
- package/index.js +277 -0
- package/package.json +11 -29
- package/pnpm-workspace.yaml +4 -0
- package/project.toml +2 -0
- package/tsconfig.json +16 -0
- package/output/index.cjs +0 -146
- package/output/index.d.ts +0 -2
- package/output/index.mjs +0 -144
package/.editorconfig
ADDED
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
package/.lefthook.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
assert_lefthook_installed: true
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# eslint-config
|
|
1
|
+
# @hyperupcall/eslint-config
|
|
2
2
|
|
|
3
3
|
Edwin's [ESLint](https://eslint.org) configuration.
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ pnpm i -D \
|
|
|
10
10
|
eslint-plugin-import eslint-plugin-promise \
|
|
11
11
|
eslint-plugin-n eslint-plugin-unicorn eslint-plugin-security \
|
|
12
12
|
@eslint-community/eslint-plugin-eslint-comments eslint-plugin-regexp \
|
|
13
|
-
eslint-plugin-perfectionist eslint-plugin-no-unsanitized
|
|
13
|
+
eslint-plugin-perfectionist eslint-plugin-no-unsanitized
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Usage
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hyperupcall/scripts-nodejs/config-eslint.js'
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import 'globals';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import css from '@eslint/css';
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import json from '@eslint/json';
|
|
6
|
+
import markdown from '@eslint/markdown';
|
|
7
|
+
import pluginPromise from 'eslint-plugin-promise';
|
|
8
|
+
import pluginNode from 'eslint-plugin-n';
|
|
9
|
+
import pluginSecurity from 'eslint-plugin-security';
|
|
10
|
+
import pluginComments from '@eslint-community/eslint-plugin-eslint-comments/configs';
|
|
11
|
+
import pluginUnicorn from 'eslint-plugin-unicorn';
|
|
12
|
+
import pluginRegexp from 'eslint-plugin-regexp';
|
|
13
|
+
import pluginNoUnsanitized from 'eslint-plugin-no-unsanitized';
|
|
14
|
+
import pluginPerfectionist from 'eslint-plugin-perfectionist';
|
|
15
|
+
import configPrettier from 'eslint-config-prettier';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @import { RuleEntry } from '@eslint/config-helpers'
|
|
19
|
+
*/
|
|
20
|
+
// TODO: import-x
|
|
21
|
+
|
|
22
|
+
const CurrentMode = process.env.HYPERUPCALL_LINT_MODE || 'release';
|
|
23
|
+
|
|
24
|
+
const cssFiles = ['**/*.css'];
|
|
25
|
+
const jsFiles = ['**/*.js'];
|
|
26
|
+
|
|
27
|
+
var index = defineConfig([
|
|
28
|
+
// @eslint/css: https://github.com/eslint/css
|
|
29
|
+
{
|
|
30
|
+
language: 'css/css',
|
|
31
|
+
files: cssFiles,
|
|
32
|
+
plugins: { css },
|
|
33
|
+
extends: [css.configs.recommended],
|
|
34
|
+
rules: {},
|
|
35
|
+
},
|
|
36
|
+
// @eslint/js: https://github.com/eslint/eslint/tree/main/packages/js
|
|
37
|
+
{
|
|
38
|
+
files: jsFiles,
|
|
39
|
+
plugins: { js },
|
|
40
|
+
languageOptions: {
|
|
41
|
+
sourceType: 'module',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
files: jsFiles,
|
|
46
|
+
plugins: { js },
|
|
47
|
+
extends: [js.configs.recommended],
|
|
48
|
+
rules: {
|
|
49
|
+
'array-callback-return': mode({
|
|
50
|
+
edit: ['off'],
|
|
51
|
+
commit: ['error'],
|
|
52
|
+
release: ['error'],
|
|
53
|
+
}),
|
|
54
|
+
'constructor-super': mode({
|
|
55
|
+
edit: ['warn'],
|
|
56
|
+
commit: ['error'],
|
|
57
|
+
release: ['error'],
|
|
58
|
+
}),
|
|
59
|
+
'for-direction': ['error'],
|
|
60
|
+
'getter-return': mode({
|
|
61
|
+
edit: ['off'],
|
|
62
|
+
commit: ['error'],
|
|
63
|
+
release: ['error'],
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
// eslint-plugin-promise: https://github.com/eslint-community/eslint-plugin-promise
|
|
68
|
+
{
|
|
69
|
+
files: jsFiles,
|
|
70
|
+
plugins: { js },
|
|
71
|
+
extends: [pluginPromise.configs['flat/recommended']],
|
|
72
|
+
rules: {},
|
|
73
|
+
},
|
|
74
|
+
// eslint-plugin-n: https://github.com/eslint-community/eslint-plugin-n
|
|
75
|
+
{
|
|
76
|
+
files: jsFiles,
|
|
77
|
+
plugins: { js },
|
|
78
|
+
extends: [pluginNode.configs['flat/recommended-script']],
|
|
79
|
+
rules: {},
|
|
80
|
+
},
|
|
81
|
+
// eslint-plugin-security: https://github.com/eslint-community/eslint-plugin-security
|
|
82
|
+
{
|
|
83
|
+
files: jsFiles,
|
|
84
|
+
plugins: { js },
|
|
85
|
+
extends: [pluginSecurity.configs.recommended],
|
|
86
|
+
rules: {},
|
|
87
|
+
},
|
|
88
|
+
// eslint-plugin-eslint-comments: https://github.com/eslint-community/eslint-plugin-eslint-comments
|
|
89
|
+
{
|
|
90
|
+
files: jsFiles,
|
|
91
|
+
plugins: { js },
|
|
92
|
+
extends: [pluginComments.recommended],
|
|
93
|
+
rules: {},
|
|
94
|
+
},
|
|
95
|
+
// eslint-plugin-unicorn: https://github.com/sindresorhus/eslint-plugin-unicorn
|
|
96
|
+
{
|
|
97
|
+
files: jsFiles,
|
|
98
|
+
plugins: { js },
|
|
99
|
+
extends: [pluginUnicorn.configs['flat/recommended']],
|
|
100
|
+
rules: {},
|
|
101
|
+
},
|
|
102
|
+
// eslint-plugin-regexp: https://github.com/sindresorhus/eslint-plugin-regexp
|
|
103
|
+
{
|
|
104
|
+
files: jsFiles,
|
|
105
|
+
plugins: { js },
|
|
106
|
+
extends: [pluginRegexp.configs['flat/recommended']],
|
|
107
|
+
rules: {},
|
|
108
|
+
},
|
|
109
|
+
// eslint-plugin-regexp: https://github.com/sindresorhus/eslint-plugin-regexp
|
|
110
|
+
{
|
|
111
|
+
files: jsFiles,
|
|
112
|
+
plugins: { js },
|
|
113
|
+
extends: [pluginNoUnsanitized.configs.recommended],
|
|
114
|
+
rules: {},
|
|
115
|
+
},
|
|
116
|
+
// eslint-plugin-no-unsanitized: https://github.com/mozilla/eslint-plugin-no-unsanitized
|
|
117
|
+
{
|
|
118
|
+
files: jsFiles,
|
|
119
|
+
plugins: { js },
|
|
120
|
+
extends: [pluginNoUnsanitized.configs.recommended],
|
|
121
|
+
rules: {},
|
|
122
|
+
},
|
|
123
|
+
// eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
|
|
124
|
+
{
|
|
125
|
+
files: jsFiles,
|
|
126
|
+
plugins: { js },
|
|
127
|
+
extends: [pluginPerfectionist.configs['recommended-natural']],
|
|
128
|
+
rules: {
|
|
129
|
+
'perfectionist/sort-objects': [
|
|
130
|
+
'error',
|
|
131
|
+
{
|
|
132
|
+
groups: ['r', 'g', 'b'],
|
|
133
|
+
customGroups: {
|
|
134
|
+
r: '^r$',
|
|
135
|
+
g: '^g$',
|
|
136
|
+
b: '^b$',
|
|
137
|
+
},
|
|
138
|
+
useConfigurationIf: {
|
|
139
|
+
allNamesMatchPattern: '^r|g|b$',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'alphabetical',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
files: [
|
|
150
|
+
'eslint.config.js',
|
|
151
|
+
'eslint.config.mjs',
|
|
152
|
+
'eslint.config.cjs',
|
|
153
|
+
'eslint.config.ts',
|
|
154
|
+
'eslint.config.mts',
|
|
155
|
+
'eslint.config.cts',
|
|
156
|
+
],
|
|
157
|
+
plugins: { js },
|
|
158
|
+
extends: [pluginPerfectionist.configs['recommended-natural']],
|
|
159
|
+
rules: {
|
|
160
|
+
'perfectionist/sort-objects': [
|
|
161
|
+
'error',
|
|
162
|
+
{
|
|
163
|
+
groups: ['language', 'files', 'plugins', 'extends', 'rules'],
|
|
164
|
+
customGroups: {
|
|
165
|
+
language: '^language$',
|
|
166
|
+
files: '^files$',
|
|
167
|
+
plugins: '^plugins$',
|
|
168
|
+
extends: '^extends$',
|
|
169
|
+
rules: '^rules$',
|
|
170
|
+
},
|
|
171
|
+
useConfigurationIf: {
|
|
172
|
+
callingFunctionNamePattern: '^defineConfig$',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: 'alphabetical',
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
// eslint-config-prettier: https://github.com/prettier/eslint-config-prettier
|
|
182
|
+
{
|
|
183
|
+
files: jsFiles,
|
|
184
|
+
plugins: { js },
|
|
185
|
+
extends: [configPrettier],
|
|
186
|
+
rules: {},
|
|
187
|
+
},
|
|
188
|
+
// @eslint/json: https://github.com/eslint/json
|
|
189
|
+
{
|
|
190
|
+
language: 'json/json',
|
|
191
|
+
files: ['**/*.json'],
|
|
192
|
+
plugins: { json },
|
|
193
|
+
extends: [json.configs.recommended],
|
|
194
|
+
ignores: ['package-lock.json'],
|
|
195
|
+
rules: {},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
language: 'json/jsonc',
|
|
199
|
+
files: ['**/*.jsonc'],
|
|
200
|
+
plugins: { json },
|
|
201
|
+
extends: [json.configs.recommended],
|
|
202
|
+
rules: {},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
language: 'json/json5',
|
|
206
|
+
files: ['**/*.json5'],
|
|
207
|
+
plugins: { json },
|
|
208
|
+
extends: [json.configs.recommended],
|
|
209
|
+
rules: {},
|
|
210
|
+
},
|
|
211
|
+
// @eslint/markdown: https://github.com/eslint/markdown
|
|
212
|
+
{
|
|
213
|
+
language: 'markdown/commonmark',
|
|
214
|
+
files: ['**/*.md'],
|
|
215
|
+
plugins: {
|
|
216
|
+
markdown,
|
|
217
|
+
},
|
|
218
|
+
extends: [markdown.configs.recommended],
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @param {Record<'edit' | 'commit' | 'release', unknown | undefined>} toggles
|
|
224
|
+
* @returns {RuleEntry}
|
|
225
|
+
*/
|
|
226
|
+
function mode(toggles) {
|
|
227
|
+
const possibleModes = ['edit', 'commit', 'release'];
|
|
228
|
+
const currentMode = 'edit';
|
|
229
|
+
if (!possibleModes.includes(CurrentMode)) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
`Expected the current mode to be ${new Intl.ListFormat().format(possibleModes.map((/** @type {string} */ item) => `"${item}"`))}. Found "${CurrentMode}"`,
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// if (currentMode === 'edit' && toggles.edit)
|
|
236
|
+
|
|
237
|
+
return /** @type RuleEntry */ (toggles[currentMode])
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export { index as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "example",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"check": "cp ../output/index.mjs ./eslint.config.js && eslint --config ./eslint.config.js"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
10
|
+
"@eslint/css": "^0.5.0",
|
|
11
|
+
"@eslint/json": "^0.11.0",
|
|
12
|
+
"@eslint/markdown": "^6.3.0",
|
|
13
|
+
"@hyperupcall/eslint-config": "^1.2.0",
|
|
14
|
+
"eslint": "^9.22.0",
|
|
15
|
+
"eslint-config-prettier": "^10.1.1",
|
|
16
|
+
"eslint-plugin-import": "^2.31.0",
|
|
17
|
+
"eslint-plugin-n": "^17.16.2",
|
|
18
|
+
"eslint-plugin-no-unsanitized": "^4.1.2",
|
|
19
|
+
"eslint-plugin-perfectionist": "^4.10.1",
|
|
20
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
21
|
+
"eslint-plugin-regexp": "^2.7.0",
|
|
22
|
+
"eslint-plugin-security": "^3.0.1",
|
|
23
|
+
"eslint-plugin-unicorn": "^57.0.0"
|
|
24
|
+
}
|
|
25
|
+
}
|