@hyperupcall/eslint-config 1.4.1 → 2.0.0

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.
File without changes
@@ -0,0 +1,36 @@
1
+ import c from 'b'
2
+
3
+ class A extends B {
4
+ constructor() {
5
+ super()
6
+ } // Would throw a ReferenceError.
7
+ }
8
+
9
+ // https://eslint.org/docs/latest/rules/array-callback-return#rule-details
10
+ const bar = foo.filter(function (x) {
11
+ if (x) {
12
+ return true
13
+ } else {
14
+ return
15
+ }
16
+ })
17
+
18
+ // https://eslint.org/docs/latest/rules/no-const-assign#rule-details
19
+ const a = 0
20
+ a = 1
21
+
22
+ function doSomething() {}
23
+ function forgotToReturn() {}
24
+
25
+ const myPromise = new Promise()
26
+ myPromise.then(function (val) {})
27
+ myPromise.then(() => {
28
+ doSomething()
29
+ })
30
+ myPromise.then((b) => {
31
+ if (b) {
32
+ return 'yes'
33
+ } else {
34
+ forgotToReturn()
35
+ }
36
+ })
@@ -0,0 +1 @@
1
+ {}
File without changes
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint/config").Config[];
2
+ export default _default;
package/index.js ADDED
@@ -0,0 +1,277 @@
1
+ import globals from 'globals'
2
+ import { defineConfig, globalIgnores } 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
+ // @ts-expect-error
8
+ import pluginPromise from 'eslint-plugin-promise'
9
+ import pluginNode from 'eslint-plugin-n'
10
+ // @ts-expect-error
11
+ import pluginSecurity from 'eslint-plugin-security'
12
+ // @ts-expect-error
13
+ import pluginComments from '@eslint-community/eslint-plugin-eslint-comments/configs'
14
+ import pluginUnicorn from 'eslint-plugin-unicorn'
15
+ import pluginRegexp from 'eslint-plugin-regexp'
16
+ // @ts-expect-error
17
+ import pluginNoUnsanitized from 'eslint-plugin-no-unsanitized'
18
+ import pluginPerfectionist from 'eslint-plugin-perfectionist'
19
+ import configPrettier from 'eslint-config-prettier'
20
+
21
+ /**
22
+ * @import { Linter } from 'eslint'
23
+ */
24
+
25
+ // TODO: import-x
26
+ // TODO: @eslint/css: Original 0.13, new: 0.14
27
+ // TODO: @eslint/js: Original 9.38.0, new: 9.39.2
28
+ // TODO: @eslint/json: Original 0.13.2, new: 0.14.0
29
+ // TODO: @eslint/markdown: Original: 7.4.1, new: 7.5.1
30
+ // TODO: @eslint/plugin-perfectionist: Original: 4.15.1, new: 5.3.1
31
+ // TODO: @eslint/plugin-unicorn: riginal: 61.0.2, new: 62.0.0
32
+ const CurrentMode = process.env.HYPERUPCALL_LINT_LEVEL || 'release'
33
+
34
+ const cssFiles = ['**/*.css']
35
+ const jsFiles = ['**/*.js']
36
+
37
+ export default defineConfig([
38
+ globalIgnores(['**/build/', '**/output/', '**/dist/']),
39
+
40
+ // @eslint/css: https://github.com/eslint/css
41
+ {
42
+ language: 'css/css',
43
+ files: cssFiles,
44
+ plugins: { css },
45
+ extends: processExtends([css.configs.recommended]),
46
+ rules: processRules({
47
+ 'css/use-baseline': 'off',
48
+ 'css/no-important': 'off',
49
+ }),
50
+ },
51
+ // @eslint/js: https://github.com/eslint/eslint/tree/main/packages/js
52
+ {
53
+ files: jsFiles,
54
+
55
+ plugins: { js },
56
+ extends: processExtends([js.configs.recommended]),
57
+ rules: processRules({
58
+ 'array-callback-return': mode({
59
+ edit: ['off'],
60
+ commit: ['error'],
61
+ release: ['error'],
62
+ }),
63
+ 'constructor-super': mode({
64
+ edit: ['warn'],
65
+ commit: ['error'],
66
+ release: ['error'],
67
+ }),
68
+ 'for-direction': ['error'],
69
+ 'getter-return': mode({
70
+ edit: ['off'],
71
+ commit: ['error'],
72
+ release: ['error'],
73
+ }),
74
+ }),
75
+ },
76
+ // eslint-plugin-promise: https://github.com/eslint-community/eslint-plugin-promise
77
+ {
78
+ files: jsFiles,
79
+ plugins: { js },
80
+ extends: processExtends([pluginPromise.configs['flat/recommended']]),
81
+ },
82
+ // eslint-plugin-n: https://github.com/eslint-community/eslint-plugin-n
83
+ {
84
+ files: jsFiles,
85
+ plugins: { js },
86
+ extends: processExtends([pluginNode.configs['flat/recommended-script']]),
87
+ },
88
+ // eslint-plugin-security: https://github.com/eslint-community/eslint-plugin-security
89
+ {
90
+ files: jsFiles,
91
+ plugins: { js },
92
+ extends: processExtends([pluginSecurity.configs.recommended]),
93
+ rules: processRules({
94
+ 'security/detect-object-injection': 'off',
95
+ }),
96
+ },
97
+ // eslint-plugin-eslint-comments: https://github.com/eslint-community/eslint-plugin-eslint-comments
98
+ {
99
+ files: jsFiles,
100
+ plugins: { js },
101
+ extends: processExtends([pluginComments.recommended]),
102
+ },
103
+ // eslint-plugin-unicorn: https://github.com/sindresorhus/eslint-plugin-unicorn
104
+ {
105
+ files: jsFiles,
106
+ plugins: { js },
107
+ extends: processExtends([pluginUnicorn.configs.recommended]),
108
+ },
109
+ // eslint-plugin-regexp: https://github.com/sindresorhus/eslint-plugin-regexp
110
+ {
111
+ files: jsFiles,
112
+ plugins: { js },
113
+ extends: processExtends([pluginRegexp.configs['flat/recommended']]),
114
+ },
115
+ // eslint-plugin-regexp: https://github.com/sindresorhus/eslint-plugin-regexp
116
+ {
117
+ files: jsFiles,
118
+ plugins: { js },
119
+ extends: processExtends([pluginNoUnsanitized.configs.recommended]),
120
+ },
121
+ // eslint-plugin-no-unsanitized: https://github.com/mozilla/eslint-plugin-no-unsanitized
122
+ {
123
+ files: jsFiles,
124
+ plugins: { js },
125
+ extends: processExtends([pluginNoUnsanitized.configs.recommended]),
126
+ },
127
+ // eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
128
+ {
129
+ files: jsFiles,
130
+ plugins: { js },
131
+ extends: processExtends([pluginPerfectionist.configs['recommended-natural']]),
132
+ rules: processRules({
133
+ 'perfectionist/sort-objects': [
134
+ 'error',
135
+ {
136
+ groups: ['r', 'g', 'b'],
137
+ customGroups: {
138
+ r: '^r$',
139
+ g: '^g$',
140
+ b: '^b$',
141
+ },
142
+ useConfigurationIf: {
143
+ allNamesMatchPattern: '^r|g|b$',
144
+ },
145
+ },
146
+ {
147
+ type: 'alphabetical',
148
+ },
149
+ ],
150
+ }),
151
+ },
152
+ {
153
+ files: [
154
+ 'eslint.config.js',
155
+ 'eslint.config.mjs',
156
+ 'eslint.config.cjs',
157
+ 'eslint.config.ts',
158
+ 'eslint.config.mts',
159
+ 'eslint.config.cts',
160
+ ],
161
+ plugins: { js },
162
+ extends: processExtends([pluginPerfectionist.configs['recommended-natural']]),
163
+ rules: processRules({
164
+ 'perfectionist/sort-objects': [
165
+ 'error',
166
+ {
167
+ groups: ['language', 'files', 'plugins', 'extends', 'rules'],
168
+ customGroups: {
169
+ language: '^language$',
170
+ files: '^files$',
171
+ plugins: '^plugins$',
172
+ extends: '^extends$',
173
+ rules: '^rules$',
174
+ },
175
+ useConfigurationIf: {
176
+ callingFunctionNamePattern: '^defineConfig$',
177
+ },
178
+ },
179
+ {
180
+ type: 'alphabetical',
181
+ },
182
+ ],
183
+ }),
184
+ },
185
+ // eslint-config-prettier: https://github.com/prettier/eslint-config-prettier
186
+ {
187
+ files: jsFiles,
188
+ plugins: { js },
189
+ extends: processExtends([configPrettier]),
190
+ },
191
+ // Other JavaScript configuration.
192
+ {
193
+ files: jsFiles,
194
+ plugins: { js },
195
+ languageOptions: {
196
+ sourceType: 'module',
197
+ },
198
+ },
199
+ // @eslint/json: https://github.com/eslint/json
200
+ {
201
+ language: 'json/json',
202
+ files: ['**/*.json'],
203
+ plugins: { json },
204
+ extends: processExtends([json.configs.recommended]),
205
+ ignores: ['package-lock.json'],
206
+ },
207
+ {
208
+ language: 'json/jsonc',
209
+ files: ['**/*.jsonc'],
210
+ plugins: { json },
211
+ extends: processExtends([json.configs.recommended]),
212
+ },
213
+ {
214
+ language: 'json/json5',
215
+ files: ['**/*.json5'],
216
+ plugins: { json },
217
+ extends: processExtends([json.configs.recommended]),
218
+ },
219
+ // @eslint/markdown: https://github.com/eslint/markdown
220
+ {
221
+ files: ['**/*.md'],
222
+ plugins: {
223
+ markdown,
224
+ },
225
+ extends: processExtends([markdown.configs.recommended]),
226
+ rules: processRules({
227
+ 'markdown/no-missing-label-refs': 'off', // TODO: Errors in frontmatter TOML arrays
228
+ }),
229
+ },
230
+ ])
231
+
232
+ /**
233
+ * @param {Record<'edit' | 'commit' | 'release', unknown | undefined>} toggles
234
+ * @returns {Linter.RuleEntry}
235
+ */
236
+ function mode(toggles) {
237
+ const possibleModes = ['none', 'edit', 'commit', 'release']
238
+ if (CurrentMode === 'none') {
239
+ return 'off'
240
+ }
241
+ const currentMode = 'edit'
242
+ if (!possibleModes.includes(CurrentMode)) {
243
+ throw new Error(
244
+ `Expected the current mode to be ${new Intl.ListFormat().format(possibleModes.map((/** @type {string} */ item) => `"${item}"`))}. Found "${CurrentMode}"`,
245
+ )
246
+ }
247
+
248
+ return /** @type Linter.RuleEntry */ (toggles[currentMode])
249
+ }
250
+
251
+ function processRules(/** @type {Partial<Linter.RulesRecord>} */ config) {
252
+ if (CurrentMode === 'off') {
253
+ for (const ruleName in config) {
254
+ if (Array.isArray(config[ruleName])) {
255
+ config[ruleName][0] = 'off'
256
+ } else {
257
+ config[ruleName] = 'off'
258
+ }
259
+ }
260
+ }
261
+
262
+ return config
263
+ }
264
+
265
+ function processConfig(/** @type {Linter.Config} */ config) {
266
+ if (config.rules) {
267
+ processRules(config.rules)
268
+ }
269
+ return config
270
+ }
271
+
272
+ function processExtends(/** @type {Linter.Config[]} */ extend) {
273
+ for (const config of extend) {
274
+ processConfig(config)
275
+ }
276
+ return extend
277
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@hyperupcall/eslint-config",
3
- "version": "1.4.1",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "Edwin's ESLint configuration.",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/fox-land/eslint-config-hyperupcall.git"
8
+ "url": "git+https://github.com/fox-land/eslint-config-hyperupcall.git"
9
9
  },
10
10
  "bugs": {
11
11
  "url": "https://github.com/fox-land/eslint-config-hyperupcall/issues"
@@ -13,15 +13,7 @@
13
13
  "author": "Edwin Kofler <edwin@kofler.dev> (https://edwinkofler.com)",
14
14
  "license": "MPL-2.0",
15
15
  "private": false,
16
- "exports": {
17
- ".": {
18
- "import": "./output/index.mjs",
19
- "require": "./output/index.cjs"
20
- }
21
- },
22
- "files": [
23
- "output/*"
24
- ],
16
+ "main": "./index.js",
25
17
  "peerDependencies": {
26
18
  "@eslint-community/eslint-plugin-eslint-comments": ">=4.0.0",
27
19
  "@eslint/css": ">=0.5.0",
@@ -31,8 +23,6 @@
31
23
  "eslint": "^9.0.0",
32
24
  "eslint-config-prettier": ">=9.1.0",
33
25
  "eslint-plugin-import-x": ">=4.0.0",
34
- "eslint-plugin-markdown": ">=5.0.0",
35
- "eslint-plugin-mdx": ">=3.0.0",
36
26
  "eslint-plugin-n": ">=17.0.0",
37
27
  "eslint-plugin-no-unsanitized": ">=4.0.0",
38
28
  "eslint-plugin-perfectionist": ">=3.0.0",
@@ -42,29 +32,21 @@
42
32
  "eslint-plugin-unicorn": ">=55.0.0"
43
33
  },
44
34
  "dependencies": {
45
- "globals": "^16.0.0"
35
+ "globals": "^17.0.0"
46
36
  },
47
37
  "devDependencies": {
48
- "@eslint/markdown": "^6.4.0",
49
- "@hyperupcall/eslint-config": "^1.2.0",
50
- "@hyperupcall/markdownlint-config": "^0.3.2",
51
- "@hyperupcall/prettier-config": "^0.9.1",
52
- "@rollup/plugin-node-resolve": "^16.0.1",
53
- "@types/node": "^22.15.17",
54
- "eslint-plugin-import-x": "^4.11.1",
55
- "markdownlint": "^0.37.4",
56
- "prettier": "^3.5.3",
57
- "prettier-plugin-pkg": "^0.18.1",
58
- "rollup": "^4.36.0",
59
- "typescript": "^5.8.2"
38
+ "@hyperupcall/scripts-nodejs": "0.7.0",
39
+ "@types/node": "^25.0.6",
40
+ "typescript": "^5.9.3"
60
41
  },
61
42
  "markdownlint-cli2": {
62
43
  "extends": "./node_modules/@hyperupcall/markdownlint-config/.markdownlint.json"
63
44
  },
64
- "prettier": "@hyperupcall/prettier-config",
45
+ "prettier": "@hyperupcall/scripts-nodejs/config-prettier.js",
65
46
  "scripts": {
66
- "build": "rm -rf ./output && rollup --config ./rollup.config.js && tsc --project ./tsconfig.json",
47
+ "typecheck": "tsc --project ./tsconfig.json",
67
48
  "format": "prettier --check .",
49
+ "format:fix": "prettier --write .",
68
50
  "lint": "eslint ."
69
51
  }
70
52
  }
@@ -0,0 +1,4 @@
1
+ onlyBuiltDependencies:
2
+ - unrs-resolver
3
+ publicHoistPattern:
4
+ - "prettier"
package/project.toml ADDED
@@ -0,0 +1,2 @@
1
+ [repository-lint]
2
+ ignoredChecks = ['nodejs/eslint']
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "include": ["./index.js"],
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "checkJs": true,
6
+ "target": "es2018",
7
+ "moduleResolution": "node16",
8
+ "module": "node16",
9
+ "lib": ["es2021"],
10
+ "noEmit": false,
11
+ "declaration": true,
12
+ "emitDeclarationOnly": true,
13
+ "strict": true,
14
+ "outDir": "./output"
15
+ }
16
+ }
package/output/index.cjs DELETED
@@ -1,146 +0,0 @@
1
- 'use strict';
2
-
3
- require('globals');
4
- var config = require('eslint/config');
5
- var langJs = require('@eslint/js');
6
- var langMarkdown = require('@eslint/markdown');
7
- var langCss = require('@eslint/css');
8
- var langJson = require('@eslint/json');
9
- var pluginPromise = require('eslint-plugin-promise');
10
- var pluginNode = require('eslint-plugin-n');
11
- var pluginSecurity = require('eslint-plugin-security');
12
- var pluginComments = require('@eslint-community/eslint-plugin-eslint-comments/configs');
13
- var pluginUnicorn = require('eslint-plugin-unicorn');
14
- var pluginRegexp = require('eslint-plugin-regexp');
15
- var pluginNoUnsanitized = require('eslint-plugin-no-unsanitized');
16
- var pluginPerfectionist = require('eslint-plugin-perfectionist');
17
- var configPrettier = require('eslint-config-prettier');
18
-
19
- /**
20
- * @import { RuleEntry } from '@eslint/config-helpers'
21
- */
22
- // TODO: import-x
23
-
24
- const CurrentMode = process.env.HYPERUPCALL_LINT_MODE || 'release';
25
-
26
- var index = config.defineConfig([
27
- // https://github.com/eslint/eslint/tree/main/packages/js
28
- langJs.configs.recommended,
29
- {
30
- rules: {
31
- 'array-callback-return': modeSwitch({
32
- edit: ['off'],
33
- commit: ['error'],
34
- release: ['error'],
35
- }),
36
- 'constructor-super': modeSwitch({
37
- edit: ['warn'],
38
- commit: ['error'],
39
- release: ['error'],
40
- }),
41
- 'for-direction': ['error'],
42
- 'getter-return': modeSwitch({
43
- edit: ['off'],
44
- commit: ['error'],
45
- release: ['error'],
46
- }),
47
- },
48
- },
49
-
50
- // https://github.com/eslint-community/eslint-plugin-promise
51
- pluginPromise.configs['flat/recommended'],
52
-
53
- // https://github.com/eslint-community/eslint-plugin-n
54
- pluginNode.configs['flat/recommended-script'],
55
-
56
- // https://github.com/eslint-community/eslint-plugin-security
57
- pluginSecurity.configs.recommended,
58
-
59
- // https://github.com/eslint-community/eslint-plugin-eslint-comments
60
- pluginComments.recomended,
61
-
62
- // https://github.com/sindresorhus/eslint-plugin-unicorn
63
- pluginUnicorn.configs['flat/recommended'],
64
-
65
- // https://www.npmjs.com/package/eslint-plugin-regexp
66
- pluginRegexp.configs['flat/recommended'],
67
-
68
- // https://github.com/mozilla/eslint-plugin-no-unsanitized
69
- pluginNoUnsanitized.configs.recommended,
70
-
71
- // https://github.com/azat-io/eslint-plugin-perfectionist
72
- pluginPerfectionist.configs['recommended-natural'],
73
-
74
- // https://github.com/prettier/eslint-config-prettier
75
- configPrettier,
76
-
77
- // https://github.com/eslint/markdown
78
- ...langMarkdown.configs.recommended,
79
- {
80
- files: ['**/*.md'],
81
- plugins: {
82
- langMarkdown,
83
- },
84
- language: 'markdown/commonmark',
85
- rules: {},
86
- },
87
-
88
- // https://github.com/mdx-js/eslint-mdx/tree/master/packages/eslint-plugin-mdx
89
- // ...langMdx.flat,
90
- // processor: langMdx.createRemarkProcessor({
91
- // lintCodeBlocks: true,
92
- // }),
93
- // },
94
-
95
- // https://github.com/eslint/css
96
- {
97
- files: ['**/*.css'],
98
- language: 'css/css',
99
- ...langCss.configs.recommended,
100
- },
101
-
102
- // https://github.com/eslint/json
103
- {
104
- plugins: {
105
- langJson,
106
- },
107
- },
108
- {
109
- files: ['**/*.json'],
110
- ignores: ['package-lock.json'],
111
- language: 'json/json',
112
- ...langJson.configs.recommended,
113
- },
114
-
115
- {
116
- files: ['**/*.jsonc'],
117
- language: 'json/jsonc',
118
- ...langJson.configs.recommended,
119
- },
120
-
121
- {
122
- files: ['**/*.json5'],
123
- language: 'json/json5',
124
- ...langJson.configs.recommended,
125
- },
126
- ]);
127
-
128
- /**
129
- * @param {Record<'edit' | 'commit' | 'release', unknown | undefined>} toggles
130
- * @returns {RuleEntry}
131
- */
132
- function modeSwitch(toggles) {
133
- const possibleModes = ['edit', 'commit', 'release'];
134
- const currentMode = 'edit';
135
- if (!possibleModes.includes(CurrentMode)) {
136
- throw new Error(
137
- `Expected the current mode to be ${new Intl.ListFormat().format(possibleModes).map((/** @type {string} */ item) => `"${item}"`)}. Found "${CurrentMode}"`,
138
- )
139
- }
140
-
141
- // if (currentMode === 'edit' && toggles.edit)
142
-
143
- return /** @type RuleEntry */ (toggles[currentMode])
144
- }
145
-
146
- module.exports = index;
package/output/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _default: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
2
- export default _default;