@kouts/eslint-config 0.0.14 → 1.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.
- package/README.md +57 -19
- package/dist/index.cjs +528 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +523 -0
- package/dist/prettier.cjs +11 -0
- package/dist/prettier.d.cts +5 -0
- package/dist/prettier.d.ts +5 -0
- package/dist/prettier.js +9 -0
- package/package.json +68 -43
- package/base.js +0 -64
- package/configVars.js +0 -3
- package/index.js +0 -19
- package/javascript.js +0 -5
- package/nuxt3.js +0 -14
- package/prettier.config.js +0 -9
- package/vue.js +0 -8
- package/vue2.js +0 -6
- package/vue3-typescript.js +0 -27
- package/vue3.js +0 -9
package/README.md
CHANGED
|
@@ -1,38 +1,67 @@
|
|
|
1
1
|
# @kouts/eslint-config
|
|
2
2
|
|
|
3
|
-
> Custom ESLint and Prettier config with sensible defaults
|
|
3
|
+
> Custom ESLint and Prettier config with Vue.js support and sensible defaults
|
|
4
|
+
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> Starting from v1, this ESLint config uses the [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) and is only compatible with ESLint v9 or v8.50.0+.
|
|
7
|
+
> If you're looking for the previous version, checkout the [README]('./README_V0.md') here.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
|
|
12
|
+
pnpm i -D @kouts/eslint-config eslint prettier
|
|
9
13
|
```
|
|
10
14
|
|
|
11
15
|
## Usage
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
### ESLint config
|
|
18
|
+
|
|
19
|
+
Add an `eslint.config.js` (or `eslint.config.cjs` if your project is CommonJS) that imports the `config` function:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { config } from '@kouts/eslint-config'
|
|
23
|
+
|
|
24
|
+
export default [
|
|
25
|
+
...config(),
|
|
26
|
+
{
|
|
27
|
+
// Add custom rules here
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
```
|
|
14
31
|
|
|
15
|
-
|
|
16
|
-
- `@kouts/eslint-config/vue2` for Vue.js 2 projects
|
|
17
|
-
- `@kouts/eslint-config/vue3` for Vue.js 3 projects
|
|
18
|
-
- `@kouts/eslint-config/vue3-typescript` for Vue.js 3 / TypeScript projects
|
|
19
|
-
- `@kouts/eslint-config/nuxt3` for Nuxt 3 projects
|
|
32
|
+
#### Customizing the config
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
You can customize the config by passing an object to the `config` function:
|
|
22
35
|
|
|
23
36
|
```javascript
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
config({
|
|
38
|
+
ts: true,
|
|
39
|
+
vue: true
|
|
40
|
+
vueVersion: 3
|
|
41
|
+
})
|
|
27
42
|
```
|
|
28
43
|
|
|
29
|
-
|
|
44
|
+
**Available options:**
|
|
45
|
+
|
|
46
|
+
| Option | Type | Description | Default |
|
|
47
|
+
| ---------- | ---------- | ----------------------------- | ------- |
|
|
48
|
+
| ts | `boolean` | Enable TypeScript support | `true` |
|
|
49
|
+
| vue | `boolean` | Enable Vue.js support | `true` |
|
|
50
|
+
| vueVersion | `2` or `3` | Specify the version of Vue.js | `3` |
|
|
51
|
+
|
|
52
|
+
### Prettier config
|
|
53
|
+
|
|
54
|
+
Create a `prettier.config.js` file with the following content:
|
|
30
55
|
|
|
31
56
|
```javascript
|
|
32
|
-
|
|
57
|
+
import prettierConfig from '@kouts/eslint-config/prettier'
|
|
58
|
+
|
|
59
|
+
export default prettierConfig
|
|
33
60
|
```
|
|
34
61
|
|
|
35
|
-
|
|
62
|
+
### package.json scripts
|
|
63
|
+
|
|
64
|
+
Add the following ESLint commands to your `.package-json` for linting and autofixing:
|
|
36
65
|
|
|
37
66
|
```json
|
|
38
67
|
{
|
|
@@ -41,7 +70,9 @@ You can add ESLint commands to `.package-json`
|
|
|
41
70
|
}
|
|
42
71
|
```
|
|
43
72
|
|
|
44
|
-
|
|
73
|
+
### VS Code settings
|
|
74
|
+
|
|
75
|
+
Ad the following settings to your VS Code project settings for autofix on save:
|
|
45
76
|
|
|
46
77
|
`.vscode/settings.json`
|
|
47
78
|
|
|
@@ -50,20 +81,27 @@ and VS Code settings for autofix on save
|
|
|
50
81
|
"editor.formatOnSave": true,
|
|
51
82
|
"editor.codeActionsOnSave": {
|
|
52
83
|
"source.fixAll.eslint": true
|
|
84
|
+
},
|
|
85
|
+
"[javascript]": {
|
|
86
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
87
|
+
},
|
|
88
|
+
"[typescript]": {
|
|
89
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
53
90
|
}
|
|
54
91
|
}
|
|
55
92
|
```
|
|
56
93
|
|
|
57
94
|
## Features
|
|
58
95
|
|
|
59
|
-
- Based on [
|
|
96
|
+
- Based on [neostandard](https://github.com/neostandard/neostandard)
|
|
60
97
|
- [Prettier](https://prettier.io) for code formatting
|
|
61
98
|
- Plugins
|
|
62
99
|
- [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html) for linting inline scripts contained in HTML files
|
|
63
100
|
- [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue/) for linting Vue.js files
|
|
64
101
|
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) for disabling all rules that conflict with Prettier
|
|
65
|
-
- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) for using
|
|
66
|
-
- [
|
|
102
|
+
- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) for using Prettier as a code formatter with `eslint --fix`
|
|
103
|
+
- [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) for auto-fixing imports order
|
|
104
|
+
- [eslint-plugin-import-x](https://github.com/lydell/eslint-plugin-simple-import-sort) for auto-fixing import/export syntax, and prevent issues with misspelling of file paths and import names
|
|
67
105
|
|
|
68
106
|
## License
|
|
69
107
|
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pluginHtml = require('eslint-plugin-html');
|
|
4
|
+
var pluginImport = require('eslint-plugin-import-x');
|
|
5
|
+
var pluginPrettier = require('eslint-plugin-prettier/recommended');
|
|
6
|
+
var pluginSimpleImportSort = require('eslint-plugin-simple-import-sort');
|
|
7
|
+
var neostandard = require('neostandard');
|
|
8
|
+
var pluginVue = require('eslint-plugin-vue');
|
|
9
|
+
|
|
10
|
+
function getDefaultExportFromCjs (x) {
|
|
11
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* WARNING: This file is autogenerated using the tools/update-eslint-all.js
|
|
16
|
+
* script. Do not edit manually.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* eslint quote-props: off -- autogenerated so don't lint */
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* IMPORTANT!
|
|
23
|
+
*
|
|
24
|
+
* We cannot add a "name" property to this object because it's still used in eslintrc
|
|
25
|
+
* which doesn't support the "name" property. If we add a "name" property, it will
|
|
26
|
+
* cause an error.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
var eslintAll = Object.freeze({
|
|
30
|
+
"rules": {
|
|
31
|
+
"accessor-pairs": "error",
|
|
32
|
+
"array-callback-return": "error",
|
|
33
|
+
"arrow-body-style": "error",
|
|
34
|
+
"block-scoped-var": "error",
|
|
35
|
+
"camelcase": "error",
|
|
36
|
+
"capitalized-comments": "error",
|
|
37
|
+
"class-methods-use-this": "error",
|
|
38
|
+
"complexity": "error",
|
|
39
|
+
"consistent-return": "error",
|
|
40
|
+
"consistent-this": "error",
|
|
41
|
+
"constructor-super": "error",
|
|
42
|
+
"curly": "error",
|
|
43
|
+
"default-case": "error",
|
|
44
|
+
"default-case-last": "error",
|
|
45
|
+
"default-param-last": "error",
|
|
46
|
+
"dot-notation": "error",
|
|
47
|
+
"eqeqeq": "error",
|
|
48
|
+
"for-direction": "error",
|
|
49
|
+
"func-name-matching": "error",
|
|
50
|
+
"func-names": "error",
|
|
51
|
+
"func-style": "error",
|
|
52
|
+
"getter-return": "error",
|
|
53
|
+
"grouped-accessor-pairs": "error",
|
|
54
|
+
"guard-for-in": "error",
|
|
55
|
+
"id-denylist": "error",
|
|
56
|
+
"id-length": "error",
|
|
57
|
+
"id-match": "error",
|
|
58
|
+
"init-declarations": "error",
|
|
59
|
+
"logical-assignment-operators": "error",
|
|
60
|
+
"max-classes-per-file": "error",
|
|
61
|
+
"max-depth": "error",
|
|
62
|
+
"max-lines": "error",
|
|
63
|
+
"max-lines-per-function": "error",
|
|
64
|
+
"max-nested-callbacks": "error",
|
|
65
|
+
"max-params": "error",
|
|
66
|
+
"max-statements": "error",
|
|
67
|
+
"new-cap": "error",
|
|
68
|
+
"no-alert": "error",
|
|
69
|
+
"no-array-constructor": "error",
|
|
70
|
+
"no-async-promise-executor": "error",
|
|
71
|
+
"no-await-in-loop": "error",
|
|
72
|
+
"no-bitwise": "error",
|
|
73
|
+
"no-caller": "error",
|
|
74
|
+
"no-case-declarations": "error",
|
|
75
|
+
"no-class-assign": "error",
|
|
76
|
+
"no-compare-neg-zero": "error",
|
|
77
|
+
"no-cond-assign": "error",
|
|
78
|
+
"no-console": "error",
|
|
79
|
+
"no-const-assign": "error",
|
|
80
|
+
"no-constant-binary-expression": "error",
|
|
81
|
+
"no-constant-condition": "error",
|
|
82
|
+
"no-constructor-return": "error",
|
|
83
|
+
"no-continue": "error",
|
|
84
|
+
"no-control-regex": "error",
|
|
85
|
+
"no-debugger": "error",
|
|
86
|
+
"no-delete-var": "error",
|
|
87
|
+
"no-div-regex": "error",
|
|
88
|
+
"no-dupe-args": "error",
|
|
89
|
+
"no-dupe-class-members": "error",
|
|
90
|
+
"no-dupe-else-if": "error",
|
|
91
|
+
"no-dupe-keys": "error",
|
|
92
|
+
"no-duplicate-case": "error",
|
|
93
|
+
"no-duplicate-imports": "error",
|
|
94
|
+
"no-else-return": "error",
|
|
95
|
+
"no-empty": "error",
|
|
96
|
+
"no-empty-character-class": "error",
|
|
97
|
+
"no-empty-function": "error",
|
|
98
|
+
"no-empty-pattern": "error",
|
|
99
|
+
"no-empty-static-block": "error",
|
|
100
|
+
"no-eq-null": "error",
|
|
101
|
+
"no-eval": "error",
|
|
102
|
+
"no-ex-assign": "error",
|
|
103
|
+
"no-extend-native": "error",
|
|
104
|
+
"no-extra-bind": "error",
|
|
105
|
+
"no-extra-boolean-cast": "error",
|
|
106
|
+
"no-extra-label": "error",
|
|
107
|
+
"no-fallthrough": "error",
|
|
108
|
+
"no-func-assign": "error",
|
|
109
|
+
"no-global-assign": "error",
|
|
110
|
+
"no-implicit-coercion": "error",
|
|
111
|
+
"no-implicit-globals": "error",
|
|
112
|
+
"no-implied-eval": "error",
|
|
113
|
+
"no-import-assign": "error",
|
|
114
|
+
"no-inline-comments": "error",
|
|
115
|
+
"no-inner-declarations": "error",
|
|
116
|
+
"no-invalid-regexp": "error",
|
|
117
|
+
"no-invalid-this": "error",
|
|
118
|
+
"no-irregular-whitespace": "error",
|
|
119
|
+
"no-iterator": "error",
|
|
120
|
+
"no-label-var": "error",
|
|
121
|
+
"no-labels": "error",
|
|
122
|
+
"no-lone-blocks": "error",
|
|
123
|
+
"no-lonely-if": "error",
|
|
124
|
+
"no-loop-func": "error",
|
|
125
|
+
"no-loss-of-precision": "error",
|
|
126
|
+
"no-magic-numbers": "error",
|
|
127
|
+
"no-misleading-character-class": "error",
|
|
128
|
+
"no-multi-assign": "error",
|
|
129
|
+
"no-multi-str": "error",
|
|
130
|
+
"no-negated-condition": "error",
|
|
131
|
+
"no-nested-ternary": "error",
|
|
132
|
+
"no-new": "error",
|
|
133
|
+
"no-new-func": "error",
|
|
134
|
+
"no-new-native-nonconstructor": "error",
|
|
135
|
+
"no-new-wrappers": "error",
|
|
136
|
+
"no-nonoctal-decimal-escape": "error",
|
|
137
|
+
"no-obj-calls": "error",
|
|
138
|
+
"no-object-constructor": "error",
|
|
139
|
+
"no-octal": "error",
|
|
140
|
+
"no-octal-escape": "error",
|
|
141
|
+
"no-param-reassign": "error",
|
|
142
|
+
"no-plusplus": "error",
|
|
143
|
+
"no-promise-executor-return": "error",
|
|
144
|
+
"no-proto": "error",
|
|
145
|
+
"no-prototype-builtins": "error",
|
|
146
|
+
"no-redeclare": "error",
|
|
147
|
+
"no-regex-spaces": "error",
|
|
148
|
+
"no-restricted-exports": "error",
|
|
149
|
+
"no-restricted-globals": "error",
|
|
150
|
+
"no-restricted-imports": "error",
|
|
151
|
+
"no-restricted-properties": "error",
|
|
152
|
+
"no-restricted-syntax": "error",
|
|
153
|
+
"no-return-assign": "error",
|
|
154
|
+
"no-script-url": "error",
|
|
155
|
+
"no-self-assign": "error",
|
|
156
|
+
"no-self-compare": "error",
|
|
157
|
+
"no-sequences": "error",
|
|
158
|
+
"no-setter-return": "error",
|
|
159
|
+
"no-shadow": "error",
|
|
160
|
+
"no-shadow-restricted-names": "error",
|
|
161
|
+
"no-sparse-arrays": "error",
|
|
162
|
+
"no-template-curly-in-string": "error",
|
|
163
|
+
"no-ternary": "error",
|
|
164
|
+
"no-this-before-super": "error",
|
|
165
|
+
"no-throw-literal": "error",
|
|
166
|
+
"no-undef": "error",
|
|
167
|
+
"no-undef-init": "error",
|
|
168
|
+
"no-undefined": "error",
|
|
169
|
+
"no-underscore-dangle": "error",
|
|
170
|
+
"no-unexpected-multiline": "error",
|
|
171
|
+
"no-unmodified-loop-condition": "error",
|
|
172
|
+
"no-unneeded-ternary": "error",
|
|
173
|
+
"no-unreachable": "error",
|
|
174
|
+
"no-unreachable-loop": "error",
|
|
175
|
+
"no-unsafe-finally": "error",
|
|
176
|
+
"no-unsafe-negation": "error",
|
|
177
|
+
"no-unsafe-optional-chaining": "error",
|
|
178
|
+
"no-unused-expressions": "error",
|
|
179
|
+
"no-unused-labels": "error",
|
|
180
|
+
"no-unused-private-class-members": "error",
|
|
181
|
+
"no-unused-vars": "error",
|
|
182
|
+
"no-use-before-define": "error",
|
|
183
|
+
"no-useless-assignment": "error",
|
|
184
|
+
"no-useless-backreference": "error",
|
|
185
|
+
"no-useless-call": "error",
|
|
186
|
+
"no-useless-catch": "error",
|
|
187
|
+
"no-useless-computed-key": "error",
|
|
188
|
+
"no-useless-concat": "error",
|
|
189
|
+
"no-useless-constructor": "error",
|
|
190
|
+
"no-useless-escape": "error",
|
|
191
|
+
"no-useless-rename": "error",
|
|
192
|
+
"no-useless-return": "error",
|
|
193
|
+
"no-var": "error",
|
|
194
|
+
"no-void": "error",
|
|
195
|
+
"no-warning-comments": "error",
|
|
196
|
+
"no-with": "error",
|
|
197
|
+
"object-shorthand": "error",
|
|
198
|
+
"one-var": "error",
|
|
199
|
+
"operator-assignment": "error",
|
|
200
|
+
"prefer-arrow-callback": "error",
|
|
201
|
+
"prefer-const": "error",
|
|
202
|
+
"prefer-destructuring": "error",
|
|
203
|
+
"prefer-exponentiation-operator": "error",
|
|
204
|
+
"prefer-named-capture-group": "error",
|
|
205
|
+
"prefer-numeric-literals": "error",
|
|
206
|
+
"prefer-object-has-own": "error",
|
|
207
|
+
"prefer-object-spread": "error",
|
|
208
|
+
"prefer-promise-reject-errors": "error",
|
|
209
|
+
"prefer-regex-literals": "error",
|
|
210
|
+
"prefer-rest-params": "error",
|
|
211
|
+
"prefer-spread": "error",
|
|
212
|
+
"prefer-template": "error",
|
|
213
|
+
"radix": "error",
|
|
214
|
+
"require-atomic-updates": "error",
|
|
215
|
+
"require-await": "error",
|
|
216
|
+
"require-unicode-regexp": "error",
|
|
217
|
+
"require-yield": "error",
|
|
218
|
+
"sort-imports": "error",
|
|
219
|
+
"sort-keys": "error",
|
|
220
|
+
"sort-vars": "error",
|
|
221
|
+
"strict": "error",
|
|
222
|
+
"symbol-description": "error",
|
|
223
|
+
"unicode-bom": "error",
|
|
224
|
+
"use-isnan": "error",
|
|
225
|
+
"valid-typeof": "error",
|
|
226
|
+
"vars-on-top": "error",
|
|
227
|
+
"yoda": "error"
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @fileoverview Configuration applied when a user configuration extends from
|
|
233
|
+
* eslint:recommended.
|
|
234
|
+
* @author Nicholas C. Zakas
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
/* eslint sort-keys: ["error", "asc"] -- Long, so make more readable */
|
|
238
|
+
|
|
239
|
+
/*
|
|
240
|
+
* IMPORTANT!
|
|
241
|
+
*
|
|
242
|
+
* We cannot add a "name" property to this object because it's still used in eslintrc
|
|
243
|
+
* which doesn't support the "name" property. If we add a "name" property, it will
|
|
244
|
+
* cause an error.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
var eslintRecommended = Object.freeze({
|
|
248
|
+
rules: Object.freeze({
|
|
249
|
+
"constructor-super": "error",
|
|
250
|
+
"for-direction": "error",
|
|
251
|
+
"getter-return": "error",
|
|
252
|
+
"no-async-promise-executor": "error",
|
|
253
|
+
"no-case-declarations": "error",
|
|
254
|
+
"no-class-assign": "error",
|
|
255
|
+
"no-compare-neg-zero": "error",
|
|
256
|
+
"no-cond-assign": "error",
|
|
257
|
+
"no-const-assign": "error",
|
|
258
|
+
"no-constant-binary-expression": "error",
|
|
259
|
+
"no-constant-condition": "error",
|
|
260
|
+
"no-control-regex": "error",
|
|
261
|
+
"no-debugger": "error",
|
|
262
|
+
"no-delete-var": "error",
|
|
263
|
+
"no-dupe-args": "error",
|
|
264
|
+
"no-dupe-class-members": "error",
|
|
265
|
+
"no-dupe-else-if": "error",
|
|
266
|
+
"no-dupe-keys": "error",
|
|
267
|
+
"no-duplicate-case": "error",
|
|
268
|
+
"no-empty": "error",
|
|
269
|
+
"no-empty-character-class": "error",
|
|
270
|
+
"no-empty-pattern": "error",
|
|
271
|
+
"no-empty-static-block": "error",
|
|
272
|
+
"no-ex-assign": "error",
|
|
273
|
+
"no-extra-boolean-cast": "error",
|
|
274
|
+
"no-fallthrough": "error",
|
|
275
|
+
"no-func-assign": "error",
|
|
276
|
+
"no-global-assign": "error",
|
|
277
|
+
"no-import-assign": "error",
|
|
278
|
+
"no-invalid-regexp": "error",
|
|
279
|
+
"no-irregular-whitespace": "error",
|
|
280
|
+
"no-loss-of-precision": "error",
|
|
281
|
+
"no-misleading-character-class": "error",
|
|
282
|
+
"no-new-native-nonconstructor": "error",
|
|
283
|
+
"no-nonoctal-decimal-escape": "error",
|
|
284
|
+
"no-obj-calls": "error",
|
|
285
|
+
"no-octal": "error",
|
|
286
|
+
"no-prototype-builtins": "error",
|
|
287
|
+
"no-redeclare": "error",
|
|
288
|
+
"no-regex-spaces": "error",
|
|
289
|
+
"no-self-assign": "error",
|
|
290
|
+
"no-setter-return": "error",
|
|
291
|
+
"no-shadow-restricted-names": "error",
|
|
292
|
+
"no-sparse-arrays": "error",
|
|
293
|
+
"no-this-before-super": "error",
|
|
294
|
+
"no-undef": "error",
|
|
295
|
+
"no-unexpected-multiline": "error",
|
|
296
|
+
"no-unreachable": "error",
|
|
297
|
+
"no-unsafe-finally": "error",
|
|
298
|
+
"no-unsafe-negation": "error",
|
|
299
|
+
"no-unsafe-optional-chaining": "error",
|
|
300
|
+
"no-unused-labels": "error",
|
|
301
|
+
"no-unused-private-class-members": "error",
|
|
302
|
+
"no-unused-vars": "error",
|
|
303
|
+
"no-useless-backreference": "error",
|
|
304
|
+
"no-useless-catch": "error",
|
|
305
|
+
"no-useless-escape": "error",
|
|
306
|
+
"no-with": "error",
|
|
307
|
+
"require-yield": "error",
|
|
308
|
+
"use-isnan": "error",
|
|
309
|
+
"valid-typeof": "error"
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @fileoverview Main package entrypoint.
|
|
315
|
+
* @author Nicholas C. Zakas
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
//------------------------------------------------------------------------------
|
|
319
|
+
// Public Interface
|
|
320
|
+
//------------------------------------------------------------------------------
|
|
321
|
+
|
|
322
|
+
var src = {
|
|
323
|
+
configs: {
|
|
324
|
+
all: eslintAll,
|
|
325
|
+
recommended: eslintRecommended
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
var js = /*@__PURE__*/getDefaultExportFromCjs(src);
|
|
330
|
+
|
|
331
|
+
const typescript = [
|
|
332
|
+
...neostandard.plugins["typescript-eslint"].configs.recommended,
|
|
333
|
+
{
|
|
334
|
+
name: "kouts/typescript",
|
|
335
|
+
rules: {
|
|
336
|
+
// Prefer T[] instead of Array<T>
|
|
337
|
+
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
338
|
+
// Prefer type over interface for objects
|
|
339
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
340
|
+
// Fix type imports
|
|
341
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
342
|
+
"error",
|
|
343
|
+
{
|
|
344
|
+
prefer: "type-imports",
|
|
345
|
+
fixStyle: "inline-type-imports"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
// Allow _ for unused variables
|
|
349
|
+
"@typescript-eslint/no-unused-vars": [
|
|
350
|
+
"error",
|
|
351
|
+
{
|
|
352
|
+
args: "none",
|
|
353
|
+
caughtErrors: "none",
|
|
354
|
+
ignoreRestSiblings: true,
|
|
355
|
+
vars: "all",
|
|
356
|
+
argsIgnorePattern: "^_"
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
|
|
363
|
+
const vue = (options) => {
|
|
364
|
+
const opts = {
|
|
365
|
+
version: 3,
|
|
366
|
+
ts: true,
|
|
367
|
+
...options
|
|
368
|
+
};
|
|
369
|
+
const vueConfig = opts.version === 3 ? pluginVue.configs["flat/recommended"] : pluginVue.configs["flat/vue2-recommended"];
|
|
370
|
+
const languageOptions = opts.ts ? {
|
|
371
|
+
languageOptions: {
|
|
372
|
+
parserOptions: {
|
|
373
|
+
parser: neostandard.plugins["typescript-eslint"].parser
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} : {};
|
|
377
|
+
const config = [
|
|
378
|
+
...vueConfig,
|
|
379
|
+
{
|
|
380
|
+
name: "kouts/vue",
|
|
381
|
+
files: ["*.vue", "**/*.vue"],
|
|
382
|
+
...languageOptions,
|
|
383
|
+
rules: {
|
|
384
|
+
// Overrides for vue/(vue3-)recommended preset
|
|
385
|
+
"vue/max-attributes-per-line": "off",
|
|
386
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
387
|
+
// Strengthen vue/(vue3-)recommended preset for autofix
|
|
388
|
+
// https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/configs/recommended.js
|
|
389
|
+
"vue/attributes-order": "error",
|
|
390
|
+
"vue/component-tags-order": "error",
|
|
391
|
+
"vue/no-lone-template": "error",
|
|
392
|
+
"vue/no-multiple-slot-args": "error",
|
|
393
|
+
"vue/no-v-html": "error",
|
|
394
|
+
"vue/order-in-components": "error",
|
|
395
|
+
"vue/this-in-template": "error",
|
|
396
|
+
"vue/require-prop-types": "error",
|
|
397
|
+
// Enforce PascalCase for Vue components
|
|
398
|
+
"vue/component-name-in-template-casing": ["error", "PascalCase", { registeredComponentsOnly: false, ignores: [] }],
|
|
399
|
+
// Do not allow inline styles
|
|
400
|
+
"vue/no-static-inline-styles": ["error", { allowBinding: false }],
|
|
401
|
+
// Require explicit emits
|
|
402
|
+
"vue/require-explicit-emits": "error",
|
|
403
|
+
// Require component to have a name property
|
|
404
|
+
"vue/require-name-property": "error",
|
|
405
|
+
// Require components that don't have any content to self-close
|
|
406
|
+
"vue/html-self-closing": [
|
|
407
|
+
"error",
|
|
408
|
+
{
|
|
409
|
+
html: {
|
|
410
|
+
void: "always",
|
|
411
|
+
normal: "never",
|
|
412
|
+
component: "always"
|
|
413
|
+
},
|
|
414
|
+
svg: "always",
|
|
415
|
+
math: "always"
|
|
416
|
+
}
|
|
417
|
+
]
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
];
|
|
421
|
+
return config;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const config = (options) => {
|
|
425
|
+
const opts = {
|
|
426
|
+
ts: true,
|
|
427
|
+
vue: true,
|
|
428
|
+
vueVersion: 3,
|
|
429
|
+
...options
|
|
430
|
+
};
|
|
431
|
+
const linterConfig = [
|
|
432
|
+
{
|
|
433
|
+
name: "kouts/ignores",
|
|
434
|
+
ignores: [
|
|
435
|
+
"**/node_modules/**",
|
|
436
|
+
"{tmp,temp}/**",
|
|
437
|
+
"**/*.min.js",
|
|
438
|
+
"vendor/**",
|
|
439
|
+
"dist/**",
|
|
440
|
+
"public/**",
|
|
441
|
+
...neostandard.resolveIgnoresFromGitignore()
|
|
442
|
+
]
|
|
443
|
+
},
|
|
444
|
+
// JavaScript
|
|
445
|
+
{
|
|
446
|
+
name: "kouts/javascript",
|
|
447
|
+
...js.configs.recommended
|
|
448
|
+
},
|
|
449
|
+
// TypeScript
|
|
450
|
+
...opts.ts ? typescript : [],
|
|
451
|
+
// Neostandard
|
|
452
|
+
...neostandard({ noJsx: true, noStyle: true, semi: false, ts: opts.ts }),
|
|
453
|
+
{
|
|
454
|
+
name: "kouts/neostandard-overrides",
|
|
455
|
+
rules: {
|
|
456
|
+
// Enforce blank lines between the given 2 kinds of statements
|
|
457
|
+
"padding-line-between-statements": [
|
|
458
|
+
"error",
|
|
459
|
+
{ blankLine: "always", prev: "*", next: "return" },
|
|
460
|
+
{ blankLine: "always", prev: ["const", "let", "var"], next: "*" },
|
|
461
|
+
{ blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"] },
|
|
462
|
+
{ blankLine: "always", prev: "directive", next: "*" },
|
|
463
|
+
{ blankLine: "any", prev: "directive", next: "directive" }
|
|
464
|
+
],
|
|
465
|
+
// Console and debugger settings depending whether we're on production or not
|
|
466
|
+
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
467
|
+
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
// Import
|
|
471
|
+
{
|
|
472
|
+
name: "kouts/import",
|
|
473
|
+
plugins: {
|
|
474
|
+
import: pluginImport
|
|
475
|
+
},
|
|
476
|
+
rules: {
|
|
477
|
+
"import/export": "error",
|
|
478
|
+
"import/first": "error",
|
|
479
|
+
"import/no-duplicates": "error",
|
|
480
|
+
"import/no-mutable-exports": "error",
|
|
481
|
+
"import/no-named-default": "error",
|
|
482
|
+
"import/no-self-import": "error",
|
|
483
|
+
"import/no-webpack-loader-syntax": "error",
|
|
484
|
+
"import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
|
|
485
|
+
"import/newline-after-import": ["error", { count: 1 }]
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
// Sort imports
|
|
489
|
+
{
|
|
490
|
+
name: "kouts/sort-imports",
|
|
491
|
+
plugins: {
|
|
492
|
+
"simple-import-sort": pluginSimpleImportSort
|
|
493
|
+
},
|
|
494
|
+
rules: {
|
|
495
|
+
"simple-import-sort/imports": [
|
|
496
|
+
"error",
|
|
497
|
+
// Remove all blank lines between imports
|
|
498
|
+
{
|
|
499
|
+
groups: [["^\\u0000", "^node:", "^@?\\w", "^", "^\\."]]
|
|
500
|
+
}
|
|
501
|
+
],
|
|
502
|
+
"simple-import-sort/exports": "error"
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
// HTML
|
|
506
|
+
{
|
|
507
|
+
name: "kouts/html",
|
|
508
|
+
files: ["**/*.html"],
|
|
509
|
+
plugins: {
|
|
510
|
+
html: pluginHtml
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
// Vue
|
|
514
|
+
...opts.vue ? vue({ version: opts.vueVersion, ts: opts.ts }) : [],
|
|
515
|
+
// Prettier
|
|
516
|
+
{
|
|
517
|
+
name: "kouts/prettier",
|
|
518
|
+
...pluginPrettier
|
|
519
|
+
}
|
|
520
|
+
];
|
|
521
|
+
return linterConfig;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
Object.defineProperty(exports, "plugins", {
|
|
525
|
+
enumerable: true,
|
|
526
|
+
get: function () { return neostandard.plugins; }
|
|
527
|
+
});
|
|
528
|
+
exports.config = config;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
export { plugins } from 'neostandard';
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
ts?: boolean;
|
|
6
|
+
vue?: boolean;
|
|
7
|
+
vueVersion?: 2 | 3;
|
|
8
|
+
};
|
|
9
|
+
declare const config: (options?: Options) => Linter.Config<Linter.RulesRecord>[];
|
|
10
|
+
|
|
11
|
+
export { config };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
export { plugins } from 'neostandard';
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
ts?: boolean;
|
|
6
|
+
vue?: boolean;
|
|
7
|
+
vueVersion?: 2 | 3;
|
|
8
|
+
};
|
|
9
|
+
declare const config: (options?: Options) => Linter.Config<Linter.RulesRecord>[];
|
|
10
|
+
|
|
11
|
+
export { config };
|