@kouts/eslint-config 0.0.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/LICENSE +21 -0
- package/README.md +69 -0
- package/base.js +64 -0
- package/configVars.js +3 -0
- package/index.js +18 -0
- package/javascript.js +5 -0
- package/package.json +64 -0
- package/prettier.config.js +9 -0
- package/vue.js +8 -0
- package/vue2.js +6 -0
- package/vue3-typescript.js +27 -0
- package/vue3.js +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Giannis Koutsaftakis
|
|
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,69 @@
|
|
|
1
|
+
# @kouts/eslint-config
|
|
2
|
+
|
|
3
|
+
> Custom ESLint and Prettier config with sensible defaults
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -D @kouts/eslint-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
There are 4 ESLint config presets that you can use:
|
|
14
|
+
|
|
15
|
+
- `plugin:@kouts/eslint-config/javascript` for JavaScript / TypeScript projects
|
|
16
|
+
- `plugin:@kouts/eslint-config/vue2` for Vue.js 2 projects
|
|
17
|
+
- `plugin:@kouts/eslint-config/vue3` for Vue.js 3 projects
|
|
18
|
+
- `plugin:@kouts/eslint-config/vue3-typescript` for Vue.js 3 / TypeScript projects
|
|
19
|
+
|
|
20
|
+
Add the desired config preset into your `.eslintrc.js` file:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
module.exports = {
|
|
24
|
+
extends: ['plugin:@kouts/eslint-config/vue2']
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Add a `prettier.config.js` file with contents:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
module.exports = require('@kouts/eslint-config/prettier.config.js')
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You can add ESLint commands to `.package-json`
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"lint": "eslint \"**/*.{vue,ts,js}\"",
|
|
39
|
+
"lint-fix": "eslint --fix \"**/*.{vue,ts,js}\""
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
and VS Code settings for autofix on save
|
|
44
|
+
|
|
45
|
+
`.vscode/settings.json`
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"editor.formatOnSave": true,
|
|
50
|
+
"editor.codeActionsOnSave": {
|
|
51
|
+
"source.fixAll.eslint": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- Based on [eslint-config-standard](https://github.com/standard/eslint-config-standard)
|
|
59
|
+
- [Prettier](https://prettier.io) for code formatting
|
|
60
|
+
- Plugins
|
|
61
|
+
- [eslint-plugin-html](https://github.com/BenoitZugmeyer/eslint-plugin-html) for linting inline scripts contained in HTML files
|
|
62
|
+
- [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue/) for linting Vue.js files
|
|
63
|
+
- [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) for disabling all rules that conflict with Prettier
|
|
64
|
+
- [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) for using prettier as a code formatter for `eslint --fix`
|
|
65
|
+
- [sort-imports-es6-autofix](https://github.com/marudor/eslint-plugin-sort-imports-es6-autofix) for auto-fixing imports order
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
[MIT](http://opensource.org/licenses/MIT)
|
package/base.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const configVars = require('./configVars.js')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
env: {
|
|
6
|
+
node: true,
|
|
7
|
+
browser: true
|
|
8
|
+
},
|
|
9
|
+
extends: ['standard'],
|
|
10
|
+
plugins: ['html', 'sort-imports-es6-autofix'],
|
|
11
|
+
ignorePatterns: ['**/node_modules/**', '{tmp,temp}/**', '**/*.min.js', 'vendor/**', 'dist/**', 'public/**'],
|
|
12
|
+
overrides: [
|
|
13
|
+
{
|
|
14
|
+
files: ['*.json'],
|
|
15
|
+
rules: {
|
|
16
|
+
quotes: [2, 'double']
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
files: ['**/*.spec.{j,t}s?(x)'],
|
|
21
|
+
env: {
|
|
22
|
+
jest: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
rules: {
|
|
27
|
+
// Sort imports
|
|
28
|
+
'sort-imports-es6-autofix/sort-imports-es6': [
|
|
29
|
+
'error',
|
|
30
|
+
{
|
|
31
|
+
ignoreCase: false,
|
|
32
|
+
ignoreMemberSort: false,
|
|
33
|
+
memberSyntaxSortOrder: ['all', 'single', 'multiple', 'none']
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
|
|
37
|
+
// Enforce a new line after the imports section
|
|
38
|
+
'import/newline-after-import': ['error', { count: 1 }],
|
|
39
|
+
|
|
40
|
+
// Enforce blank lines between the given 2 kinds of statements
|
|
41
|
+
'padding-line-between-statements': [
|
|
42
|
+
'error',
|
|
43
|
+
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
44
|
+
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
|
|
45
|
+
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
|
|
46
|
+
{ blankLine: 'always', prev: 'directive', next: '*' },
|
|
47
|
+
{ blankLine: 'any', prev: 'directive', next: 'directive' }
|
|
48
|
+
],
|
|
49
|
+
|
|
50
|
+
// Console and debugger settings depending whether we're on production or not
|
|
51
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
52
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
53
|
+
|
|
54
|
+
// Print width setting
|
|
55
|
+
'max-len': [
|
|
56
|
+
'error',
|
|
57
|
+
{
|
|
58
|
+
code: configVars.printWidth,
|
|
59
|
+
ignoreComments: true,
|
|
60
|
+
ignoreUrls: true
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
package/configVars.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const base = require('./base')
|
|
2
|
+
const javascript = require('./javascript')
|
|
3
|
+
const vue = require('./vue')
|
|
4
|
+
const vue2 = require('./vue2')
|
|
5
|
+
const vue3 = require('./vue3')
|
|
6
|
+
const vue3Typescript = require('./vue3')
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
configs: {
|
|
11
|
+
base,
|
|
12
|
+
javascript,
|
|
13
|
+
vue,
|
|
14
|
+
vue2,
|
|
15
|
+
vue3,
|
|
16
|
+
'vue3-typescript': vue3Typescript
|
|
17
|
+
}
|
|
18
|
+
}
|
package/javascript.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kouts/eslint-config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Kouts's ESLint config",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"base.js",
|
|
9
|
+
"javascript.js",
|
|
10
|
+
"vue.js",
|
|
11
|
+
"vue2.js",
|
|
12
|
+
"vue3.js",
|
|
13
|
+
"vue3-typescript.js",
|
|
14
|
+
"prettier.config.js",
|
|
15
|
+
"configVars.js"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
+
"lint": "eslint \"**/*.js\"",
|
|
20
|
+
"lint-fix": "eslint --fix \"**/*.js\"",
|
|
21
|
+
"lint-debug": "eslint -c vue3-typescript.js --print-config \"**/*.js\" > ./eslint-debug.json"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"lint",
|
|
25
|
+
"eslint",
|
|
26
|
+
"eslintplugin",
|
|
27
|
+
"eslintconfig",
|
|
28
|
+
"standard",
|
|
29
|
+
"vue",
|
|
30
|
+
"vue3"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/kouts/eslint-config.git"
|
|
35
|
+
},
|
|
36
|
+
"author": "kouts",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/kouts/eslint-config/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/kouts/eslint-config#readme",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@typescript-eslint/parser": "^5.31.0",
|
|
44
|
+
"@vue/eslint-config-typescript": "^11.0.0",
|
|
45
|
+
"eslint-config-prettier": "^8.5.0",
|
|
46
|
+
"eslint-config-standard": "^17.0.0",
|
|
47
|
+
"eslint-plugin-html": "^7.1.0",
|
|
48
|
+
"eslint-plugin-import": "^2.26.0",
|
|
49
|
+
"eslint-plugin-n": "^15.2.4",
|
|
50
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
51
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
52
|
+
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
|
53
|
+
"eslint-plugin-vue": "^9.3.0",
|
|
54
|
+
"prettier": "^2.7.1",
|
|
55
|
+
"typescript": "^4.6.3",
|
|
56
|
+
"vue-eslint-parser": "^9.0.3"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"eslint": "^8.23.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"eslint": "^8.20.0"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/vue.js
ADDED
package/vue2.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const javascript = require.resolve('./javascript.js')
|
|
2
|
+
const vue = require.resolve('./vue.js')
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
env: {
|
|
6
|
+
'vue/setup-compiler-macros': true
|
|
7
|
+
},
|
|
8
|
+
extends: ['plugin:vue/vue3-recommended', '@vue/eslint-config-typescript/recommended', vue, javascript],
|
|
9
|
+
overrides: [
|
|
10
|
+
{
|
|
11
|
+
files: ['*.vue'],
|
|
12
|
+
parser: 'vue-eslint-parser',
|
|
13
|
+
parserOptions: {
|
|
14
|
+
parser: '@typescript-eslint/parser'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
rules: {
|
|
19
|
+
/* Typescript */
|
|
20
|
+
|
|
21
|
+
// Disable 'no-unused-vars' as TypeScript has its own version
|
|
22
|
+
'no-unused-vars': 'off',
|
|
23
|
+
|
|
24
|
+
// Prefer T[] instead of Array<T>
|
|
25
|
+
'@typescript-eslint/array-type': ['error', { default: 'array' }]
|
|
26
|
+
}
|
|
27
|
+
}
|