From 63d9287a3aa9eac892688d7fe513004c3e36d54d Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 11 Feb 2022 23:34:40 +0100 Subject: [PATCH] using one eslint config --- .eslintrc.json | 43 ++++++++++++++++++++---- frontend/gulpfile.js | 17 +++------- ts.eslintrc.json => old_js.eslintrc.json | 25 +++----------- 3 files changed, 45 insertions(+), 40 deletions(-) rename ts.eslintrc.json => old_js.eslintrc.json (62%) diff --git a/.eslintrc.json b/.eslintrc.json index 971975097..4fec5fa13 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,13 +16,16 @@ "extends": [ "eslint:recommended", "plugin:json/recommended", - "plugin:require-path-exists/recommended" + "plugin:require-path-exists/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" ], - "plugins": ["json", "require-path-exists"], + "plugins": ["json", "require-path-exists", "@typescript-eslint"], "parserOptions": { - "ecmaVersion": 13, + "ecmaVersion": 12, "sourceType": "module" }, + // "parser": "@typescript-eslint/parser", "rules": { "json/*": ["error"], "indent": ["off"], //handled by prettier @@ -33,15 +36,41 @@ { "allowTemplateLiterals": true, "avoidEscape": true } ], "semi": ["error", "always"], - "no-unused-vars": ["error", { "argsIgnorePattern": "^(_|e|event)" }], "no-empty": ["error", { "allowEmptyCatch": true }], + "no-unused-vars": ["error", { "argsIgnorePattern": "^(_|e|event)" }], + "no-var": 2, "require-path-exists/notEmpty": 2, "require-path-exists/tooManyArguments": 2, "require-path-exists/exists": [ 2, { - "extensions": ["", ".ts", ".js", ".es.js", ".json5", ".es", ".es6"] + "extensions": [ + "", + ".js", + ".ts", + ".tsx", + ".es.ts", + ".tsx", + ".json5", + ".es", + ".es6", + ".coffee" + ] } - ] - } + ], + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-unused-vars": "off" + }, + "overrides": [ + { + // enable the rule specifically for TypeScript files + "files": ["*.ts", "*.tsx"], + "rules": { + "@typescript-eslint/explicit-function-return-type": ["error"], + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/no-empty-function": "error", + "@typescript-eslint/no-unused-vars": "error" + } + } + ] } diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index 36fa151d3..deb86a77b 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -22,20 +22,13 @@ task("clean", function () { return src(["./public/"], { allowEmpty: true }).pipe(vinylPaths(del)); }); -task("lint-js", function () { - return src("./src/js/**/*.js") +task("lint", function () { + return src(["./src/js/**/*.js", "./src/js/**/*.ts"]) .pipe(eslint(eslintConfig)) .pipe(eslint.format()) .pipe(eslint.failAfterError()); }); -task("lint-ts", function () { - return src("./src/js/**/*.ts") - .pipe(eslint(tsEslintConfig)) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - task("lint-json", function () { return src("./static/**/*.json") .pipe(eslint(eslintConfig)) @@ -121,8 +114,7 @@ task("updateSwCacheName", function () { task( "compile", series( - "lint-js", - "lint-ts", + "lint", "lint-json", "browserify", "static", @@ -133,8 +125,7 @@ task( task("watch", function () { watch("./src/sass/**/*.scss", series("sass")); - watch("./src/js/**/*.js", series("lint-js", "browserify")); - watch("./src/js/**/*.ts", series("lint-ts", "browserify")); + watch(["./src/js/**/*.js", "./src/js/**/*.ts"], series("lint", "browserify")); watch("./static/**/*.*", series("lint-json", "static")); }); diff --git a/ts.eslintrc.json b/old_js.eslintrc.json similarity index 62% rename from ts.eslintrc.json rename to old_js.eslintrc.json index 987be60c1..971975097 100644 --- a/ts.eslintrc.json +++ b/old_js.eslintrc.json @@ -16,18 +16,14 @@ "extends": [ "eslint:recommended", "plugin:json/recommended", - "plugin:require-path-exists/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" + "plugin:require-path-exists/recommended" ], - "plugins": ["json", "require-path-exists", "@typescript-eslint"], + "plugins": ["json", "require-path-exists"], "parserOptions": { - "ecmaVersion": 12, + "ecmaVersion": 13, "sourceType": "module" }, - "parser": "@typescript-eslint/parser", "rules": { - "@typescript-eslint/ban-ts-comment": "off", "json/*": ["error"], "indent": ["off"], //handled by prettier "linebreak-style": ["error", "unix"], @@ -37,25 +33,14 @@ { "allowTemplateLiterals": true, "avoidEscape": true } ], "semi": ["error", "always"], + "no-unused-vars": ["error", { "argsIgnorePattern": "^(_|e|event)" }], "no-empty": ["error", { "allowEmptyCatch": true }], - "no-var": 2, "require-path-exists/notEmpty": 2, "require-path-exists/tooManyArguments": 2, "require-path-exists/exists": [ 2, { - "extensions": [ - "", - ".js", - ".ts", - ".tsx", - ".es.ts", - ".tsx", - ".json5", - ".es", - ".es6", - ".coffee" - ] + "extensions": ["", ".ts", ".js", ".es.js", ".json5", ".es", ".es6"] } ] }