From dcdee8b3080f92965b74a70099d8a01ce086d5d2 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 6 Sep 2020 09:32:16 +0200 Subject: [PATCH] Simplified eslint config --- .eslintrc | 77 ++++++------------------------- config/env.js | 1 + config/paths.js | 1 + config/webpack.config.js | 4 +- config/webpackDevServer.config.js | 1 + scripts/build.js | 6 +-- scripts/start.js | 2 +- src/registerServiceWorker.js | 4 +- 8 files changed, 26 insertions(+), 70 deletions(-) diff --git a/.eslintrc b/.eslintrc index 84103e15..4d3db727 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,7 @@ { + "extends": [ + "@shlinkio/js-coding-standard" + ], "plugins": ["jest"], "env": { "jest/globals": true @@ -11,67 +14,15 @@ "process": true, "setImmediate": true }, - "overrides": [ - { - "files": ["**/*.js"], - "extends": [ - "adidas-env/browser", - "adidas-env/module", - "adidas-env/node", - "adidas-es9", - "adidas-babel", - "adidas-react" - ], - "settings": { - "react": { - "version": "detect" - } - }, - "rules": { - "max-len": ["error", { - "code": 120, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true - }], - "no-mixed-operators": "off", - "comma-dangle": ["error", "always-multiline"], - "no-invalid-this": "off", - "no-inline-comments": "off", - "no-console": "warn", - "template-curly-spacing": ["error", "never"], - "no-warning-comments": "off", - "no-undefined": "off", - "indent": ["error", 2, {"SwitchCase": 1}], - "no-empty-function": "off", - "lines-around-comment": "off", - "no-magic-numbers": "off", - "react/no-array-index-key": "off", - "react/no-did-update-set-state": "off", - "react/display-name": "off", - "react/jsx-curly-spacing": ["error", "never"], - "react/jsx-indent-props": ["error", 2], - "react/jsx-first-prop-new-line": ["error", "multiline-multiprop"], - "react/jsx-closing-bracket-location": ["error", "tag-aligned"], - "react/jsx-filename-extension": ["error", {"extensions": [".js", ".jsx"]}] - } - }, - { - "files": ["**/*.ts", "**/*.tsx"], - "extends": [ - "@shlinkio/js-coding-standard" - ], - "rules": { - "max-len": ["error", { - "code": 120, - "ignoreStrings": true, - "ignoreTemplateLiterals": true, - "ignoreComments": true - }], - "no-mixed-operators": "off", - "react/display-name": "off", - "@typescript-eslint/require-array-sort-compare": "off" - } - } - ] + "rules": { + "max-len": ["error", { + "code": 120, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreComments": true + }], + "no-mixed-operators": "off", + "react/display-name": "off", + "@typescript-eslint/require-array-sort-compare": "off" + } } diff --git a/config/env.js b/config/env.js index b57375d1..c4ca2b01 100644 --- a/config/env.js +++ b/config/env.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */ const fs = require('fs'); const path = require('path'); diff --git a/config/paths.js b/config/paths.js index b34d9058..0728ca85 100644 --- a/config/paths.js +++ b/config/paths.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */ const path = require('path'); const fs = require('fs'); diff --git a/config/webpack.config.js b/config/webpack.config.js index 5134e5a2..a182eced 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -227,7 +227,7 @@ module.exports = (webpackEnv) => { // Turned on because emoji and regex is not minified properly using default // https://github.com/facebook/create-react-app/issues/2488 - ascii_only: true, + ascii_only: true, // eslint-disable-line @typescript-eslint/camelcase }, }, @@ -668,7 +668,7 @@ module.exports = (webpackEnv) => { fs: 'empty', net: 'empty', tls: 'empty', - child_process: 'empty', + child_process: 'empty', // eslint-disable-line @typescript-eslint/camelcase }, // Turn off performance processing because we utilize diff --git a/config/webpackDevServer.config.js b/config/webpackDevServer.config.js index 6dc74982..61ca020b 100644 --- a/config/webpackDevServer.config.js +++ b/config/webpackDevServer.config.js @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ const fs = require('fs'); const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware'); diff --git a/scripts/build.js b/scripts/build.js index b8854055..4ac2a6f9 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */ // Do this as the first thing so that any code reading it knows the right env. process.env.BABEL_ENV = 'production'; @@ -43,8 +43,8 @@ if (!checkRequiredFiles([ paths.appHtml, paths.appIndexJs ])) { // Process CLI arguments const argvSliceStart = 2; const argv = process.argv.slice(argvSliceStart); -const writeStatsJson = argv.indexOf('--stats') !== -1; -const withoutDist = argv.indexOf('--no-dist') !== -1; +const writeStatsJson = argv.includes('--stats'); +const withoutDist = argv.includes('--no-dist'); const { version, hasVersion } = getVersionFromArgs(argv); // Generate configuration diff --git a/scripts/start.js b/scripts/start.js index 68a4a08c..f1d2ba11 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -1,4 +1,4 @@ -/* eslint-disable no-console */ +/* eslint-disable no-console, @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/promise-function-async, @typescript-eslint/prefer-optional-chain */ // Do this as the first thing so that any code reading it knows the right env. process.env.BABEL_ENV = 'development'; diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index 023439b2..f12df500 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/promise-function-async, @typescript-eslint/no-misused-promises */ + // In production, we register a service worker to serve assets from local cache. // This lets the app load faster on subsequent visits in production, and gives @@ -96,7 +98,7 @@ function checkValidServiceWorker(swUrl) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === NOT_FOUND_STATUS || - response.headers.get('content-type').indexOf('javascript') === -1 + response.headers.get('content-type').includes('javascript') ) { // No service worker found. Probably a different app. Reload the page. return navigator.serviceWorker.ready.then((registration) =>