Skip to content

Commit c102033

Browse files
committed
feat(eslint)!: level up to eslint flat config
BREAKING CHANGES: - no eslint ^9.37 is required - sc config is applied by using the exposed functions - sc rules shall be used with recommended config
1 parent 91a2b72 commit c102033

23 files changed

+2952
-2630
lines changed

package-lock.json

Lines changed: 2602 additions & 2182 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"scripts": {
1212
"build:ci": "lerna run build",
13-
"build:lint:ci": "lerna run build:lint:ci",
13+
"build:lint:ci": "lerna run build --scope @shiftcode/eslint-plugin-rules && lerna run build --scope @shiftcode/eslint-config-recommended",
1414
"lint:ci": "lerna run lint:ci",
1515
"prepare": "husky",
1616
"prettier": "lerna run prettier",
@@ -27,8 +27,7 @@
2727
"@commitlint/prompt-cli": "^19.3.1",
2828
"@types/jest": "^29.5.12",
2929
"@types/node": "^20.11.1",
30-
"@typescript-eslint/eslint-plugin": "^8.13.0",
31-
"eslint": "^9.3.0",
30+
"eslint": "^9.36.0",
3231
"husky": "^9.0.11",
3332
"jest": "^29.7.0",
3433
"lint-staged": "^15.2.7",

packages/eslint-config-recommended/README.md

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,67 @@
22

33
> 🎯 Target runtime: es2023 ([Node >= 20](https://node.green/#ES2023))
44
5-
> ⚠️ This module exports code using CommonJS
65

76
This module provides an eslint default rule-set configuration for shiftcode projects.
87

98
### remark
109

11-
by using this module, the [@shiftcode/eslint-plugin-rules](../eslint-plugin-rules) module will be automatically included too.
10+
by using this module, the [@shiftcode/eslint-plugin-rules](../eslint-plugin-rules) module will be automatically included
11+
too.
12+
and depends on additional libraries that provide rules.
1213

1314
## usage
15+
the module only exports a single function `defineScTsConfig` which can be used to create the eslint configuration.
16+
it is basically a wrapper around the new eslint `defineConfig` function but already includes the setup for typescript,
17+
some rules with default configurations and will ensure the prettier rules (disabling formatting rules) are included at last.
1418

15-
sample .eslintrc.js file:
16-
17-
```javascript
18-
module.exports = {
19-
// ...
20-
21-
// all child eslintrc configs from workspace packages inherit this extension
22-
extends: [
23-
'^shiftcode',
24-
],
25-
26-
// ...
27-
}
28-
```
19+
sample `eslint.config.mjs`:
2920

30-
## provided configurations
21+
```js
22+
import { defineScTsConfig } from '@shiftcode/eslint-config-recommended'
3123

32-
the following provided configurations might be included:
24+
export default defineScTsConfig(
25+
{
26+
languageOptions: {
27+
ecmaVersion: 2023,
28+
sourceType: 'module',
29+
parserOptions: { project: ['./tsconfig.json', './tsconfig.spec.json'] },
30+
},
31+
},
32+
{
33+
files: ['**/*.ts'],
34+
rules: {
35+
'@typescript-eslint/explicit-function-return-type': 'error',
36+
},
37+
}
38+
)
39+
```
3340

34-
- ``@shiftcode/recommended``: rule-set for common javascript and typescript files
35-
- ``@shiftcode/recommended/ng-config``: angular-specific rule-set for angular apps
41+
## Additional configurations
3642

37-
## Optional Peer Dependencies
38-
All the optional peer dependencies (`@angular-eslint/*`) are only required if the [ng-config](./src/ng-config/index.ts)
39-
is used
43+
Additionally on the submodule `/angular` the `defineScAngularConfig` function is exported
44+
which includes angular-specific rules and configurations.
4045

41-
## Ideas
46+
```js
47+
import { defineScAngularConfig } from '@shiftcode/eslint-config-recommended/angular'
4248

43-
it could be useful to create another configuration (i.e. ``shiftcode/node-config``)
44-
used within services/backend workspaces, because the naming conventions aren't really the same as for a client workspace.
49+
export default defineScAngularConfig(
50+
{
51+
languageOptions: {
52+
ecmaVersion: 2022,
53+
sourceType: 'module',
54+
parserOptions: {
55+
project: ['./tsconfig.app.json', './tsconfig.spec.json'],
56+
},
57+
},
58+
},
59+
{
60+
files: ['**/*.ts'],
61+
rules: {
62+
'@angular-eslint/component-selector': ['error', { type: 'element', prefix: 'gf', style: 'kebab-case' }],
63+
},
64+
}
65+
)
66+
```
4567

46-
Examples:
47-
- const PEdgeLabel = ...
48-
- export const JwtGuardConfig = ...
49-
- const { TextP } = process
50-
- export function VersionedITOf<T,K> { ... }
51-
- etc.
68+
when using the angular configuration, the peer dependency `angular-eslint` is required.

packages/eslint-config-recommended/docs/README.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/eslint-config-recommended/docs/base_eslintrc.mjs

Lines changed: 0 additions & 49 deletions
This file was deleted.

packages/eslint-config-recommended/docs/tslint-to-eslint-mapping.ts

Lines changed: 0 additions & 126 deletions
This file was deleted.

packages/eslint-config-recommended/ng-config/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/eslint-config-recommended/package.json

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
"license": "UNLICENSED",
77
"author": "shiftcode GmbH <[email protected]>",
88
"sideEffects": false,
9-
"type": "commonjs",
9+
"type": "module",
1010
"exports": {
1111
".": {
1212
"types": "./dist/index.d.ts",
1313
"default": "./dist/index.js"
1414
},
15-
"./ng-config": {
16-
"types": "./dist/ng-config/index.d.ts",
17-
"default": "./dist/ng-config/index.js"
15+
"./angular": {
16+
"types": "./dist/angular/index.d.ts",
17+
"default": "./dist/angular/index.js"
1818
}
1919
},
20-
"main": "./dist/index.js",
21-
"module": "./dist/index.js",
2220
"types": "./dist/index.d.ts",
2321
"scripts": {
2422
"prebuild": "rm -rf ./dist",
@@ -36,36 +34,22 @@
3634
"test:ci": "npm run test"
3735
},
3836
"dependencies": {
37+
"@eslint/js": "^9.37.0",
3938
"@shiftcode/eslint-plugin-rules": "^2.0.1",
40-
"@typescript-eslint/eslint-plugin": "^8.17.0",
41-
"@typescript-eslint/parser": "^8.17.0",
42-
"eslint": "^9.3.0",
43-
"eslint-config-prettier": "^9.1.0",
44-
"eslint-plugin-import": "^2.30.0",
45-
"eslint-plugin-unused-imports": "^4.1.3",
46-
"typescript-eslint": "8.13.0"
39+
"eslint": "^9.37.0",
40+
"eslint-config-prettier": "^10.1.8",
41+
"eslint-plugin-import": "^2.32.0",
42+
"eslint-plugin-unused-imports": "^4.2.0",
43+
"typescript-eslint": "8.46.0"
44+
},
45+
"devDependencies": {
46+
"angular-eslint": "^20.3.0"
4747
},
4848
"peerDependencies": {
49-
"@angular-eslint/builder": "^19.0.0",
50-
"@angular-eslint/eslint-plugin": "^19.0.0",
51-
"@angular-eslint/eslint-plugin-template": "^19.0.0",
52-
"@angular-eslint/schematics": "^19.0.0",
53-
"@angular-eslint/template-parser": "^19.0.0"
49+
"angular-eslint": "^20.3.0"
5450
},
5551
"peerDependenciesMeta": {
56-
"@angular-eslint/builder": {
57-
"optional": true
58-
},
59-
"@angular-eslint/eslint-plugin": {
60-
"optional": true
61-
},
62-
"@angular-eslint/eslint-plugin-template": {
63-
"optional": true
64-
},
65-
"@angular-eslint/schematics": {
66-
"optional": true
67-
},
68-
"@angular-eslint/template-parser": {
52+
"angular-eslint": {
6953
"optional": true
7054
}
7155
},

0 commit comments

Comments
 (0)