Skip to content

Commit

Permalink
feat(eslint): migrate deprecated typescript-eslint rules to stylistic (
Browse files Browse the repository at this point in the history
…#1297)

## Proposed change

Migrating deprecated eslint-typescript rules to stylistic linter
split the typescript rules to files according to the plugin they refer
to
  • Loading branch information
kpanot authored Jan 31, 2024
2 parents 89c89ca + b38f210 commit b463843
Show file tree
Hide file tree
Showing 77 changed files with 980 additions and 630 deletions.
1 change: 1 addition & 0 deletions apps/chrome-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/localization": "workspace:^",
"@o3r/rules-engine": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/chrome": "^0.0.259",
"@types/jest": "~29.5.2",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions apps/github-cascading-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@nx/js": "~17.2.0",
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/ejs": "^3.1.2",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions apps/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"@o3r/testing": "workspace:^",
"@playwright/test": "~1.41.0",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/bootstrap": "^5.2.6",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions apps/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
"@o3r/core": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/eslint": "^8.42.0",
"@types/glob": "^8.0.0",
"@types/jest": "~29.5.2",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
"@playwright/test": "~1.41.0",
"@popperjs/core": "^2.11.5",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@swc-node/register": "^1.6.7",
"@swc/core": "^1.3.85",
"@types/jest": "~29.5.2",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@swc/cli": "^0.3.0",
"@swc/core": "^1.3.85",
"@types/jest": "~29.5.2",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@o3r/test-helpers": "workspace:^",
"@openapitools/openapi-generator-cli": "~2.9.0",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
"@types/minimatch": "^5.1.2",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/showcase-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@openapitools/openapi-generator-cli": "~2.9.0",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@swc/cli": "^0.3.0",
"@swc/core": "^1.3.85",
"@types/jest": "~29.5.2",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/swagger-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/glob": "^8.0.0",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-terasu/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@o3r/amaterasu-sdk": "workspace:^",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-terasu/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-terasu/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/amaterasu/amaterasu-api-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/amaterasu/amaterasu-dodo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@types/tar": "~6.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/amaterasu/amaterasu-otter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/amaterasu/amaterasu-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jasmine": "~5.1.0",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/apis-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@o3r/schematics": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@o3r/schematics": "workspace:^",
"@o3r/testing": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/artifactory-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/fs-extra": "^11.0.0",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/azure-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"@o3r/test-helpers": "workspace:^",
"@o3r/testing": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"@o3r/test-helpers": "workspace:^",
"@o3r/testing": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jasmine": "~5.1.0",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/@o3r/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@o3r/telemetry": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down Expand Up @@ -149,6 +150,7 @@
"@types/jest": "~29.5.2",
"nx": "~17.2.0",
"@typescript-eslint/parser": "^6.11.0",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"cpy-cli": "^5.0.0",
"eslint": "^8.42.0",
"@nx/eslint-plugin": "~17.2.0",
Expand Down
14 changes: 5 additions & 9 deletions packages/@o3r/core/src/store/async/async.operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ import { AsyncRequest, ExtractFromApiActionPayloadType, FromApiActionPayload } f
* @param cancelRequestActionFactory function that returns the action to emit in case the FromApi action is 'cancelled' because a new action was received by the switchMap
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export function fromApiEffectSwitchMap<
T extends FromApiActionPayload<any>,
S extends ExtractFromApiActionPayloadType<T>,
U extends Action,
V extends Action,
W extends Action>(
successHandler: (result: S, action: T) => U | Observable<U> | Promise<Observable<U> | U>,
errorHandler?: (error: any, action: T) => Observable<V>,
cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W): OperatorFunction<T, U | V | W> {
export function fromApiEffectSwitchMap<T extends FromApiActionPayload<any>, S extends ExtractFromApiActionPayloadType<T>, U extends Action, V extends Action, W extends Action>(
successHandler: (result: S, action: T) => U | Observable<U> | Promise<Observable<U> | U>,
errorHandler?: (error: any, action: T) => Observable<V>,
cancelRequestActionFactory?: (props: AsyncRequest, action: T) => W): OperatorFunction<T, U | V | W> {

const pendingRequestIdsContext: Record<string, boolean> = {};

return (source$) => source$.pipe(
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"@o3r/styling": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^20.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type DesignTokenTypeStrokeStyleDetailsValue = {

/** Value of the Design Token Stroke Style */
export type DesignTokenTypeStrokeStyleValue = DesignTokenTypeStrokeStyleDetailsValue |
'solid' | 'dashed' | 'dotted' | 'double'| 'groove' | 'ridge' | 'outset' | 'inset';
'solid' | 'dashed' | 'dotted' | 'double' | 'groove' | 'ridge' | 'outset' | 'inset';

/** Design Token Stroke Style */
export interface DesignTokenTypeStrokeStyle<T extends DesignTokenTypeStrokeStyleValue = DesignTokenTypeStrokeStyleValue> extends DesignTokenBase<T> {
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/dev-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@nx/jest": "~17.2.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/fs-extra": "^11.0.0",
"@types/glob": "^8.0.0",
"@types/jest": "~29.5.2",
Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/dynamic-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/jasmine": "~5.1.0",
"@types/jest": "~29.5.2",
"@types/node": "^20.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class DynamicContentService {
private readonly mediaFolder: string;

constructor(@Inject(DYNAMIC_CONTENT_BASE_PATH_TOKEN) dynamicContentPath: string,
@Inject(CMS_ASSETS_PATH_TOKEN) private readonly cmsOnlyAssetsPath: string,
@Optional() private readonly store?: Store<AssetPathOverrideStore>) {
@Inject(CMS_ASSETS_PATH_TOKEN) private readonly cmsOnlyAssetsPath: string,
@Optional() private readonly store?: Store<AssetPathOverrideStore>) {
this.basePath = dynamicContentPath.replace(/\/$/, '');
this.mediaFolder = MEDIA_FOLDER_NAME;
}
Expand Down
16 changes: 1 addition & 15 deletions packages/@o3r/eslint-config-otter/index.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable quote-props */
module.exports = {
'extends': [
'./typescript.cjs',
'plugin:jest/recommended'
],
'plugins': [
'jest'
],
'rules': {
'jest/no-conditional-expect': 'warn',
'jest/no-done-callback': 'warn'
}
};
module.exports = require('./typescript.cjs');
10 changes: 10 additions & 0 deletions packages/@o3r/eslint-config-otter/migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/schematics/collection-schema.json",
"schematics": {
"migration-v10_0": {
"version": "10.0.0-alpha.0",
"description": "Updates of the Otter Library to v10.0.*",
"factory": "./schematics/ng-update/index#updateV100"
}
}
}
9 changes: 7 additions & 2 deletions packages/@o3r/eslint-config-otter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"build": "yarn cpy --flat {typescript,typescript-fast,index,jasmine,jasmine-fast,template}.cjs package.json dist && yarn postbuild",
"postbuild": "patch-package-json-main",
"prepare:publish": "prepare-publish ./dist",
"prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy 'collection.json' dist",
"prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy '{collection,migration}.json' dist",
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
},
"peerDependencies": {
Expand All @@ -56,6 +56,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@schematics/angular": "~17.0.0",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.11.0",
"eslint": "^8.22.0",
Expand All @@ -79,6 +80,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@schematics/angular": "~17.0.3",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.11.0",
Expand Down Expand Up @@ -126,5 +128,8 @@
"optional": true
}
},
"schematics": "./collection.json"
"schematics": "./collection.json",
"ng-update": {
"migrations": "./migration.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable @typescript-eslint/naming-convention */

module.exports = {
'extends': [
'plugin:@angular-eslint/template/recommended'
],
'rules': {
'max-len': 'off'
}
};
13 changes: 13 additions & 0 deletions packages/@o3r/eslint-config-otter/rules/template/otter.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/naming-convention */

module.exports = {
extends: [
'plugin:@o3r/template-recommended'
],
plugins: [
'@o3r'
],
rules: {
'@o3r/no-folder-import-for-module': 'error'
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable @typescript-eslint/naming-convention */

module.exports = {
extends: [
'plugin:@angular-eslint/recommended'
],
rules: {
'@angular-eslint/no-host-metadata-property': 'off',
'@angular-eslint/no-input-rename': 'off',
'@angular-eslint/directive-class-suffix': 'off',
'@angular-eslint/no-empty-lifecycle-method': 'off',
'@angular-eslint/no-output-on-prefix': 'error',
'@angular-eslint/directive-selector': [
'error',
{
'type': 'attribute',
'style': 'camelCase'
}
],
'@angular-eslint/component-selector': [
'error',
{
'type': 'element',
'style': 'kebab-case'
}
]
}
};
Loading

0 comments on commit b463843

Please sign in to comment.