@niondigital/eslint-config-base 1.10.0 → 2.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/README.md CHANGED
@@ -1,32 +1,44 @@
1
1
  # `@niondigital/eslint-config-base`
2
2
 
3
- This package provides an eslint config as used by [nion digital](https://www.nion-digital.com) as an extensible shared config.
3
+ Shared ESLint config as base by [nion digital](https://www.nion-digital.com).
4
4
 
5
5
  ## Installation
6
6
 
7
- ```sh
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
- ## Usage
13
+ 2. Create `eslint.config.mjs` at the root and add the following code:
12
14
 
13
- Extend local eslint configuration with `@niondigital/eslint-config-base`:
15
+ ```js
16
+ import getConfig from '@niondigital/eslint-config-base';
14
17
 
15
- ```json
16
- {
17
- "extends": "@niondigital/eslint-config-base",
18
- "rules": {}
19
- }
18
+ export default getConfig();
20
19
  ```
21
20
 
22
- ## License
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
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
29
-
30
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
23
+ ```js
24
+ {
25
+ // ...
26
+ "scripts": {
27
+ // ...
28
+ "eslint": "eslint --fix \"src/**/*.ts\""
29
+ }
30
+ }
31
+ ```
31
32
 
32
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
- "version": "1.10.0",
4
- "description": "niondigital base eslint config",
3
+ "type": "module",
4
+ "version": "2.0.1",
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
- "@typescript-eslint/eslint-plugin": "^7.15.0",
57
- "eslint": "^8.2.0",
58
- "eslint-config-airbnb": "^19.0.4",
59
- "eslint-config-prettier": "^9.1.0",
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": "b7e03be9363548807715e7f3c778ad507d102d38"
19
+ "gitHead": "1f3beb8e3c7a6e59cfa23b4849b272ab68ed5a35"
70
20
  }
package/.eslintrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "./index.js",
3
- "rules": {
4
- "@typescript-eslint/naming-convention": "off"
5
- }
6
- }
package/index.js DELETED
@@ -1,175 +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
- selector: 'variable',
84
- modifiers: ['destructured'],
85
- format: null /* allow other naming styles in destructured variables, e.g. for parsing API responses */
86
- }
87
- /*
88
- {
89
- selector: 'interface',
90
- format: ['PascalCase'],
91
- prefix: ['I']
92
- }
93
- */
94
- ],
95
-
96
- // types
97
- '@typescript-eslint/no-explicit-any': 'off',
98
- '@typescript-eslint/no-inferrable-types': 'off',
99
-
100
- // member accessibility
101
- '@typescript-eslint/explicit-member-accessibility': 'error',
102
-
103
- // unused vars
104
- 'no-unused-vars': 'off',
105
- '@typescript-eslint/no-unused-vars': 'off',
106
- 'unused-imports/no-unused-imports': 'error',
107
- 'unused-imports/no-unused-vars': [
108
- 'warn',
109
- {
110
- vars: 'all',
111
- varsIgnorePattern: '^_',
112
- args: 'after-used',
113
- argsIgnorePattern: '^_'
114
- }
115
- ],
116
-
117
- // use of semicolons
118
- semi: 'off',
119
- '@typescript-eslint/semi': ['error'],
120
-
121
- // this usage in classes
122
- 'class-methods-use-this': 'off',
123
- '@typescript-eslint/class-methods-use-this': 'error'
124
- },
125
- overrides: [
126
- {
127
- files: ['**/*.test.{j,t}s?(x)'],
128
- plugins: ['jest'],
129
- env: {
130
- 'jest/globals': true
131
- },
132
- rules: {
133
- 'jest/no-disabled-tests': 'warn',
134
- 'jest/no-identical-title': 'error',
135
- 'jest/valid-expect': 'error'
136
- }
137
- },
138
- // .js files (including config files in the package root directory) are likely to not be included
139
- // in the tsconfig.json file. So we can't parse them with the regular parser as this would fail
140
- // as it requires all linted files to be included in tsconfig
141
- {
142
- files: ['./*.js', './.*.js', '**/*.js', '**/.*.js'],
143
- parserOptions: {
144
- parser: 'espree'
145
- },
146
- rules: {
147
- '@typescript-eslint/explicit-function-return-type': 'off',
148
- '@typescript-eslint/naming-convention': 'off',
149
- 'import/no-unresolved': 'off'
150
- }
151
- },
152
- // handle storybook config files indentation issues
153
- {
154
- files: ['./*.stories.js', './.*.stories.js', '**/*.stories.js', '**/.*.stories.js'],
155
- parserOptions: {
156
- parser: 'espree'
157
- },
158
- rules: {
159
- '@typescript-eslint/indent': 'off',
160
- 'prettier/prettier': 'off'
161
- }
162
- }
163
- ],
164
- settings: {
165
- 'import/resolver': {
166
- typescript: {},
167
- node: {
168
- extensions: ['.js', '.jsx', '.ts', '.tsx']
169
- }
170
- },
171
- 'import/parsers': {
172
- '@typescript-eslint/parser': ['.ts', '.tsx']
173
- }
174
- }
175
- };