@enke.dev/lint 0.6.4
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/LICENSE +21 -0
- package/README.md +63 -0
- package/eslint-plugins.d.ts +19 -0
- package/eslint.config.d.ts +3 -0
- package/eslint.config.js +101 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 David Enke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @enke/lint
|
|
2
|
+
|
|
3
|
+
## Install packages
|
|
4
|
+
|
|
5
|
+
Make sure to install the necessary peer dependencies `eslint`, `prettier` and `typescript`.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -D @enke/lint eslint prettier typescript
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Prepare config
|
|
12
|
+
|
|
13
|
+
Create a `eslint.config.js` file in the root of your project and add the following content:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import config from '@enke/lint';
|
|
17
|
+
|
|
18
|
+
export default config;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Using Typescript
|
|
22
|
+
|
|
23
|
+
If you intend to use Typescript for your config file, you just have to install `typescript`.
|
|
24
|
+
|
|
25
|
+
Your config file can then renamed to `eslint.config.ts` and look like this at minimum:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import config from '@enke/lint';
|
|
29
|
+
export default config;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
But you may want to modify the config to your needs:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import config from '@enke/lint';
|
|
36
|
+
import type { Linter } from 'eslint';
|
|
37
|
+
|
|
38
|
+
export default [
|
|
39
|
+
...config,
|
|
40
|
+
// ignore generated stuff
|
|
41
|
+
{ ignores: ['src/generated'] },
|
|
42
|
+
// override rules for test files with mocha / chai
|
|
43
|
+
{
|
|
44
|
+
files: ['**/*.spec.ts'],
|
|
45
|
+
rules: {
|
|
46
|
+
'@typescript-eslint/no-unused-expressions': ['off'],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
] satisfies Linter.Config[];
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> Until eslint 9.18.0 some hacks have been necessary to make this work.
|
|
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
|
|
56
|
+
|
|
57
|
+
Like the experimental typescript config flag above, the VSCode Eslint plugin can be configured to pick up the packages correctly by setting:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"eslint.workingDirectories": ["./packages/foo", "./packages/bar"]
|
|
62
|
+
}
|
|
63
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare module 'eslint-plugin-import-extensions' {
|
|
2
|
+
import type { ESLint } from 'eslint';
|
|
3
|
+
|
|
4
|
+
const plugin: ESLint.Plugin;
|
|
5
|
+
|
|
6
|
+
export default plugin;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'eslint-plugin-import' {
|
|
10
|
+
import type { Linter } from 'eslint';
|
|
11
|
+
|
|
12
|
+
export const js: {
|
|
13
|
+
readonly flatConfigs: {
|
|
14
|
+
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> };
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default js;
|
|
19
|
+
}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/// <reference types="./eslint-plugins.d.ts" />
|
|
2
|
+
import { fixupPluginRules } from '@eslint/compat';
|
|
3
|
+
import eslintJs from '@eslint/js';
|
|
4
|
+
import eslintJson from '@eslint/json';
|
|
5
|
+
import eslintPluginImport from 'eslint-plugin-import';
|
|
6
|
+
import eslintPluginImportExtension from 'eslint-plugin-import-extensions';
|
|
7
|
+
import { configs as eslintPluginLitConfigs } from 'eslint-plugin-lit';
|
|
8
|
+
import eslintPluginPackageJson from 'eslint-plugin-package-json';
|
|
9
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
10
|
+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
11
|
+
import eslintPluginUnusedImports from 'eslint-plugin-unused-imports';
|
|
12
|
+
import { configs as eslintPluginWebComponentsConfigs } from 'eslint-plugin-wc';
|
|
13
|
+
import eslintTs from 'typescript-eslint';
|
|
14
|
+
export default eslintTs.config(eslintJs.configs.recommended, ...eslintTs.configs.strict, ...eslintTs.configs.stylistic, eslintPluginPrettierRecommended, eslintPluginImport.flatConfigs.recommended, eslintPluginPackageJson.configs.recommended, eslintPluginLitConfigs['flat/recommended'], eslintPluginWebComponentsConfigs['flat/recommended'], {
|
|
15
|
+
ignores: ['node_modules/', 'dist/', 'lib/'],
|
|
16
|
+
}, {
|
|
17
|
+
languageOptions: {
|
|
18
|
+
parserOptions: {
|
|
19
|
+
ecmaVersion: 'latest',
|
|
20
|
+
project: true,
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
tsconfigRootDir: './',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}, {
|
|
26
|
+
plugins: {
|
|
27
|
+
'simple-import-sort': eslintPluginSimpleImportSort,
|
|
28
|
+
'unused-imports': eslintPluginUnusedImports,
|
|
29
|
+
'import-extensions': fixupPluginRules(eslintPluginImportExtension),
|
|
30
|
+
},
|
|
31
|
+
}, {
|
|
32
|
+
settings: {
|
|
33
|
+
'import/resolver': {
|
|
34
|
+
typescript: true,
|
|
35
|
+
node: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}, {
|
|
39
|
+
rules: {
|
|
40
|
+
// formatting
|
|
41
|
+
'linebreak-style': ['error', 'unix'],
|
|
42
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
43
|
+
semi: ['error', 'always'],
|
|
44
|
+
// import sorting
|
|
45
|
+
'simple-import-sort/imports': [
|
|
46
|
+
'error',
|
|
47
|
+
{
|
|
48
|
+
groups: [
|
|
49
|
+
// Side effect imports.
|
|
50
|
+
['^\\u0000'],
|
|
51
|
+
// Node.js builtins prefixed with `node:`.
|
|
52
|
+
['^node:'],
|
|
53
|
+
// Packages.
|
|
54
|
+
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
55
|
+
['^@?\\w'],
|
|
56
|
+
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
57
|
+
// Anything not matched in another group.
|
|
58
|
+
['^'],
|
|
59
|
+
// Relative imports.
|
|
60
|
+
// Anything that starts with a dot.
|
|
61
|
+
['^\\.'],
|
|
62
|
+
// Assetic imports, most likely inline loaded style files for lit components
|
|
63
|
+
// or raw loaded files like images, meta data or fonts.
|
|
64
|
+
['\\?(inline|raw)$'],
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
'simple-import-sort/exports': 'error',
|
|
69
|
+
// import extensions
|
|
70
|
+
'import-extensions/require-extensions': ['error', { expectedExtensions: ['js'] }],
|
|
71
|
+
'import-extensions/require-index': ['error', { expectedExtensions: ['js'] }],
|
|
72
|
+
// import rules
|
|
73
|
+
'import/enforce-node-protocol-usage': ['error', 'always'], // enforce node: import prefix
|
|
74
|
+
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], // type imports
|
|
75
|
+
'import/first': 'error',
|
|
76
|
+
'import/newline-after-import': 'error',
|
|
77
|
+
'import/no-duplicates': 'error',
|
|
78
|
+
'import/no-unresolved': 'error',
|
|
79
|
+
'import/extensions': ['error', 'ignorePackages', { ts: 'never', js: 'always' }],
|
|
80
|
+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
|
|
81
|
+
// unused imports
|
|
82
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
83
|
+
'unused-imports/no-unused-vars': [
|
|
84
|
+
'error',
|
|
85
|
+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrors: 'none' },
|
|
86
|
+
],
|
|
87
|
+
'unused-imports/no-unused-imports': 'error',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
// json files
|
|
91
|
+
{
|
|
92
|
+
...eslintJson.configs.recommended,
|
|
93
|
+
files: ['**/*.json'],
|
|
94
|
+
ignores: ['package-lock.json'],
|
|
95
|
+
language: 'json/json',
|
|
96
|
+
rules: {
|
|
97
|
+
'no-irregular-whitespace': 'off',
|
|
98
|
+
'import-extensions/require-extensions': 'off',
|
|
99
|
+
'import-extensions/require-index': 'off',
|
|
100
|
+
},
|
|
101
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enke.dev/lint",
|
|
3
|
+
"version": "0.6.4",
|
|
4
|
+
"description": "Meta package to provide linting for web projects",
|
|
5
|
+
"homepage": "https://github.com/enke-dev/lint",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/enke-dev/lint.git"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"eslint.config.js",
|
|
12
|
+
"eslint.config.d.ts",
|
|
13
|
+
"eslint-plugins.d.ts",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "eslint.config.js",
|
|
18
|
+
"types": "eslint.config.d.ts",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc"
|
|
21
|
+
},
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "David Enke",
|
|
24
|
+
"email": "david@enke.dev"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"eslint": "^9.30.0",
|
|
32
|
+
"prettier": "^3.6.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@eslint/compat": "^1.3.1",
|
|
36
|
+
"@eslint/js": "^9.30.0",
|
|
37
|
+
"@eslint/json": "^0.12.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.35.0",
|
|
40
|
+
"eslint-config-prettier": "^10.1.5",
|
|
41
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
42
|
+
"eslint-plugin-import": "^2.32.0",
|
|
43
|
+
"eslint-plugin-import-extensions": "^0.1.5",
|
|
44
|
+
"eslint-plugin-lit": "^2.1.1",
|
|
45
|
+
"eslint-plugin-package-json": "^0.42.0",
|
|
46
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
47
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
48
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
49
|
+
"eslint-plugin-wc": "^3.0.1",
|
|
50
|
+
"typescript": "^5.8.3",
|
|
51
|
+
"typescript-eslint": "^8.35.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "22.15.33",
|
|
55
|
+
"typescript": "5.8.3"
|
|
56
|
+
}
|
|
57
|
+
}
|