Browse Source

chore: Use override instead of env to control eslint on markdown (#23454)

pull/22956/head
Eric Wang 5 years ago
committed by GitHub
parent
commit
9a43e439b3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      .eslintrc.js
  2. 2
      package.json

68
.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;

2
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'",

Loading…
Cancel
Save