From 9ca96b237184aee7ed1791c8f80abf06f3b11812 Mon Sep 17 00:00:00 2001 From: Dean Pogni Date: Sun, 16 Dec 2018 19:58:23 -0800 Subject: [PATCH 1/2] Move eslint config to .eslintrc.js file --- ui.apps/src/main/webpack.core/.eslintrc.js | 39 +++++++++++++++++++ .../webpack.core/internals/eslint.config.js | 26 ++----------- ui.apps/src/main/webpack.project/index.js | 15 +------ 3 files changed, 43 insertions(+), 37 deletions(-) create mode 100644 ui.apps/src/main/webpack.core/.eslintrc.js diff --git a/ui.apps/src/main/webpack.core/.eslintrc.js b/ui.apps/src/main/webpack.core/.eslintrc.js new file mode 100644 index 0000000..fdd6d38 --- /dev/null +++ b/ui.apps/src/main/webpack.core/.eslintrc.js @@ -0,0 +1,39 @@ +const CONFIG_WEBPACK = require('./internals/webpack.config.js'); + +module.exports = { + env: { + browser: true, + es6: true, + node: true, + }, + // Optional: Replace `eslint:recommended` with `eslint-config-infield` and run + // `npm install --save-dev eslint-config-infield` for stricter linting rules + extends: "eslint:recommended", + parserOptions: { + ecmaVersion: 8, + sourceType: 'module', + }, + settings: { + // This prevents `no-unused-vars` and `import/no-unresolved` from being thrown + // when modules are imported that are defined in Webpack but not correctly + // resolved by `eslint-plugin-import`. Note that `eslint-plugin-import` can + // be defined directly in this project's package.json but it can also be an + // dependency of an extended ESLint configuration. + 'import/resolver': { + node: { + paths: (CONFIG_WEBPACK.resolve && CONFIG_WEBPACK.resolve.modules) || [], + }, + }, + }, + + // If you want to define variables that are available across various processed JavaScript + // files, define them here. More details: http://eslint.org/docs/user-guide/configuring#specifying-globals + globals: { + $: true, + Granite: true, + }, + + rules: { + "no-console" : 1, // 0 = off, 1 = warn, 2 = error + } +} diff --git a/ui.apps/src/main/webpack.core/internals/eslint.config.js b/ui.apps/src/main/webpack.core/internals/eslint.config.js index edbe27a..10f9669 100644 --- a/ui.apps/src/main/webpack.core/internals/eslint.config.js +++ b/ui.apps/src/main/webpack.core/internals/eslint.config.js @@ -1,29 +1,9 @@ const merge = require('merge'); -const CONFIG = require('./../../webpack.project'); -const CONFIG_WEBPACK = require('./webpack.config.js'); +const CONFIG = require('../../webpack.project'); +const path = require('path'); const ESLINT_DEFAULT = { - env: { - browser: true, - es6: true, - node: true, - }, - parserOptions: { - ecmaVersion: 8, - sourceType: 'module', - }, - settings: { - // This prevents `no-unused-vars` and `import/no-unresolved` from being thrown - // when modules are imported that are defined in Webpack but not correctly - // resolved by `eslint-plugin-import`. Note that `eslint-plugin-import` can - // be defined directly in this project's package.json but it can also be an - // dependency of an extended ESLint configuration. - 'import/resolver': { - node: { - paths: (CONFIG_WEBPACK.resolve && CONFIG_WEBPACK.resolve.modules) || [], - }, - }, - }, + extends: path.resolve(__dirname, '../.eslintrc.js'), }; module.exports = merge.recursive(true, ESLINT_DEFAULT, CONFIG.eslint); diff --git a/ui.apps/src/main/webpack.project/index.js b/ui.apps/src/main/webpack.project/index.js index 9c065e6..43d15eb 100644 --- a/ui.apps/src/main/webpack.project/index.js +++ b/ui.apps/src/main/webpack.project/index.js @@ -45,20 +45,7 @@ const WEBPACK = { * as strict as possible. */ const ESLINT = { - // Optional: Replace `eslint:recommended` with `eslint-config-infield` and run - // `npm install --save-dev eslint-config-infield` for stricter linting rules - extends: "eslint:recommended", - - // If you want to define variables that are available across various processed JavaScript - // files, define them here. More details: http://eslint.org/docs/user-guide/configuring#specifying-globals - globals: { - $: true, - Granite: true, - }, - - rules: { - "no-console": "off", - }, + // You can override or extend the default ESLINT configuration here }; /** From 2200f62f3ff116bd767080df70c2ed5a24d8d708 Mon Sep 17 00:00:00 2001 From: Dean Pogni Date: Sun, 16 Dec 2018 22:23:26 -0800 Subject: [PATCH 2/2] cleanup --- ui.apps/src/main/webpack.core/.eslintrc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui.apps/src/main/webpack.core/.eslintrc.js b/ui.apps/src/main/webpack.core/.eslintrc.js index fdd6d38..39ad767 100644 --- a/ui.apps/src/main/webpack.core/.eslintrc.js +++ b/ui.apps/src/main/webpack.core/.eslintrc.js @@ -1,14 +1,14 @@ const CONFIG_WEBPACK = require('./internals/webpack.config.js'); module.exports = { + // Optional: Replace `eslint:recommended` with `eslint-config-infield` and run + // `npm install --save-dev eslint-config-infield` for stricter linting rules + extends: "eslint:recommended", env: { browser: true, es6: true, node: true, }, - // Optional: Replace `eslint:recommended` with `eslint-config-infield` and run - // `npm install --save-dev eslint-config-infield` for stricter linting rules - extends: "eslint:recommended", parserOptions: { ecmaVersion: 8, sourceType: 'module',