Skip to content

Commit

Permalink
chore: Migrate from TSLint to ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Mar 9, 2023
1 parent bcf60de commit 0441a03
Show file tree
Hide file tree
Showing 454 changed files with 15,044 additions and 9,434 deletions.
288 changes: 288 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
ignorePatterns: ['**/generated*', '**/*.js', '**/*.d.ts', '/packages/ui-devkit/scaffold/**/*'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: [
'eslint-plugin-import',
'eslint-plugin-jsdoc',
'eslint-plugin-prefer-arrow',
'@typescript-eslint',
],
root: true,
overrides: [
{
files: ['./packages/ui-devkit/src/client/**/*'],
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
},
{
files: ['./packages/ui-devkit/src/compiler/**/*'],
parserOptions: {
project: 'tsconfig.compiler.json',
sourceType: 'module',
},
},
],
rules: {
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': [
'error',
{
types: {
Object: {
message: 'Avoid using the `Object` type. Did you mean `object`?',
},
Function: {
message:
'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
},
Boolean: {
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
},
Number: {
message: 'Avoid using the `Number` type. Did you mean `number`?',
},
String: {
message: 'Avoid using the `String` type. Did you mean `string`?',
},
Symbol: {
message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
},
},
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'off',
{
accessibility: 'explicit',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/naming-convention': [
'off',
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extra-semi': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
},
],
'@typescript-eslint/no-loss-of-precision': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-shadow': [
'error',
{
hoist: 'all',
},
],
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/quotes': ['error', 'single'],
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/triple-slash-reference': [
'error',
{
path: 'always',
types: 'prefer-import',
lib: 'always',
},
],
'@typescript-eslint/typedef': 'off',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
'arrow-parens': ['off', 'always'],
complexity: 'off',
'constructor-super': 'error',
'dot-notation': 'off',
eqeqeq: ['error', 'smart'],
'guard-for-in': 'error',
'id-denylist': 'off',
'id-match': 'off',
'import/order': [
'error',
{
alphabetize: {
caseInsensitive: true,
order: 'asc',
},
'newlines-between': 'always',
groups: [
['builtin', 'external', 'internal', 'unknown', 'object', 'type'],
'parent',
['sibling', 'index'],
],
distinctGroup: false,
pathGroupsExcludedImportTypes: [],
pathGroups: [
{
pattern: './',
patternOptions: {
nocomment: true,
dot: true,
},
group: 'sibling',
position: 'before',
},
{
pattern: '.',
patternOptions: {
nocomment: true,
dot: true,
},
group: 'sibling',
position: 'before',
},
{
pattern: '..',
patternOptions: {
nocomment: true,
dot: true,
},
group: 'parent',
position: 'before',
},
{
pattern: '../',
patternOptions: {
nocomment: true,
dot: true,
},
group: 'parent',
position: 'before',
},
],
},
],
indent: 'off',
'jsdoc/check-alignment': 'off',
'jsdoc/check-indentation': 'off',
'jsdoc/newline-after-description': 'off',
'max-classes-per-file': 'off',
'max-len': [
'error',
{
code: 170,
},
],
'new-parens': 'error',
'no-array-constructor': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-empty': 'error',
'no-empty-function': 'off',
'no-eval': 'error',
'no-extra-semi': 'off',
'no-fallthrough': 'error',
'no-implied-eval': 'off',
'no-invalid-this': 'off',
'no-loss-of-precision': 'off',
'no-new-wrappers': 'error',
'no-shadow': 'off',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-underscore-dangle': 'off',
'no-unsafe-finally': 'error',
'no-unused-expressions': 'off',
'no-unused-labels': 'error',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'no-var': 'error',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'prefer-arrow/prefer-arrow-functions': 'off',
'prefer-const': 'error',
quotes: 'off',
radix: 'error',
'require-await': 'off',
'spaced-comment': [
'error',
'always',
{
markers: ['/'],
},
],
'use-isnan': 'error',
'valid-typeof': 'off',
},
};
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"watch": "lerna run watch --parallel",
"watch:core-common": "lerna run --scope @vendure/common --scope @vendure/core watch --parallel",
"lint": "yarn tslint --fix",
"lint": "yarn eslint --fix",
"format": "prettier --write --html-whitespace-sensitivity ignore",
"bootstrap": "lerna bootstrap",
"docs:generate-typescript-docs": "ts-node scripts/docs/generate-typescript-docs.ts",
Expand Down Expand Up @@ -52,7 +52,6 @@
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"typescript": "4.9.5",
"unplugin-swc": "^1.3.2",
"vitest": "^0.29.2"
Expand Down Expand Up @@ -91,5 +90,14 @@
"pre-commit": "lint-staged",
"pre-push": "yarn check-imports && yarn check-angular-versions && yarn build && yarn test && yarn e2e"
}
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^40.0.1",
"eslint-plugin-prefer-arrow": "^1.2.3"
}
}
2 changes: 1 addition & 1 deletion packages/admin-ui-plugin/build.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:no-console */
/* eslint-disable no-console */
import { execSync, spawn } from 'child_process';
import fs from 'fs-extra';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/admin-ui-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "rimraf lib && node -r ts-node/register build.ts && yarn compile",
"watch": "tsc -p ./tsconfig.build.json --watch",
"lint": "tslint --fix --project ./",
"lint": "eslint --fix .",
"compile": "tsc -p ./tsconfig.build.json"
},
"homepage": "https://www.vendure.io/",
Expand Down
20 changes: 11 additions & 9 deletions packages/admin-ui-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ export class AdminUiPlugin implements NestModule {
)
.forRoutes('sockjs-node');

Logger.info(`Compiling Admin UI app in development mode`, loggerCtx);
Logger.info('Compiling Admin UI app in development mode', loggerCtx);
app.compile().then(
() => {
Logger.info(`Admin UI compiling and watching for changes...`, loggerCtx);
Logger.info('Admin UI compiling and watching for changes...', loggerCtx);
},
(err: any) => {
Logger.error(`Failed to compile: ${err}`, loggerCtx, err.stack);
Logger.error(`Failed to compile: ${JSON.stringify(err)}`, loggerCtx, err.stack);
},
);
await overwriteConfig();
Expand All @@ -178,15 +178,15 @@ export class AdminUiPlugin implements NestModule {
consumer.apply(await this.createStaticServer(app)).forRoutes(route);

if (app && typeof app.compile === 'function') {
Logger.info(`Compiling Admin UI app in production mode...`, loggerCtx);
Logger.info('Compiling Admin UI app in production mode...', loggerCtx);
app.compile()
.then(overwriteConfig)
.then(
() => {
Logger.info(`Admin UI successfully compiled`, loggerCtx);
Logger.info('Admin UI successfully compiled', loggerCtx);
},
(err: any) => {
Logger.error(`Failed to compile: ${err}`, loggerCtx, err.stack);
Logger.error(`Failed to compile: ${JSON.stringify(err)}`, loggerCtx, err.stack);
},
);
} else {
Expand Down Expand Up @@ -265,9 +265,11 @@ export class AdminUiPlugin implements NestModule {
try {
await fs.writeFile(adminUiConfigPath, JSON.stringify(config, null, 2));
} catch (e: any) {
throw new Error('[AdminUiPlugin] Could not write vendure-ui-config.json file:\n' + e.message);
throw new Error(
'[AdminUiPlugin] Could not write vendure-ui-config.json file:\n' + JSON.stringify(e.message),
);
}
Logger.verbose(`Applied configuration to vendure-ui-config.json file`, loggerCtx);
Logger.verbose('Applied configuration to vendure-ui-config.json file', loggerCtx);
}

/**
Expand All @@ -289,7 +291,7 @@ export class AdminUiPlugin implements NestModule {
);
await fs.writeFile(indexHtmlPath, withCustomBaseHref);
} catch (e: any) {
throw new Error('[AdminUiPlugin] Could not write index.html file:\n' + e.message);
throw new Error('[AdminUiPlugin] Could not write index.html file:\n' + JSON.stringify(e.message));
}
Logger.verbose(`Applied baseHref "/${baseHref}/" to index.html file`, loggerCtx);
}
Expand Down
Loading

0 comments on commit 0441a03

Please sign in to comment.