@niondigital/eslint-config-base 1.9.0 → 2.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 +30 -18
- package/config.js +18 -0
- package/package.json +12 -62
- package/.eslintrc +0 -3
- package/index.js +0 -170
- package/test.test.js +0 -5
package/README.md
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
# `@niondigital/eslint-config-base`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared ESLint config as base by [nion digital](https://www.nion-digital.com).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. Install package as a dev dependency:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
8
10
|
npx install-peerdeps --dev @niondigital/eslint-config-base
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
2. Create `eslint.config.mjs` at the root and add the following code:
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
```js
|
|
16
|
+
import getConfig from '@niondigital/eslint-config-base';
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
"extends": "@niondigital/eslint-config-base",
|
|
18
|
-
"rules": {}
|
|
19
|
-
}
|
|
18
|
+
export default getConfig();
|
|
20
19
|
```
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
The MIT License (MIT)
|
|
25
|
-
|
|
26
|
-
Copyright (c) 2024 nion digital GmbH, Germany
|
|
21
|
+
3. Add the following script in `package.json`:
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
```js
|
|
24
|
+
{
|
|
25
|
+
// ...
|
|
26
|
+
"scripts": {
|
|
27
|
+
// ...
|
|
28
|
+
"eslint": "eslint --fix \"src/**/*.ts\""
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
4. (Optional) You can customize the config by passing an object:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
export default getConfig({
|
|
37
|
+
// Files to be ignored
|
|
38
|
+
ignores: [],
|
|
39
|
+
// Additional ESLint rules
|
|
40
|
+
additionalRules: {},
|
|
41
|
+
// Additional ESLint config
|
|
42
|
+
additionalConfig: [],
|
|
43
|
+
});
|
|
44
|
+
```
|
package/config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
|
|
5
|
+
export default ({ ignores = [], additionalRules = {}, additionalConfig = [] } = {}) => {
|
|
6
|
+
const rules = {
|
|
7
|
+
'no-undef': 'off',
|
|
8
|
+
...additionalRules,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return defineConfig([
|
|
12
|
+
eslint.configs.recommended,
|
|
13
|
+
...tseslint.configs.recommended,
|
|
14
|
+
...additionalConfig,
|
|
15
|
+
{ ignores },
|
|
16
|
+
{ rules },
|
|
17
|
+
]);
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,70 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niondigital/eslint-config-base",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"author": "Dominik Gallitzendörfer <dominik.gallitzendoerfer@nion-digital.com>",
|
|
6
|
+
"main": "./config.js",
|
|
7
|
+
"repository": "https://github.com/niondigital/javascript-style",
|
|
8
|
+
"license": "MIT",
|
|
5
9
|
"keywords": [
|
|
6
10
|
"eslint",
|
|
7
|
-
"config"
|
|
8
|
-
"eslintconfig",
|
|
9
|
-
"niondigital"
|
|
11
|
+
"eslint-config"
|
|
10
12
|
],
|
|
11
|
-
"author": "David Seibert <david.seibert@nion-digital.com>",
|
|
12
|
-
"homepage": "https://github.com/niondigital/javascript-style",
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"main": "index.js",
|
|
15
|
-
"exports": {
|
|
16
|
-
".": "./index.js",
|
|
17
|
-
"./.editorconfig": "./.editorconfig"
|
|
18
|
-
},
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/niondigital/javascript-style.git"
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"lint": "eslint .",
|
|
25
|
-
"lint:fix": "eslint . --fix"
|
|
26
|
-
},
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/niondigital/javascript-style/issues"
|
|
29
|
-
},
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@babel/runtime": "^7.23.9",
|
|
35
|
-
"@eslint/js": "^9.3.0",
|
|
36
|
-
"@types/eslint__js": "^8.42.3",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
38
|
-
"babel-preset-airbnb": "^4.5.0",
|
|
39
|
-
"babel-tape-runner": "^3.0.0",
|
|
40
|
-
"eclint": "^2.8.1",
|
|
41
|
-
"eslint": "^8.57.0",
|
|
42
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
43
|
-
"eslint-config-prettier": "^9.1.0",
|
|
44
|
-
"eslint-find-rules": "^4.1.0",
|
|
45
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
46
|
-
"eslint-plugin-import": "^2.29.1",
|
|
47
|
-
"eslint-plugin-jest": "^28.8.0",
|
|
48
|
-
"eslint-plugin-unused-imports": "^4.1.3",
|
|
49
|
-
"in-publish": "^2.0.1",
|
|
50
|
-
"jest": "^29.7.0",
|
|
51
|
-
"safe-publish-latest": "^2.0.0",
|
|
52
|
-
"typescript": "^5.4.5",
|
|
53
|
-
"typescript-eslint": "^7.11.0"
|
|
54
|
-
},
|
|
55
13
|
"peerDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"
|
|
59
|
-
"eslint
|
|
60
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
61
|
-
"eslint-plugin-import": "^2.29.1",
|
|
62
|
-
"eslint-plugin-jest": "^28.8.0",
|
|
63
|
-
"eslint-plugin-unused-imports": "^4.1.3",
|
|
64
|
-
"jest": "*"
|
|
65
|
-
},
|
|
66
|
-
"engines": {
|
|
67
|
-
"node": ">=18.0.0"
|
|
14
|
+
"@eslint/js": "^9.37.0",
|
|
15
|
+
"eslint": "^9.37.0",
|
|
16
|
+
"typescript": "^5.9.3",
|
|
17
|
+
"typescript-eslint": "^8.46.0"
|
|
68
18
|
},
|
|
69
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "977a04e3db155a623b3242fbe1d076be4ed2063e"
|
|
70
20
|
}
|
package/.eslintrc
DELETED
package/index.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
module.exports = {
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
extends: [
|
|
5
|
-
'eslint:recommended',
|
|
6
|
-
'plugin:@typescript-eslint/recommended',
|
|
7
|
-
'eslint-config-airbnb',
|
|
8
|
-
'plugin:jest/recommended',
|
|
9
|
-
'prettier'
|
|
10
|
-
],
|
|
11
|
-
plugins: ['@typescript-eslint', 'eslint-plugin-unused-imports'],
|
|
12
|
-
rules: {
|
|
13
|
-
'comma-dangle': 'off',
|
|
14
|
-
// use tabs for indentation
|
|
15
|
-
indent: 0,
|
|
16
|
-
'no-tabs': 0,
|
|
17
|
-
// allow imports without file extensions
|
|
18
|
-
'import/extensions': ['error', 'always', { js: 'never', ts: 'never' }],
|
|
19
|
-
// require leading spaces in comments
|
|
20
|
-
'spaced-comment': [
|
|
21
|
-
'error',
|
|
22
|
-
'always',
|
|
23
|
-
{
|
|
24
|
-
markers: ['/']
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
'import/prefer-default-export': 0,
|
|
28
|
-
|
|
29
|
-
'@typescript-eslint/indent': ['error', 'tab'],
|
|
30
|
-
|
|
31
|
-
'no-use-before-define': 0,
|
|
32
|
-
|
|
33
|
-
// allow long lines
|
|
34
|
-
'max-len': 0,
|
|
35
|
-
|
|
36
|
-
// handle redeclares via typescript-eslint
|
|
37
|
-
'no-redeclare': 'off',
|
|
38
|
-
'@typescript-eslint/no-redeclare': 'error',
|
|
39
|
-
|
|
40
|
-
// shadowing
|
|
41
|
-
'no-shadow': 'off', // replaced by ts-eslint rule below
|
|
42
|
-
'@typescript-eslint/no-shadow': 'error',
|
|
43
|
-
|
|
44
|
-
// naming conventions
|
|
45
|
-
camelcase: 'off',
|
|
46
|
-
'no-underscore-dangle': 'off',
|
|
47
|
-
'@typescript-eslint/naming-convention': [
|
|
48
|
-
'error',
|
|
49
|
-
{
|
|
50
|
-
selector: 'default',
|
|
51
|
-
format: ['camelCase']
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
selector: ['function'],
|
|
55
|
-
format: ['camelCase', 'PascalCase'],
|
|
56
|
-
leadingUnderscore: 'allow'
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
selector: 'variable',
|
|
60
|
-
format: ['camelCase', 'UPPER_CASE'],
|
|
61
|
-
leadingUnderscore: 'allow'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
selector: 'parameter',
|
|
65
|
-
format: ['camelCase'],
|
|
66
|
-
leadingUnderscore: 'allow'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
selector: 'memberLike',
|
|
70
|
-
format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
|
|
71
|
-
leadingUnderscore: 'allow'
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
selector: 'import',
|
|
75
|
-
format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
|
|
76
|
-
leadingUnderscore: 'allow'
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
selector: 'typeLike',
|
|
80
|
-
format: ['PascalCase']
|
|
81
|
-
}
|
|
82
|
-
/*
|
|
83
|
-
{
|
|
84
|
-
selector: 'interface',
|
|
85
|
-
format: ['PascalCase'],
|
|
86
|
-
prefix: ['I']
|
|
87
|
-
}
|
|
88
|
-
*/
|
|
89
|
-
],
|
|
90
|
-
|
|
91
|
-
// types
|
|
92
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
93
|
-
'@typescript-eslint/no-inferrable-types': 'off',
|
|
94
|
-
|
|
95
|
-
// member accessibility
|
|
96
|
-
'@typescript-eslint/explicit-member-accessibility': 'error',
|
|
97
|
-
|
|
98
|
-
// unused vars
|
|
99
|
-
'no-unused-vars': 'off',
|
|
100
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
101
|
-
'unused-imports/no-unused-imports': 'error',
|
|
102
|
-
'unused-imports/no-unused-vars': [
|
|
103
|
-
'warn',
|
|
104
|
-
{
|
|
105
|
-
vars: 'all',
|
|
106
|
-
varsIgnorePattern: '^_',
|
|
107
|
-
args: 'after-used',
|
|
108
|
-
argsIgnorePattern: '^_'
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
|
|
112
|
-
// use of semicolons
|
|
113
|
-
semi: 'off',
|
|
114
|
-
'@typescript-eslint/semi': ['error'],
|
|
115
|
-
|
|
116
|
-
// this usage in classes
|
|
117
|
-
'class-methods-use-this': 'off',
|
|
118
|
-
'@typescript-eslint/class-methods-use-this': 'error'
|
|
119
|
-
},
|
|
120
|
-
overrides: [
|
|
121
|
-
{
|
|
122
|
-
files: ['**/*.test.{j,t}s?(x)'],
|
|
123
|
-
plugins: ['jest'],
|
|
124
|
-
env: {
|
|
125
|
-
'jest/globals': true
|
|
126
|
-
},
|
|
127
|
-
rules: {
|
|
128
|
-
'jest/no-disabled-tests': 'warn',
|
|
129
|
-
'jest/no-identical-title': 'error',
|
|
130
|
-
'jest/valid-expect': 'error'
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
// .js files (including config files in the package root directory) are likely to not be included
|
|
134
|
-
// in the tsconfig.json file. So we can't parse them with the regular parser as this would fail
|
|
135
|
-
// as it requires all linted files to be included in tsconfig
|
|
136
|
-
{
|
|
137
|
-
files: ['./*.js', './.*.js', '**/*.js', '**/.*.js'],
|
|
138
|
-
parserOptions: {
|
|
139
|
-
parser: 'espree'
|
|
140
|
-
},
|
|
141
|
-
rules: {
|
|
142
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
143
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
144
|
-
'import/no-unresolved': 'off'
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
// handle storybook config files indentation issues
|
|
148
|
-
{
|
|
149
|
-
files: ['./*.stories.js', './.*.stories.js', '**/*.stories.js', '**/.*.stories.js'],
|
|
150
|
-
parserOptions: {
|
|
151
|
-
parser: 'espree'
|
|
152
|
-
},
|
|
153
|
-
rules: {
|
|
154
|
-
'@typescript-eslint/indent': 'off',
|
|
155
|
-
'prettier/prettier': 'off'
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
settings: {
|
|
160
|
-
'import/resolver': {
|
|
161
|
-
typescript: {},
|
|
162
|
-
node: {
|
|
163
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
'import/parsers': {
|
|
167
|
-
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|