@iqrf/eslint-config 0.0.1 → 0.0.3
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/README.md +4 -4
- package/dist/index.d.ts +68 -3
- package/dist/index.js +185 -39
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -38,9 +38,6 @@ Create a `eslint.config.mjs` file in the root of your project with the following
|
|
|
38
38
|
import { iqrfEslint } from '@iqrf/eslint-config';
|
|
39
39
|
|
|
40
40
|
export default iqrfEslint(
|
|
41
|
-
[
|
|
42
|
-
// Add your custom rules here
|
|
43
|
-
],
|
|
44
41
|
{
|
|
45
42
|
typescript: true,
|
|
46
43
|
vue: true,
|
|
@@ -48,6 +45,9 @@ export default iqrfEslint(
|
|
|
48
45
|
json: true,
|
|
49
46
|
markdown: true,
|
|
50
47
|
},
|
|
48
|
+
[
|
|
49
|
+
// Add your custom rules here
|
|
50
|
+
],
|
|
51
51
|
);
|
|
52
52
|
```
|
|
53
53
|
|
|
@@ -57,6 +57,6 @@ Enable flat config if you are using ESLint < 9.0.0:
|
|
|
57
57
|
|
|
58
58
|
```json
|
|
59
59
|
{
|
|
60
|
-
"eslint.experimental.useFlatConfig": true
|
|
60
|
+
"eslint.experimental.useFlatConfig": true
|
|
61
61
|
}
|
|
62
62
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,11 @@ declare const comments: Linter.FlatConfig;
|
|
|
34
34
|
* limitations under the License.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
interface Options {
|
|
38
|
+
typescript: boolean;
|
|
39
|
+
vue: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const imports: (options: Options) => Linter.FlatConfig;
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* Copyright 2024 MICRORISC s.r.o.
|
|
@@ -72,6 +76,42 @@ declare const javascript: Linter.FlatConfig[];
|
|
|
72
76
|
|
|
73
77
|
declare const json: Linter.FlatConfig[];
|
|
74
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Copyright 2024 MICRORISC s.r.o.
|
|
81
|
+
*
|
|
82
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
83
|
+
* you may not use this file except in compliance with the License.
|
|
84
|
+
* You may obtain a copy of the License at
|
|
85
|
+
*
|
|
86
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
87
|
+
*
|
|
88
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
89
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
90
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
91
|
+
* See the License for the specific language governing permissions and
|
|
92
|
+
* limitations under the License.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
declare const markdown: Linter.FlatConfig;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Copyright 2024 MICRORISC s.r.o.
|
|
99
|
+
*
|
|
100
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
101
|
+
* you may not use this file except in compliance with the License.
|
|
102
|
+
* You may obtain a copy of the License at
|
|
103
|
+
*
|
|
104
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
105
|
+
*
|
|
106
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
107
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
108
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
109
|
+
* See the License for the specific language governing permissions and
|
|
110
|
+
* limitations under the License.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
declare const promise: Linter.FlatConfig;
|
|
114
|
+
|
|
75
115
|
/**
|
|
76
116
|
* Copyright 2024 MICRORISC s.r.o.
|
|
77
117
|
*
|
|
@@ -126,6 +166,29 @@ declare const stylistic: Linter.FlatConfig;
|
|
|
126
166
|
|
|
127
167
|
declare const typescript: Linter.FlatConfig[];
|
|
128
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Copyright 2024 MICRORISC s.r.o.
|
|
171
|
+
*
|
|
172
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
173
|
+
* you may not use this file except in compliance with the License.
|
|
174
|
+
* You may obtain a copy of the License at
|
|
175
|
+
*
|
|
176
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
177
|
+
*
|
|
178
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
179
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
180
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
181
|
+
* See the License for the specific language governing permissions and
|
|
182
|
+
* limitations under the License.
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Retrieves the Vue version from the package.json file.
|
|
187
|
+
* @return number Vue version
|
|
188
|
+
*/
|
|
189
|
+
declare function getVueVersion(): number;
|
|
190
|
+
declare const vue: (tsEnabled: boolean) => Linter.FlatConfig[];
|
|
191
|
+
|
|
129
192
|
/**
|
|
130
193
|
* @constant {boolean} isInEditor Is the code running in an editor?
|
|
131
194
|
*/
|
|
@@ -152,6 +215,8 @@ interface IqrfEslintOptions {
|
|
|
152
215
|
import: boolean;
|
|
153
216
|
/** Markdown support - enabled by default. */
|
|
154
217
|
markdown: boolean;
|
|
218
|
+
/** Promise support - enabled by default. */
|
|
219
|
+
promise: boolean;
|
|
155
220
|
/** RegExp support - enabled by default. */
|
|
156
221
|
regExp: boolean;
|
|
157
222
|
/** TypeScript support - auto-enabled by default. */
|
|
@@ -178,6 +243,6 @@ interface IqrfEslintOptions {
|
|
|
178
243
|
* limitations under the License.
|
|
179
244
|
*/
|
|
180
245
|
|
|
181
|
-
declare function iqrfEslint(
|
|
246
|
+
declare function iqrfEslint(options?: Partial<IqrfEslintOptions>, config?: Linter.FlatConfig | Linter.FlatConfig[]): Linter.FlatConfig[];
|
|
182
247
|
|
|
183
|
-
export { comments, hasTypescript, hasVitest, hasVue, imports, iqrfEslint, isInEditor, javascript, json, regexp, stylistic, typescript, versionVue };
|
|
248
|
+
export { comments, getVueVersion, hasTypescript, hasVitest, hasVue, imports, iqrfEslint, isInEditor, javascript, json, markdown, promise, regexp, stylistic, typescript, versionVue, vue };
|
package/dist/index.js
CHANGED
|
@@ -17,33 +17,89 @@ var comments = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// src/configs/imports.ts
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import process2 from "node:process";
|
|
20
22
|
import pluginImport from "eslint-plugin-import-x";
|
|
21
|
-
var
|
|
23
|
+
var commonRules = (options) => ({
|
|
24
|
+
"import-x/consistent-type-specifier-style": [
|
|
25
|
+
"error",
|
|
26
|
+
"prefer-inline"
|
|
27
|
+
],
|
|
28
|
+
"import-x/order": [
|
|
29
|
+
"error",
|
|
30
|
+
{
|
|
31
|
+
"alphabetize": {
|
|
32
|
+
"order": "asc",
|
|
33
|
+
"caseInsensitive": true
|
|
34
|
+
},
|
|
35
|
+
"pathGroups": [
|
|
36
|
+
{
|
|
37
|
+
"pattern": "@/**",
|
|
38
|
+
"group": "internal"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"groups": [
|
|
42
|
+
"builtin",
|
|
43
|
+
"external",
|
|
44
|
+
"internal",
|
|
45
|
+
"parent",
|
|
46
|
+
"sibling",
|
|
47
|
+
"index",
|
|
48
|
+
"object",
|
|
49
|
+
"type"
|
|
50
|
+
],
|
|
51
|
+
"newlines-between": "always"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"import-x/no-unresolved": [
|
|
55
|
+
"warn",
|
|
56
|
+
options.vue ? {
|
|
57
|
+
ignore: ["^virtual:"]
|
|
58
|
+
} : {}
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
var imports = (options) => options.typescript ? {
|
|
62
|
+
languageOptions: {
|
|
63
|
+
ecmaVersion: 2022,
|
|
64
|
+
parserOptions: {
|
|
65
|
+
ecmaVersion: 2022,
|
|
66
|
+
sourceType: "module"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
22
69
|
plugins: {
|
|
23
70
|
"import-x": pluginImport
|
|
24
71
|
},
|
|
25
72
|
rules: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"pattern": "@/**",
|
|
40
|
-
"group": "internal"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
|
|
44
|
-
"newlines-between": "always"
|
|
73
|
+
...pluginImport.configs.recommended.rules,
|
|
74
|
+
...pluginImport.configs.typescript.rules,
|
|
75
|
+
...commonRules(options)
|
|
76
|
+
},
|
|
77
|
+
settings: {
|
|
78
|
+
...pluginImport.configs.typescript.settings,
|
|
79
|
+
"import-x/resolver": {
|
|
80
|
+
"node": {
|
|
81
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
82
|
+
},
|
|
83
|
+
"typescript": {
|
|
84
|
+
"alwaysTryTypes": true,
|
|
85
|
+
"project": path.join(process2.cwd(), "tsconfig.json")
|
|
45
86
|
}
|
|
46
|
-
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} : {
|
|
90
|
+
languageOptions: {
|
|
91
|
+
ecmaVersion: 2022,
|
|
92
|
+
parserOptions: {
|
|
93
|
+
ecmaVersion: 2022,
|
|
94
|
+
sourceType: "module"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
plugins: {
|
|
98
|
+
"import-x": pluginImport
|
|
99
|
+
},
|
|
100
|
+
rules: {
|
|
101
|
+
...pluginImport.configs.recommended.rules,
|
|
102
|
+
...commonRules(options)
|
|
47
103
|
}
|
|
48
104
|
};
|
|
49
105
|
|
|
@@ -104,6 +160,29 @@ var javascript = [
|
|
|
104
160
|
import pluginJson from "eslint-plugin-jsonc";
|
|
105
161
|
var json = pluginJson.configs["flat/recommended-with-json"];
|
|
106
162
|
|
|
163
|
+
// src/configs/markdown.ts
|
|
164
|
+
import pluginMarkdown from "eslint-plugin-markdown";
|
|
165
|
+
var markdown = {
|
|
166
|
+
files: ["**/*.md"],
|
|
167
|
+
plugins: {
|
|
168
|
+
markdown: pluginMarkdown
|
|
169
|
+
},
|
|
170
|
+
processor: "markdown/markdown",
|
|
171
|
+
rules: {
|
|
172
|
+
...pluginMarkdown.configs.recommended.rules
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/configs/promise.ts
|
|
177
|
+
import pluginPromise from "eslint-plugin-promise";
|
|
178
|
+
var promise = {
|
|
179
|
+
...pluginPromise.configs["flat/recommended"],
|
|
180
|
+
rules: {
|
|
181
|
+
...pluginPromise.configs["flat/recommended"].rules,
|
|
182
|
+
"promise/always-return": "warn"
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
107
186
|
// src/configs/regexp.ts
|
|
108
187
|
import pluginRegexp from "eslint-plugin-regexp";
|
|
109
188
|
var regexp = {
|
|
@@ -176,6 +255,8 @@ var stylistic = {
|
|
|
176
255
|
};
|
|
177
256
|
|
|
178
257
|
// src/configs/typescript.ts
|
|
258
|
+
import path2 from "node:path";
|
|
259
|
+
import process3 from "node:process";
|
|
179
260
|
import tsEslint from "typescript-eslint";
|
|
180
261
|
var typescript = tsEslint.config(
|
|
181
262
|
{
|
|
@@ -188,7 +269,7 @@ var typescript = tsEslint.config(
|
|
|
188
269
|
parser: tsEslint.parser,
|
|
189
270
|
parserOptions: {
|
|
190
271
|
sourceType: "module",
|
|
191
|
-
project:
|
|
272
|
+
project: path2.join(process3.cwd(), "tsconfig.json")
|
|
192
273
|
}
|
|
193
274
|
},
|
|
194
275
|
rules: {
|
|
@@ -201,6 +282,7 @@ var typescript = tsEslint.config(
|
|
|
201
282
|
}
|
|
202
283
|
],
|
|
203
284
|
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
285
|
+
"@typescript-eslint/no-duplicate-enum-values": "warn",
|
|
204
286
|
"@typescript-eslint/no-explicit-any": "warn",
|
|
205
287
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
206
288
|
"@typescript-eslint/no-inferrable-types": "off"
|
|
@@ -208,26 +290,77 @@ var typescript = tsEslint.config(
|
|
|
208
290
|
}
|
|
209
291
|
);
|
|
210
292
|
|
|
293
|
+
// src/configs/vue.ts
|
|
294
|
+
import pluginVue from "eslint-plugin-vue";
|
|
295
|
+
import { getPackageInfoSync } from "local-pkg";
|
|
296
|
+
import tsEslint2 from "typescript-eslint";
|
|
297
|
+
import parserVue from "vue-eslint-parser";
|
|
298
|
+
function getVueVersion() {
|
|
299
|
+
const pkg = getPackageInfoSync("vue", { paths: [process.cwd()] });
|
|
300
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0])) {
|
|
301
|
+
return +pkg.version[0];
|
|
302
|
+
}
|
|
303
|
+
return 3;
|
|
304
|
+
}
|
|
305
|
+
var config = getVueVersion() === 3 ? pluginVue.configs["flat/recommended"] : pluginVue.configs["flat/vue2-recommended"];
|
|
306
|
+
var vue = (tsEnabled) => [
|
|
307
|
+
{
|
|
308
|
+
...config,
|
|
309
|
+
files: ["**/*.vue"],
|
|
310
|
+
plugins: {
|
|
311
|
+
vue: pluginVue
|
|
312
|
+
},
|
|
313
|
+
languageOptions: {
|
|
314
|
+
parser: parserVue,
|
|
315
|
+
parserOptions: {
|
|
316
|
+
ecmaFeatures: {
|
|
317
|
+
jsx: true
|
|
318
|
+
},
|
|
319
|
+
extraFileExtensions: [".vue"],
|
|
320
|
+
parser: tsEnabled ? tsEslint2.parser : null,
|
|
321
|
+
sourceType: "module"
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
rules: {
|
|
325
|
+
...config.rules,
|
|
326
|
+
"vue/html-indent": [
|
|
327
|
+
"warn",
|
|
328
|
+
"tab"
|
|
329
|
+
],
|
|
330
|
+
"vue/html-quotes": [
|
|
331
|
+
"warn",
|
|
332
|
+
"single"
|
|
333
|
+
],
|
|
334
|
+
"vue/max-attributes-per-line": [
|
|
335
|
+
"warn",
|
|
336
|
+
{ singleline: 3 }
|
|
337
|
+
],
|
|
338
|
+
"vue/multi-word-component-names": "off"
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
];
|
|
342
|
+
|
|
211
343
|
// src/env.ts
|
|
212
|
-
import
|
|
213
|
-
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
214
|
-
var isInEditor = !!(!
|
|
344
|
+
import process4 from "node:process";
|
|
345
|
+
import { getPackageInfoSync as getPackageInfoSync2, isPackageExists } from "local-pkg";
|
|
346
|
+
var isInEditor = !!(!process4.env.CI && (process4.env.VSCODE_PID || process4.env.JETBRAINS_IDE || process4.env.VIM));
|
|
215
347
|
var hasTypescript = isPackageExists("typescript");
|
|
216
348
|
var hasVitest = isPackageExists("vitest");
|
|
217
349
|
var hasVue = isPackageExists("nuxt") || isPackageExists("vitepress") || isPackageExists("vue") || isPackageExists("vuepress");
|
|
218
|
-
var versionVue =
|
|
350
|
+
var versionVue = getPackageInfoSync2("vue")?.version;
|
|
219
351
|
|
|
220
352
|
// src/index.ts
|
|
221
|
-
function iqrfEslint({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
353
|
+
function iqrfEslint(options = {}, config2 = []) {
|
|
354
|
+
const {
|
|
355
|
+
import: enableImport = true,
|
|
356
|
+
markdown: enableMarkdown = true,
|
|
357
|
+
promise: enablePromise = true,
|
|
358
|
+
regExp: enableRegExp = true,
|
|
359
|
+
typescript: enableTypescript = hasTypescript,
|
|
360
|
+
vue: enableVue = hasVue
|
|
361
|
+
} = options;
|
|
229
362
|
const configs = [];
|
|
230
|
-
const ignoreFiles = [".gitignore", ".eslintignore"].filter((
|
|
363
|
+
const ignoreFiles = [".gitignore", ".eslintignore"].filter((path3) => fs.existsSync(path3));
|
|
231
364
|
if (ignoreFiles.length > 0) {
|
|
232
365
|
configs.push(configGitignore({
|
|
233
366
|
files: ignoreFiles
|
|
@@ -236,23 +369,33 @@ function iqrfEslint({
|
|
|
236
369
|
configs.push(...javascript);
|
|
237
370
|
configs.push(comments);
|
|
238
371
|
if (enableImport) {
|
|
239
|
-
configs.push(imports);
|
|
372
|
+
configs.push(imports({ typescript: enableTypescript, vue: enableVue }));
|
|
240
373
|
}
|
|
241
374
|
if (enableTypescript) {
|
|
242
375
|
configs.push(...typescript);
|
|
243
376
|
}
|
|
377
|
+
if (enablePromise) {
|
|
378
|
+
configs.push(promise);
|
|
379
|
+
}
|
|
244
380
|
configs.push(...json);
|
|
245
381
|
configs.push(stylistic);
|
|
246
382
|
if (enableRegExp) {
|
|
247
383
|
configs.push(regexp);
|
|
248
384
|
}
|
|
249
|
-
if (
|
|
250
|
-
configs.push(
|
|
385
|
+
if (enableMarkdown) {
|
|
386
|
+
configs.push(markdown);
|
|
387
|
+
}
|
|
388
|
+
if (enableVue) {
|
|
389
|
+
configs.push(...vue(enableTypescript));
|
|
390
|
+
}
|
|
391
|
+
if (Object.keys(config2).length > 0) {
|
|
392
|
+
configs.push(...Array.isArray(config2) ? config2 : [config2]);
|
|
251
393
|
}
|
|
252
394
|
return configs;
|
|
253
395
|
}
|
|
254
396
|
export {
|
|
255
397
|
comments,
|
|
398
|
+
getVueVersion,
|
|
256
399
|
hasTypescript,
|
|
257
400
|
hasVitest,
|
|
258
401
|
hasVue,
|
|
@@ -261,8 +404,11 @@ export {
|
|
|
261
404
|
isInEditor,
|
|
262
405
|
javascript,
|
|
263
406
|
json,
|
|
407
|
+
markdown,
|
|
408
|
+
promise,
|
|
264
409
|
regexp,
|
|
265
410
|
stylistic,
|
|
266
411
|
typescript,
|
|
267
|
-
versionVue
|
|
412
|
+
versionVue,
|
|
413
|
+
vue
|
|
268
414
|
};
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@eslint/js": "^9.6.0",
|
|
19
19
|
"@stylistic/eslint-plugin": "^2.3.0",
|
|
20
20
|
"eslint-config-flat-gitignore": "^0.1.5",
|
|
21
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
21
22
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
22
23
|
"eslint-plugin-import-x": "^0.5.3",
|
|
23
24
|
"eslint-plugin-jsdoc": "^48.5.0",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/eslint": "^8.56.10",
|
|
46
|
+
"@types/eslint-plugin-markdown": "^2.0.2",
|
|
45
47
|
"@types/eslint__js": "^8.42.3",
|
|
46
48
|
"@types/node": "^20.14.9",
|
|
47
49
|
"bumpp": "^9.4.1",
|
|
@@ -79,7 +81,7 @@
|
|
|
79
81
|
},
|
|
80
82
|
"type": "module",
|
|
81
83
|
"types": "dist/index.d.ts",
|
|
82
|
-
"version": "0.0.
|
|
84
|
+
"version": "0.0.3",
|
|
83
85
|
"scripts": {
|
|
84
86
|
"build": "tsup",
|
|
85
87
|
"lint": "eslint .",
|