Match-id-ddc04393535a21d690fbfe2f977d3107d3c8ed23

This commit is contained in:
* 2022-03-19 13:50:48 +08:00 committed by *
parent 337b729402
commit e371508043
3 changed files with 23 additions and 270 deletions

View File

@ -1,12 +1,8 @@
const restrictedGlobals = require('confusing-browser-globals');
const OFF = 0;
const ERROR = 2;
module.exports = {
extends: ['fbjs', 'prettier'],
// Stop ESLint from looking for a configuration file in parent folders
extends: [
'eslint:recommended',
'prettier',
],
root: true,
plugins: [
@ -14,173 +10,36 @@ module.exports = {
'no-for-of-loops',
'no-function-declare-after-return',
'react',
'@typescript-eslint',
],
parser: 'babel-eslint',
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
modules: true,
experimentalObjectRestSpread: true,
},
},
env: {
'mocha': true,
'node': true,
browser: true,
jest: true,
node: true,
es6: true,
},
// We're stricter than the default config, mostly. We'll override a few rules
// and then enable some React specific ones.
rules: {
'accessor-pairs': OFF,
'brace-style': [ERROR, '1tbs'],
'consistent-return': OFF,
'dot-location': [ERROR, 'property'],
// We use console['error']() as a signal to not transform it:
'dot-notation': [ERROR, {allowPattern: '^(error|warn)$'}],
'eol-last': ERROR,
eqeqeq: [ERROR, 'allow-null'],
indent: OFF,
'jsx-quotes': [ERROR, 'prefer-double'],
'keyword-spacing': [ERROR, {after: true, before: true}],
'no-bitwise': OFF,
'no-inner-declarations': [ERROR, 'functions'],
'no-multi-spaces': ERROR,
'no-restricted-globals': [ERROR].concat(restrictedGlobals),
'no-restricted-syntax': [ERROR, 'WithStatement'],
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-use-before-define': OFF,
'no-useless-concat': OFF,
quotes: [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true}],
'space-before-blocks': ERROR,
'space-before-function-paren': OFF,
'valid-typeof': [ERROR, {requireStringLiterals: true}],
'accessor-pairs': 'off',
'brace-style': ['error', '1tbs'],
'func-style': ['warn', 'declaration', { allowArrowFunctions: true }],
'max-lines-per-function': 'off',
'object-curly-newline': 'off',
// 尾随逗号
'comma-dangle': ['error', 'only-multiline'],
// We apply these settings to files that should run on Node.
// They can't use JSX or ES6 modules, and must be in strict mode.
// They can, however, use other ES6 features.
// (Note these rules are overridden later for source files.)
'no-var': ERROR,
strict: ERROR,
// Enforced by Prettier
// TODO: Prettier doesn't handle long strings or long comments. Not a big
// deal. But I turned it off because loading the plugin causes some obscure
// syntax error and it didn't seem worth investigating.
'max-len': OFF,
// React & JSX
// Our transforms set this automatically
'react/jsx-boolean-value': [ERROR, 'always'],
'react/jsx-no-undef': ERROR,
// We don't care to do this
'react/jsx-sort-prop-types': OFF,
'react/jsx-space-before-closing': ERROR,
'react/jsx-uses-react': ERROR,
'react/no-is-mounted': OFF,
// This isn't useful in our test code
'react/react-in-jsx-scope': ERROR,
'react/self-closing-comp': ERROR,
// We don't care to do this
'react/jsx-wrap-multilines': [
ERROR,
{declaration: false, assignment: false},
],
// Prevent for...of loops because they require a Symbol polyfill.
// You can disable this rule for code that isn't shipped (e.g. build scripts and tests).
'no-for-of-loops/no-for-of-loops': ERROR,
// Prevent function declarations after return statements
'no-function-declare-after-return/no-function-declare-after-return': ERROR,
},
overrides: [
{
// We apply these settings to the source files that get compiled.
// They can use all features including JSX (but shouldn't use `var`).
files: [
// Internal forwarding modules
'libs/*/*.js',
// Source files
'libs/*/src/**/*.js',
],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
},
rules: {
'no-var': ERROR,
'prefer-const': ERROR,
strict: OFF,
},
},
{
files: ['**/__tests__/*.js'],
rules: {
// https://github.com/jest-community/eslint-plugin-jest
'jest/no-focused-tests': ERROR,
'jest/valid-expect': ERROR,
'jest/valid-expect-in-promise': ERROR,
},
},
{
files: [
'**/__tests__/**/*.js',
'scripts/**/*.js',
'libs/*/npm/**/*.js',
'libs/dom-event-testing-library/**/*.js',
'libs/react-devtools*/**/*.js',
],
rules: {
'react-internal/no-production-logging': OFF,
'react-internal/warning-args': OFF,
},
},
{
files: ['libs/react-native-renderer/**/*.js'],
globals: {
nativeFabricUIManager: true,
},
},
{
files: ['libs/react-transport-dom-webpack/**/*.js'],
globals: {
__webpack_chunk_load__: true,
__webpack_require__: true,
},
},
{
files: ['libs/scheduler/**/*.js'],
globals: {
TaskController: true,
},
},
{
files: [
'scripts/e2e-test/**/*.js',
'scripts/e2e-test/**/*.jsx',
],
parserOptions: {
sourceType: 'module',
},
}
],
globals: {
SharedArrayBuffer: true,
spyOnDev: true,
spyOnDevAndProd: true,
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
__EXPERIMENTAL__: true,
__VARIANT__: true,
gate: true,
trustedTypes: true,
'no-for-of-loops/no-for-of-loops': 'error',
'no-function-declare-after-return/no-function-declare-after-return': 'error',
},
};

View File

@ -51,6 +51,8 @@
"@mattiasbuelens/web-streams-polyfill": "^0.3.2",
"@types/jest": "^26.0.24",
"@types/node": "^17.0.18",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.3",
"babel-jest": "^27.5.1",
@ -66,7 +68,6 @@
"ejs": "^3.1.6",
"error-stack-parser": "^2.0.6",
"eslint": "^7.32.0",
"eslint-config-fbjs": "^1.1.1",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-flowtype": "^2.25.0",
@ -87,7 +88,6 @@
"react-lifecycles-compat": "^3.0.4",
"regenerator-runtime": "^0.13.9",
"rimraf": "^3.0.0",
"tslint": "^6.0.0",
"typescript": "^3.9.7",
"webpack": "^4.46.0",
"webpack-cli": "^4.7.2"

View File

@ -1,106 +0,0 @@
{
"rules": {
"deprecation": true,
"use-isnan": true,
"max-line-length": [
true,
{
"limit": 120,
"ignore-pattern": "^import |^export {(.*?)}",
"check-strings": false,
"check-regex": true
}
],
"member-ordering": [true, { "order": "fields-first" }],
"no-unnecessary-type-assertion": true,
"no-parameter-reassignment": true,
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"no-for-in-array": true,
"no-arg": true,
"no-any": [true, { "ignore-rest-args": true }],
"no-shadowed-variable": [
true,
{
"class": true,
"enum": true,
"function": true,
"interface": false,
"namespace": true,
"typeAlias": false,
"typeParameter": false,
"underscore": false
}
],
"no-sparse-arrays": true,
"no-string-literal": true,
"no-for-in": true,
"no-invalid-this": true,
"no-switch-case-fall-through": true,
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
"no-non-null-assertion": true,
"no-this-assignment": [
true,
{ "allowed-names": ["^self$"], "allow-destructuring": true }
],
"no-var-keyword": true,
"no-require-imports": true,
"prefer-for-of": true,
"prefer-conditional-expression": [true, "check-else-if"],
"prefer-object-spread": true,
"typeof-compare": true,
"cyclomatic-complexity": [true, 20],
"prefer-readonly": true,
"prefer-const": true,
"radix": true,
"space-before-function-paren": [
true,
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always",
"method": "never",
"constructor": "never"
}
],
"space-within-parens": 1,
"type-literal-delimiter": true,
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"require-const-for-all-caps",
"allow-pascal-case"
]
},
"curly": true,
"class-name": true,
"one-line": [true, "check-catch", "check-finally", "check-else"],
"arrow-parens": [true, "ban-single-arg-parens"],
"indent": [true, "spaces", 4],
"one-variable-per-declaration": true,
"ban-comma-operator": true,
"function-constructor": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],
"jsdoc-format": [true, "check-multiline-start"],
"no-irregular-whitespace": true,
"no-trailing-whitespace": [
true,
"ignore-comments",
"ignore-jsdoc",
"ignore-template-strings",
"ignore-blank-lines"
],
"triple-equals": true,
"prefer-template": [true, "allow-single-concat"],
"quotemark": [
true,
"single",
"jsx-double",
"avoid-template",
"avoid-escape"
]
},
"defaultSeverity": "warning"
}