From 9a43e439b3c9613e3f4b51e74c056e3f1c096ec4 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Wed, 22 Apr 2020 01:21:56 +1000 Subject: [PATCH] chore: Use override instead of env to control eslint on markdown (#23454) --- .eslintrc.js | 68 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3147b2293e..817a77fb8a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,8 @@ -const eslintrc = { +const commonGlobals = { + gtag: true, +}; + +module.exports = { extends: [ 'airbnb', 'prettier', @@ -31,6 +35,30 @@ const eslintrc = { '@typescript-eslint/no-unused-expressions': 2, }, }, + { + files: ['*.md'], + globals: { + ...commonGlobals, + React: true, + ReactDOM: true, + mountNode: true, + }, + rules: { + indent: 0, + 'no-console': 0, + 'no-plusplus': 0, + 'eol-last': 0, + 'no-script-url': 0, + 'prefer-rest-params': 0, + 'react/no-access-state-in-setstate': 0, + 'react/destructuring-assignment': 0, + 'react/no-multi-comp': 0, + 'jsx-a11y/href-no-hash': 0, + 'import/no-extraneous-dependencies': 0, + 'import/no-unresolved': 0, + 'jsx-a11y/control-has-associated-label': 0, + }, + }, ], rules: { camelcase: 0, @@ -91,38 +119,10 @@ const eslintrc = { 'jest/no-test-callback': 0, 'jest/expect-expect': 0, 'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks - "unicorn/better-regex": 2, - "unicorn/prefer-trim-start-end": 2, - "unicorn/expiring-todo-comments": 2, - "unicorn/no-abusive-eslint-disable": 2, - }, - globals: { - gtag: true, + 'unicorn/better-regex': 2, + 'unicorn/prefer-trim-start-end': 2, + 'unicorn/expiring-todo-comments': 2, + 'unicorn/no-abusive-eslint-disable': 2, }, + globals: commonGlobals, }; - -if (process.env.RUN_ENV === 'DEMO') { - eslintrc.globals = Object.assign(eslintrc.globals, { - React: true, - ReactDOM: true, - mountNode: true, - }); - - Object.assign(eslintrc.rules, { - indent: 0, - 'no-console': 0, - 'no-plusplus': 0, - 'eol-last': 0, - 'no-script-url': 0, - 'prefer-rest-params': 0, - 'react/no-access-state-in-setstate': 0, - 'react/destructuring-assignment': 0, - 'react/no-multi-comp': 0, - 'jsx-a11y/href-no-hash': 0, - 'import/no-extraneous-dependencies': 0, - 'import/no-unresolved': 0, - 'jsx-a11y/control-has-associated-label': 0, - }); -} - -module.exports = eslintrc; diff --git a/package.json b/package.json index dd796c8748..7d7ec2b703 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "lint-fix:demo": "eslint-tinker ./components/*/demo/*.md", "lint-fix:script": "npm run lint:script -- --fix", "lint-fix:style": "npm run lint:style -- --fix", - "lint:demo": "cross-env RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md'", + "lint:demo": "eslint components/*/demo/*.md", "lint:deps": "antd-tools run deps-lint", "lint:md": "remark components/", "lint:script": "eslint . --ext '.js,.jsx,.ts,.tsx'",