@enke.dev/lint 0.8.4 → 0.9.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/README.md +27 -21
- package/eslint-plugins.d.ts +24 -0
- package/eslint.config.d.ts +1 -2
- package/eslint.config.js +113 -80
- package/package.json +20 -21
package/README.md
CHANGED
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## Install packages
|
|
4
4
|
|
|
5
|
-
Make sure to install the necessary peer dependencies
|
|
5
|
+
Make sure to install the necessary peer dependencies:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm i -D @enke.dev/lint eslint prettier
|
|
8
|
+
npm i -D @enke.dev/lint eslint prettier
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
For Typescript support, install:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i -D @enke.dev/lint eslint prettier jiti typescript typescript-eslint
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Prepare Eslint config
|
|
12
18
|
|
|
13
19
|
Create a `eslint.config.js` file in the root of your project and add the following content:
|
|
14
20
|
|
|
@@ -18,24 +24,26 @@ import config from '@enke.dev/lint';
|
|
|
18
24
|
export default config;
|
|
19
25
|
```
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
### Using Typescript
|
|
22
28
|
|
|
23
|
-
If you intend to use Typescript for your config file, you just have to install `typescript`.
|
|
29
|
+
If you intend to use Typescript for your config file, you just have to install `typescript` and `jiti`.
|
|
24
30
|
|
|
25
|
-
Your config file can then renamed to `eslint.config.ts` and look like this at minimum:
|
|
31
|
+
Your config file can then be renamed to `eslint.config.ts` and look like this at minimum:
|
|
26
32
|
|
|
27
33
|
```ts
|
|
28
34
|
import config from '@enke.dev/lint';
|
|
35
|
+
|
|
29
36
|
export default config;
|
|
30
37
|
```
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
You may want to modify the config to your needs, e.g. like this:
|
|
33
40
|
|
|
34
41
|
```ts
|
|
35
42
|
import config from '@enke.dev/lint';
|
|
36
|
-
import
|
|
43
|
+
import { defineConfig } from 'eslint/config';
|
|
37
44
|
|
|
38
|
-
export default [
|
|
45
|
+
export default defineConfig([
|
|
46
|
+
// extend the base config
|
|
39
47
|
...config,
|
|
40
48
|
// ignore generated stuff
|
|
41
49
|
{ ignores: ['src/generated'] },
|
|
@@ -46,30 +54,28 @@ export default [
|
|
|
46
54
|
'@typescript-eslint/no-unused-expressions': ['off'],
|
|
47
55
|
},
|
|
48
56
|
},
|
|
49
|
-
]
|
|
57
|
+
]);
|
|
50
58
|
```
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
> If your stuck to an older version, you can use a [release prior 0.3.0](https://www.npmjs.com/package/@enke/lint/v/0.2.2).
|
|
54
|
-
|
|
55
|
-
## Using monorepos
|
|
60
|
+
### Using Monorepos
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
The VSCode Eslint plugin can be configured to pick up packages correctly by updating your `settings.json`, e.g.:
|
|
58
63
|
|
|
59
64
|
```json
|
|
60
65
|
{
|
|
61
|
-
"eslint.workingDirectories": ["./packages
|
|
66
|
+
"eslint.workingDirectories": ["./packages/*"]
|
|
62
67
|
}
|
|
63
68
|
```
|
|
64
69
|
|
|
65
|
-
## Stylelint (experimental)
|
|
70
|
+
## Prepare Stylelint config (experimental)
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
Uses some common presets and can be used in CSS, SASS and SCSS files.\
|
|
73
|
+
It will enforce a specific property order and specific custom property prefixes if configured.
|
|
68
74
|
|
|
69
|
-
As this is totally opt-in, all
|
|
75
|
+
As this is totally opt-in, all necessary dependencies must be installed first:
|
|
70
76
|
|
|
71
77
|
```bash
|
|
72
|
-
npm i -D stylelint stylelint-config-rational-order stylelint-config-standard-scss stylelint-order
|
|
78
|
+
npm i -D @enke.dev/lint stylelint stylelint-config-rational-order stylelint-config-standard-scss stylelint-order
|
|
73
79
|
```
|
|
74
80
|
|
|
75
81
|
Create a `stylelint.config.js` file in the root of your project and add the following content:
|
|
@@ -82,4 +88,4 @@ import { defineConfig } from '@enke.dev/lint/stylelint.config.js';
|
|
|
82
88
|
export default defineConfig({ cssCustomPropertyPrefix: 'your-prefix' });
|
|
83
89
|
```
|
|
84
90
|
|
|
85
|
-
For now, no TypeScript support is
|
|
91
|
+
For now, [no TypeScript support](https://github.com/stylelint/stylelint/issues/4940) is possible.
|
package/eslint-plugins.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
declare module 'eslint-plugin-html' {
|
|
2
|
+
import type { ESLint } from 'eslint';
|
|
3
|
+
|
|
4
|
+
const plugin: ESLint.Plugin;
|
|
5
|
+
|
|
6
|
+
export default plugin;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
declare module 'eslint-plugin-import-extensions' {
|
|
2
10
|
import type { ESLint } from 'eslint';
|
|
3
11
|
|
|
@@ -17,3 +25,19 @@ declare module 'eslint-plugin-import' {
|
|
|
17
25
|
|
|
18
26
|
export default js;
|
|
19
27
|
}
|
|
28
|
+
|
|
29
|
+
declare module 'eslint-plugin-lit-a11y' {
|
|
30
|
+
import type { ESLint, Linter } from 'eslint';
|
|
31
|
+
|
|
32
|
+
export const configs: {
|
|
33
|
+
readonly recommended: {
|
|
34
|
+
readonly rules: Readonly<Linter.RulesRecord>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const plugin: ESLint.Plugin & {
|
|
39
|
+
readonly configs;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default plugin;
|
|
43
|
+
}
|
package/eslint.config.d.ts
CHANGED
package/eslint.config.js
CHANGED
|
@@ -2,97 +2,130 @@
|
|
|
2
2
|
import { fixupPluginRules } from '@eslint/compat';
|
|
3
3
|
import eslintJs from '@eslint/js';
|
|
4
4
|
import eslintJson from '@eslint/json';
|
|
5
|
+
import { defineConfig } from 'eslint/config';
|
|
6
|
+
import eslintPluginHtml from 'eslint-plugin-html';
|
|
5
7
|
import eslintPluginImport from 'eslint-plugin-import';
|
|
6
8
|
import eslintPluginImportExtension from 'eslint-plugin-import-extensions';
|
|
7
9
|
import { configs as eslintPluginLitConfigs } from 'eslint-plugin-lit';
|
|
8
|
-
import
|
|
10
|
+
import { configs as eslintPluginLitA11yConfigs } from 'eslint-plugin-lit-a11y';
|
|
11
|
+
import { configs as eslintPluginPackageJsonConfigs } from 'eslint-plugin-package-json';
|
|
9
12
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
10
13
|
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
11
14
|
import eslintPluginUnusedImports from 'eslint-plugin-unused-imports';
|
|
12
15
|
import { configs as eslintPluginWebComponentsConfigs } from 'eslint-plugin-wc';
|
|
13
16
|
import eslintTs from 'typescript-eslint';
|
|
14
|
-
export default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
export default defineConfig([
|
|
18
|
+
eslintJs.configs.recommended,
|
|
19
|
+
...eslintTs.configs.strict,
|
|
20
|
+
...eslintTs.configs.stylistic,
|
|
21
|
+
eslintPluginPrettierRecommended,
|
|
22
|
+
eslintPluginImport.flatConfigs.recommended,
|
|
23
|
+
{
|
|
24
|
+
ignores: ['node_modules/', 'dist/'],
|
|
21
25
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
// Javascript and Typescript files
|
|
27
|
+
{
|
|
28
|
+
files: ['**/*.{js,ts}'],
|
|
29
|
+
...eslintPluginWebComponentsConfigs['flat/recommended'],
|
|
30
|
+
...eslintPluginLitConfigs['flat/recommended'],
|
|
31
|
+
...eslintPluginLitA11yConfigs.recommended,
|
|
32
|
+
plugins: {
|
|
33
|
+
'simple-import-sort': eslintPluginSimpleImportSort,
|
|
34
|
+
'unused-imports': eslintPluginUnusedImports,
|
|
35
|
+
'import-extensions': fixupPluginRules(eslintPluginImportExtension),
|
|
27
36
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
languageOptions: {
|
|
38
|
+
parserOptions: {
|
|
39
|
+
ecmaVersion: 'latest',
|
|
40
|
+
project: true,
|
|
41
|
+
requireConfigFile: false,
|
|
42
|
+
sourceType: 'module',
|
|
43
|
+
tsconfigRootDir: import.meta.dirname,
|
|
44
|
+
},
|
|
33
45
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'linebreak-style': ['error', 'unix'],
|
|
39
|
-
quotes: ['error', 'single', { avoidEscape: true }],
|
|
40
|
-
semi: ['error', 'always'],
|
|
41
|
-
// import sorting
|
|
42
|
-
'simple-import-sort/imports': [
|
|
43
|
-
'error',
|
|
44
|
-
{
|
|
45
|
-
groups: [
|
|
46
|
-
// Side effect imports.
|
|
47
|
-
['^\\u0000'],
|
|
48
|
-
// Node.js builtins prefixed with `node:`.
|
|
49
|
-
['^node:'],
|
|
50
|
-
// Packages.
|
|
51
|
-
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
52
|
-
['^@?\\w'],
|
|
53
|
-
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
54
|
-
// Anything not matched in another group.
|
|
55
|
-
['^'],
|
|
56
|
-
// Relative imports.
|
|
57
|
-
// Anything that starts with a dot.
|
|
58
|
-
['^\\.'],
|
|
59
|
-
// Assetic imports, most likely inline loaded style files for lit components
|
|
60
|
-
// or raw loaded files like images, meta data or fonts.
|
|
61
|
-
['\\?(inline|raw)$'],
|
|
62
|
-
],
|
|
46
|
+
settings: {
|
|
47
|
+
'import/resolver': {
|
|
48
|
+
typescript: true,
|
|
49
|
+
node: true,
|
|
63
50
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
51
|
+
litHtmlSources: true,
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
// formatting
|
|
55
|
+
'@typescript-eslint/no-unused-expressions': [
|
|
56
|
+
'error',
|
|
57
|
+
{ allowShortCircuit: true, allowTernary: true },
|
|
58
|
+
],
|
|
59
|
+
curly: 'error',
|
|
60
|
+
'linebreak-style': ['error', 'unix'],
|
|
61
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
62
|
+
semi: ['error', 'always'],
|
|
63
|
+
// import sorting
|
|
64
|
+
'simple-import-sort/imports': [
|
|
65
|
+
'error',
|
|
66
|
+
{
|
|
67
|
+
groups: [
|
|
68
|
+
// Side effect imports.
|
|
69
|
+
['^\\u0000'],
|
|
70
|
+
// Node.js builtins prefixed with `node:`.
|
|
71
|
+
['^node:'],
|
|
72
|
+
// Packages.
|
|
73
|
+
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
74
|
+
['^@?\\w'],
|
|
75
|
+
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
76
|
+
// Anything not matched in another group.
|
|
77
|
+
['^'],
|
|
78
|
+
// Relative imports.
|
|
79
|
+
// Anything that starts with a dot.
|
|
80
|
+
['^\\.'],
|
|
81
|
+
// Assetic imports, most likely inline loaded style files for lit components
|
|
82
|
+
// or raw loaded files like images, meta data or fonts.
|
|
83
|
+
['\\?(inline|raw)$'],
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
'simple-import-sort/exports': 'error',
|
|
88
|
+
// import extensions
|
|
89
|
+
'import-extensions/require-extensions': ['error', { expectedExtensions: ['js'] }],
|
|
90
|
+
'import-extensions/require-index': ['error', { expectedExtensions: ['js'] }],
|
|
91
|
+
// import rules
|
|
92
|
+
'import/enforce-node-protocol-usage': ['error', 'always'], // enforce node: import prefix
|
|
93
|
+
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], // type imports
|
|
94
|
+
'import/first': 'error',
|
|
95
|
+
'import/newline-after-import': 'error',
|
|
96
|
+
'import/no-duplicates': 'error',
|
|
97
|
+
'import/no-unresolved': 'error',
|
|
98
|
+
'import/extensions': ['error', 'ignorePackages', { ts: 'never', js: 'always' }],
|
|
99
|
+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
|
|
100
|
+
// unused imports
|
|
101
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
102
|
+
'unused-imports/no-unused-vars': [
|
|
103
|
+
'error',
|
|
104
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrors: 'none' },
|
|
105
|
+
],
|
|
106
|
+
'unused-imports/no-unused-imports': 'error',
|
|
107
|
+
// web components / a11y
|
|
108
|
+
'wc/guard-super-call': 'off',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
// HTML files
|
|
112
|
+
{
|
|
113
|
+
files: ['**/*.html'],
|
|
114
|
+
plugins: { html: eslintPluginHtml },
|
|
85
115
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
// JSON files
|
|
117
|
+
{
|
|
118
|
+
...eslintPluginPackageJsonConfigs.recommended,
|
|
119
|
+
...eslintJson.configs.recommended,
|
|
120
|
+
ignores: ['package-lock.json'],
|
|
121
|
+
language: 'json/json',
|
|
122
|
+
rules: {
|
|
123
|
+
'no-irregular-whitespace': 'off',
|
|
124
|
+
'import-extensions/require-extensions': 'off',
|
|
125
|
+
'import-extensions/require-index': 'off',
|
|
126
|
+
},
|
|
127
|
+
settings: {
|
|
128
|
+
'html/html-extensions': ['.html'],
|
|
129
|
+
},
|
|
97
130
|
},
|
|
98
|
-
|
|
131
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enke.dev/lint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Meta package to provide linting for web projects",
|
|
5
5
|
"homepage": "https://github.com/enke-dev/lint",
|
|
6
6
|
"repository": {
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
"types": "eslint.config.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint -c eslint.config.ts ./*.config.ts",
|
|
23
|
+
"inspect": "./node_modules/.bin/eslint-config-inspector --config eslint.config.ts",
|
|
24
|
+
"dev": "tsc --watch",
|
|
23
25
|
"build": "tsc"
|
|
24
26
|
},
|
|
25
27
|
"author": {
|
|
@@ -31,45 +33,42 @@
|
|
|
31
33
|
"access": "public"
|
|
32
34
|
},
|
|
33
35
|
"peerDependencies": {
|
|
34
|
-
"eslint": "^9.
|
|
36
|
+
"eslint": "^9.35.0",
|
|
35
37
|
"prettier": "^3.6.2"
|
|
36
38
|
},
|
|
37
39
|
"optionalDependencies": {
|
|
38
|
-
"
|
|
40
|
+
"jiti": "^2.5.1",
|
|
41
|
+
"stylelint": "^16.24.0",
|
|
39
42
|
"stylelint-config-rational-order": "^0.1.2",
|
|
40
|
-
"stylelint-config-standard-scss": "^
|
|
41
|
-
"stylelint-order": "^7.0.0"
|
|
43
|
+
"stylelint-config-standard-scss": "^16.0.0",
|
|
44
|
+
"stylelint-order": "^7.0.0",
|
|
45
|
+
"typescript": "^5.9.2",
|
|
46
|
+
"typescript-eslint": "^8.43.0"
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
49
|
"@eslint/compat": "^1.3.2",
|
|
45
|
-
"@eslint/js": "^9.
|
|
50
|
+
"@eslint/js": "^9.35.0",
|
|
46
51
|
"@eslint/json": "^0.13.2",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
48
|
-
"@typescript-eslint/parser": "^8.42.0",
|
|
49
52
|
"eslint-config-prettier": "^10.1.8",
|
|
50
53
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
54
|
+
"eslint-plugin-html": "^8.1.3",
|
|
51
55
|
"eslint-plugin-import": "^2.32.0",
|
|
52
56
|
"eslint-plugin-import-extensions": "^0.1.5",
|
|
53
57
|
"eslint-plugin-lit": "^2.1.1",
|
|
54
|
-
"eslint-plugin-
|
|
58
|
+
"eslint-plugin-lit-a11y": "^5.1.1",
|
|
59
|
+
"eslint-plugin-package-json": "^0.56.2",
|
|
55
60
|
"eslint-plugin-prettier": "^5.5.4",
|
|
56
61
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
57
62
|
"eslint-plugin-unused-imports": "^4.2.0",
|
|
58
|
-
"eslint-plugin-wc": "^3.0.1"
|
|
59
|
-
"typescript": "^5.9.2",
|
|
60
|
-
"typescript-eslint": "^8.42.0"
|
|
63
|
+
"eslint-plugin-wc": "^3.0.1"
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
66
|
+
"@eslint/config-inspector": "1.2.0",
|
|
63
67
|
"@types/node": "24.3.1",
|
|
68
|
+
"eslint": "9.35.0",
|
|
64
69
|
"jiti": "2.5.1",
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"eslint-plugin-unused-imports": {
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "$@typescript-eslint/eslint-plugin"
|
|
70
|
-
},
|
|
71
|
-
"typescript-eslint": {
|
|
72
|
-
"typescript": "$typescript"
|
|
73
|
-
}
|
|
70
|
+
"prettier": "3.6.2",
|
|
71
|
+
"typescript": "5.9.2",
|
|
72
|
+
"typescript-eslint": "8.43.0"
|
|
74
73
|
}
|
|
75
74
|
}
|