From 8e9b627e8de8afc924c33e87435917d58f7121b0 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 28 Aug 2023 22:23:47 +0800 Subject: [PATCH 01/43] Update .eslintrc.yaml A better eslint rules config (maybe). --- .eslintrc.yaml | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 397a8ee08d4..cd6be15a224 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -50,7 +50,6 @@ rules: camelcase: off # underscores may come in handy in some cases eqeqeq: warn # important check missing from recommended keyword-spacing: warn # we require this explicitly - no-multi-spaces: off # useful for manually align some expression across lines prefer-rest-params: off # we need ES5 to be fast too prefer-spread: off # we need ES5 to be fast too space-before-function-paren: [warn, always] # we require this explicitly @@ -82,8 +81,7 @@ rules: lines-between-class-members: off # be more lenient on member declarations max-classes-per-file: off # helper classes are common - max-len: [warn, 150] # more lenient on max length per line - no-console: error # prefer the uniform logging methods + no-plusplus: off # allow increment/decrement operators no-continue: off # allow unlabeled continues no-mixed-operators: off # this is just cumbersome @@ -112,7 +110,6 @@ rules: 'ts-nocheck': true, 'ts-check': false, }] - '@typescript-eslint/no-unused-expressions': warn # TODO: this is just too much work '@typescript-eslint/explicit-module-boundary-types': off @@ -128,15 +125,6 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - '@typescript-eslint/no-empty-function': [error, { - allow: [ - private-constructors, - protected-constructors, - decoratedFunctions, - overrideMethods, - ] - }] - '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties @@ -163,3 +151,34 @@ rules: '@typescript-eslint/explicit-function-return-type': [error, { allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful }] + + max-len: [warn, 250] # more lenient on max length per line + no-console: warn # prefer the uniform logging methods + '@typescript-eslint/no-unused-expressions': off + '@typescript-eslint/no-empty-function': off + no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] + + comma-dangle: ['error', { + "arrays": "only-multiline", + "objects": "only-multiline", + "imports": "never", + "exports": "never", + "functions": "never" + }] + function-paren-newline: off + space-infix-ops: warn + key-spacing: [warn, { + 'singleLine':{ + 'beforeColon': false, + 'afterColon': true + }, + 'multiLine' :{ + 'beforeColon': true, + 'afterColon': true, + 'align': 'colon' + } + }] + no-multiple-empty-lines: [warn, {'max': 2, 'maxEOF': 1}] + '@typescript-eslint/no-unsafe-argument': off + '@typescript-eslint/no-unsafe-enum-comparison': off + '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] From 8f0074808130d1f7e0bedd5c5dfe5d709021d9e3 Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 13:21:42 +0800 Subject: [PATCH 02/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化规则 --- .eslintrc.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index cd6be15a224..c43dc310893 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -180,5 +180,4 @@ rules: }] no-multiple-empty-lines: [warn, {'max': 2, 'maxEOF': 1}] '@typescript-eslint/no-unsafe-argument': off - '@typescript-eslint/no-unsafe-enum-comparison': off '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] From 19062a9bf7d14029b324173a5ebf8ceee64a8c9c Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 13:28:12 +0800 Subject: [PATCH 03/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化规则 --- .eslintrc.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index c43dc310893..3a2bd91cdeb 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -159,11 +159,11 @@ rules: no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] comma-dangle: ['error', { - "arrays": "only-multiline", - "objects": "only-multiline", - "imports": "never", - "exports": "never", - "functions": "never" + 'arrays': 'only-multiline', + 'objects': 'only-multiline', + 'imports': 'never', + 'exports': 'never', + 'functions': 'never' }] function-paren-newline: off space-infix-ops: warn @@ -173,7 +173,7 @@ rules: 'afterColon': true }, 'multiLine' :{ - 'beforeColon': true, + 'beforeColon': false, 'afterColon': true, 'align': 'colon' } From bb4f9a746fe23f671f75f69f3c2e5a43be29e9f7 Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 13:40:05 +0800 Subject: [PATCH 04/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化规则 --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 3a2bd91cdeb..0e9aa369ad6 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -165,6 +165,7 @@ rules: 'exports': 'never', 'functions': 'never' }] + quote-props: ['error', 'consistent-as-needed'] function-paren-newline: off space-infix-ops: warn key-spacing: [warn, { From f3ace4673c7889623de8953f0f88c0a8370159ca Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 20:28:43 +0800 Subject: [PATCH 05/43] Update .eslintrc.yaml --- .eslintrc.yaml | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0e9aa369ad6..021a3be9261 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -11,7 +11,7 @@ extends: - plugin:@typescript-eslint/recommended - plugin:@typescript-eslint/recommended-requiring-type-checking -plugins: ["@typescript-eslint"] +plugins: ['@typescript-eslint'] settings: import/resolver: @@ -48,7 +48,7 @@ rules: ##### RECOMMENDED RULE OVERRIDES ##### camelcase: off # underscores may come in handy in some cases - eqeqeq: warn # important check missing from recommended + keyword-spacing: warn # we require this explicitly prefer-rest-params: off # we need ES5 to be fast too prefer-spread: off # we need ES5 to be fast too @@ -73,9 +73,9 @@ rules: indent: [error, 4, { SwitchCase: 0, ignoredNodes: [ # https://stackoverflow.com/a/72897089 - "FunctionExpression > .params[decorators.length > 0]", - "FunctionExpression > .params > :matches(Decorator, :not(:first-child))", - "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key", + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', ] }] @@ -136,8 +136,6 @@ rules: allowBoolean: true }] - '@typescript-eslint/type-annotation-spacing': warn - # We choose to use style `... as foo` since it's more common. # In the other hand, angle bracket style can be ambiguous with j/tsx syntax. # For example, https://babeljs.io/docs/en/babel-plugin-transform-typescript#istsx @@ -152,22 +150,37 @@ rules: allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful }] + + # constructor-super: error + # curly: [ error, all ] + # no-debugger: error + # no-duplicate-case: error + # no-eval: error + # no-sparse-arrays: error + # no-trailing-spaces: error + # no-var: error + # prefer-const: error + # prefer-numeric-literals: off + # prefer-template: error + + + # '@typescript-eslint/no-unsafe-argument': off + max-len: [warn, 250] # more lenient on max length per line no-console: warn # prefer the uniform logging methods - '@typescript-eslint/no-unused-expressions': off '@typescript-eslint/no-empty-function': off no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] comma-dangle: ['error', { - 'arrays': 'only-multiline', - 'objects': 'only-multiline', + 'arrays': 'never', + 'objects': 'always-multiline', 'imports': 'never', 'exports': 'never', 'functions': 'never' }] quote-props: ['error', 'consistent-as-needed'] function-paren-newline: off - space-infix-ops: warn + space-unary-ops: error key-spacing: [warn, { 'singleLine':{ 'beforeColon': false, @@ -179,6 +192,17 @@ rules: 'align': 'colon' } }] - no-multiple-empty-lines: [warn, {'max': 2, 'maxEOF': 1}] - '@typescript-eslint/no-unsafe-argument': off + one-var: [error, never] + eqeqeq: ['error', 'smart'] + no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] + arrow-body-style: [off, as-needed] + arrow-parens: [ error, as-needed ] + brace-style: [ error, 1tbs ] + id-denylist: [ error, any, unknown, Number, number, String, string, Boolean, boolean, Undefined, undefined ] + id-match: off + no-cond-assign: off + no-constant-condition: off + # padded-blocks: ['error', { 'classes': 'always' }] + "@typescript-eslint/space-infix-ops": ["error"] + '@typescript-eslint/type-annotation-spacing': [error, { "before": false, "after": true }] From 82990e745d8cd075f820c5f35f6e97f38d146db2 Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 30 Aug 2023 20:39:10 +0800 Subject: [PATCH 06/43] Update .eslintrc.yaml --- .eslintrc.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 021a3be9261..b7e747b1d78 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -196,7 +196,7 @@ rules: eqeqeq: ['error', 'smart'] no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] - arrow-body-style: [off, as-needed] + arrow-body-style: [error, as-needed] arrow-parens: [ error, as-needed ] brace-style: [ error, 1tbs ] id-denylist: [ error, any, unknown, Number, number, String, string, Boolean, boolean, Undefined, undefined ] @@ -205,4 +205,13 @@ rules: no-constant-condition: off # padded-blocks: ['error', { 'classes': 'always' }] "@typescript-eslint/space-infix-ops": ["error"] - '@typescript-eslint/type-annotation-spacing': [error, { "before": false, "after": true }] + '@typescript-eslint/type-annotation-spacing': [error, { + before: false, + after: true, + overrides : { + arrow: { + before: true, + after: true, + } + } + }] From 733ffbeeacc3d6e3df3b52b0fd43b1b433cb51f0 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 13:28:51 +0800 Subject: [PATCH 07/43] Update .eslintrc.yaml --- .eslintrc.yaml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b7e747b1d78..552f049681d 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -171,14 +171,22 @@ rules: '@typescript-eslint/no-empty-function': off no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] - comma-dangle: ['error', { + comma-dangle: [error, { 'arrays': 'never', 'objects': 'always-multiline', 'imports': 'never', 'exports': 'never', 'functions': 'never' }] - quote-props: ['error', 'consistent-as-needed'] + quote-props: [error, 'consistent-as-needed'] + no-extra-parens: [error, 'all', { + conditionalAssign: false, + returnAssign: false, + nestedBinaryExpressions: false, + enforceForArrowConditionals: false, + enforceForFunctionPrototypeMethods: false, + ignoreJSX: 'all' + }] function-paren-newline: off space-unary-ops: error key-spacing: [warn, { @@ -193,9 +201,8 @@ rules: } }] one-var: [error, never] - eqeqeq: ['error', 'smart'] + eqeqeq: [error, smart] no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] - '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] arrow-body-style: [error, as-needed] arrow-parens: [ error, as-needed ] brace-style: [ error, 1tbs ] @@ -203,8 +210,10 @@ rules: id-match: off no-cond-assign: off no-constant-condition: off - # padded-blocks: ['error', { 'classes': 'always' }] - "@typescript-eslint/space-infix-ops": ["error"] + nonblock-statement-body-position: [error, below] + # padded-blocks: [error, { 'classes': 'always' }] + '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] + "@typescript-eslint/space-infix-ops": [error] '@typescript-eslint/type-annotation-spacing': [error, { before: false, after: true, From 98ccad55e6be5b4b3889ac48039d3dbfe75aefdd Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 13:57:48 +0800 Subject: [PATCH 08/43] Update .eslintrc.yaml --- .eslintrc.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 552f049681d..8409591f588 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -124,7 +124,14 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - + '@typescript-eslint/no-empty-function': [error, { + allow: [ + private-constructors, + protected-constructors, + decoratedFunctions, + overrideMethods, + ] + }] '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties @@ -168,7 +175,6 @@ rules: max-len: [warn, 250] # more lenient on max length per line no-console: warn # prefer the uniform logging methods - '@typescript-eslint/no-empty-function': off no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] comma-dangle: [error, { @@ -212,9 +218,16 @@ rules: no-constant-condition: off nonblock-statement-body-position: [error, below] # padded-blocks: [error, { 'classes': 'always' }] + '@typescript-eslint/no-unused-expressions': [error, + { + "allowShortCircuit": true, + "allowTernary": true, + "allowTaggedTemplates": false + } + ] '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] "@typescript-eslint/space-infix-ops": [error] - '@typescript-eslint/type-annotation-spacing': [error, { + '@typescript-eslint/type-annotation-spacing': [warn, { before: false, after: true, overrides : { From 8588453a6567c92e42e87a5915221d9466494217 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 13:59:59 +0800 Subject: [PATCH 09/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 8409591f588..c18dfb675c5 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -124,6 +124,7 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages + '@typescript-eslint/no-empty-function': [error, { allow: [ private-constructors, @@ -132,6 +133,7 @@ rules: overrideMethods, ] }] + '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties From 8c9d6c2f894ad0bbf54b34b882a9c0587fed1026 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 14:02:59 +0800 Subject: [PATCH 10/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index c18dfb675c5..dad0629a91a 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -180,7 +180,7 @@ rules: no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] comma-dangle: [error, { - 'arrays': 'never', + 'arrays': 'always-multiline', 'objects': 'always-multiline', 'imports': 'never', 'exports': 'never', From 4de06af63410d4e3c6118f25aeef00cdc5b78442 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 14:08:09 +0800 Subject: [PATCH 11/43] Update .eslintrc.yaml --- .eslintrc.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index dad0629a91a..395cb579531 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -173,11 +173,12 @@ rules: # prefer-template: error - # '@typescript-eslint/no-unsafe-argument': off + '@typescript-eslint/no-unsafe-argument': warn max-len: [warn, 250] # more lenient on max length per line no-console: warn # prefer the uniform logging methods no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] + no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] comma-dangle: [error, { 'arrays': 'always-multiline', @@ -197,7 +198,7 @@ rules: }] function-paren-newline: off space-unary-ops: error - key-spacing: [warn, { + key-spacing: [error, { 'singleLine':{ 'beforeColon': false, 'afterColon': true @@ -210,7 +211,6 @@ rules: }] one-var: [error, never] eqeqeq: [error, smart] - no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] arrow-body-style: [error, as-needed] arrow-parens: [ error, as-needed ] brace-style: [ error, 1tbs ] @@ -229,7 +229,7 @@ rules: ] '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] "@typescript-eslint/space-infix-ops": [error] - '@typescript-eslint/type-annotation-spacing': [warn, { + '@typescript-eslint/type-annotation-spacing': [error, { before: false, after: true, overrides : { From 95d11898d7c80c7869a7b58c174580b464d61911 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 15:05:31 +0800 Subject: [PATCH 12/43] Update .eslintrc.yaml --- .eslintrc.yaml | 75 ++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 395cb579531..dedc0ca872b 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -161,7 +161,7 @@ rules: # constructor-super: error - # curly: [ error, all ] + # curly: [error, all] # no-debugger: error # no-duplicate-case: error # no-eval: error @@ -181,61 +181,64 @@ rules: no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] comma-dangle: [error, { - 'arrays': 'always-multiline', - 'objects': 'always-multiline', - 'imports': 'never', - 'exports': 'never', - 'functions': 'never' + 'arrays': always-multiline, + 'objects': always-multiline, + 'imports': never, + 'exports': never, + 'functions': never }] - quote-props: [error, 'consistent-as-needed'] - no-extra-parens: [error, 'all', { - conditionalAssign: false, - returnAssign: false, - nestedBinaryExpressions: false, - enforceForArrowConditionals: false, - enforceForFunctionPrototypeMethods: false, - ignoreJSX: 'all' + quote-props: [error, consistent-as-needed] + no-extra-parens: [error, all, { + 'conditionalAssign': false, + 'returnAssign': false, + 'nestedBinaryExpressions': false, + 'enforceForArrowConditionals': false, + 'enforceForFunctionPrototypeMethods': false, + 'ignoreJSX': all }] function-paren-newline: off space-unary-ops: error key-spacing: [error, { - 'singleLine':{ + 'singleLine': { 'beforeColon': false, 'afterColon': true }, - 'multiLine' :{ + 'multiLine': { 'beforeColon': false, 'afterColon': true, - 'align': 'colon' + 'align': colon } }] one-var: [error, never] eqeqeq: [error, smart] arrow-body-style: [error, as-needed] - arrow-parens: [ error, as-needed ] - brace-style: [ error, 1tbs ] - id-denylist: [ error, any, unknown, Number, number, String, string, Boolean, boolean, Undefined, undefined ] + arrow-parens: [error, always] + brace-style: [error, 1tbs] + id-denylist: [error, any, unknown, Number, number, String, string, Boolean, boolean, Undefined, undefined] id-match: off no-cond-assign: off no-constant-condition: off nonblock-statement-body-position: [error, below] - # padded-blocks: [error, { 'classes': 'always' }] - '@typescript-eslint/no-unused-expressions': [error, - { - "allowShortCircuit": true, - "allowTernary": true, - "allowTaggedTemplates": false - } - ] - '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, ignoreUnions: true }] - "@typescript-eslint/space-infix-ops": [error] + # padded-blocks: [error, { + # 'classes': always + # }] + '@typescript-eslint/no-unused-expressions': [error, { + 'allowShortCircuit': true, + 'allowTernary': true, + 'allowTaggedTemplates': false + }] + '@typescript-eslint/no-duplicate-type-constituents': [error, { + 'ignoreIntersections': false, + 'ignoreUnions': true + }] + '@typescript-eslint/space-infix-ops': [error] '@typescript-eslint/type-annotation-spacing': [error, { - before: false, - after: true, - overrides : { - arrow: { - before: true, - after: true, + 'before': false, + 'after': true, + 'overrides' : { + 'arrow': { + 'before': true, + 'after': true, } } }] From 98f8db7ae565167840e51708f053281c277433b3 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 16:32:56 +0800 Subject: [PATCH 13/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index dedc0ca872b..951ddf4b348 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -214,7 +214,7 @@ rules: arrow-body-style: [error, as-needed] arrow-parens: [error, always] brace-style: [error, 1tbs] - id-denylist: [error, any, unknown, Number, number, String, string, Boolean, boolean, Undefined, undefined] + id-denylist: [error, any, unknown, Number, number, String, Boolean, boolean, Undefined, undefined] id-match: off no-cond-assign: off no-constant-condition: off From ef7eec4710079713726bc52600e8c00ea06fe14d Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 17:03:04 +0800 Subject: [PATCH 14/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 951ddf4b348..7a460623178 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -214,7 +214,7 @@ rules: arrow-body-style: [error, as-needed] arrow-parens: [error, always] brace-style: [error, 1tbs] - id-denylist: [error, any, unknown, Number, number, String, Boolean, boolean, Undefined, undefined] + id-denylist: [error, any, unknown, Number, number, Boolean, boolean, String, Undefined] id-match: off no-cond-assign: off no-constant-condition: off From 10a90ba0a922f085e3f5dce20163fa646a99a802 Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 31 Aug 2023 20:09:28 +0800 Subject: [PATCH 15/43] Update .eslintrc.yaml --- .eslintrc.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 7a460623178..207c624fb03 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -188,14 +188,6 @@ rules: 'functions': never }] quote-props: [error, consistent-as-needed] - no-extra-parens: [error, all, { - 'conditionalAssign': false, - 'returnAssign': false, - 'nestedBinaryExpressions': false, - 'enforceForArrowConditionals': false, - 'enforceForFunctionPrototypeMethods': false, - 'ignoreJSX': all - }] function-paren-newline: off space-unary-ops: error key-spacing: [error, { @@ -222,6 +214,14 @@ rules: # padded-blocks: [error, { # 'classes': always # }] + '@typescript-eslint/no-extra-parens': [error, all, { + 'conditionalAssign': false, + 'returnAssign': false, + 'nestedBinaryExpressions': false, + 'enforceForArrowConditionals': false, + 'enforceForFunctionPrototypeMethods': false, + 'ignoreJSX': all + }] '@typescript-eslint/no-unused-expressions': [error, { 'allowShortCircuit': true, 'allowTernary': true, @@ -231,6 +231,7 @@ rules: 'ignoreIntersections': false, 'ignoreUnions': true }] + '@typescript-eslint/keyword-spacing': [error] '@typescript-eslint/space-infix-ops': [error] '@typescript-eslint/type-annotation-spacing': [error, { 'before': false, From f1505bf1923a13dd0d88b2eed4929157c3846161 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 12 Sep 2023 17:34:29 +0800 Subject: [PATCH 16/43] Update .eslintrc.yaml --- .eslintrc.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 207c624fb03..b23ee21c9f4 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -85,7 +85,7 @@ rules: no-plusplus: off # allow increment/decrement operators no-continue: off # allow unlabeled continues no-mixed-operators: off # this is just cumbersome - no-multi-assign: off # it is handy sometimes + no-nested-ternary: off # it is handy sometimes no-param-reassign: off # the output object is passed as parameters all the time no-restricted-syntax: off # for-in is a efficient choice for plain objects @@ -177,8 +177,16 @@ rules: max-len: [warn, 250] # more lenient on max length per line no-console: warn # prefer the uniform logging methods - no-multi-spaces: [warn, {'ignoreEOLComments': true, 'exceptions': {'Property': true, 'VariableDeclarator': false } }] + no-multi-spaces: [warn, { + 'ignoreEOLComments': true, + 'exceptions': { + 'Property': true, + 'VariableDeclarator': false + } + }] no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] + no-multi-assign: [error, { 'ignoreNonDeclaration': true }] + max-statements-per-line: [error, { max: 1 }] comma-dangle: [error, { 'arrays': always-multiline, From c0b808d1789c525bf95d497d2f249f0ce69cc09f Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 12 Sep 2023 18:23:01 +0800 Subject: [PATCH 17/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b23ee21c9f4..4d605f2d77a 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -210,7 +210,7 @@ rules: } }] one-var: [error, never] - eqeqeq: [error, smart] + eqeqeq: [error, always, {'null': ignore}] arrow-body-style: [error, as-needed] arrow-parens: [error, always] brace-style: [error, 1tbs] From 9d8771d6760f7127c39ebf6a5f3f1296890c8af6 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 25 Sep 2023 16:21:23 +0800 Subject: [PATCH 18/43] Update .eslintrc.yaml --- .eslintrc.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 4d605f2d77a..0fcb9182253 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -219,9 +219,10 @@ rules: no-cond-assign: off no-constant-condition: off nonblock-statement-body-position: [error, below] - # padded-blocks: [error, { - # 'classes': always - # }] + func-names: off + padded-blocks: [error, { + 'classes': always + }] '@typescript-eslint/no-extra-parens': [error, all, { 'conditionalAssign': false, 'returnAssign': false, From 61499c63df72a26c3c22341c1c98c768458f41d6 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 25 Sep 2023 18:52:15 +0800 Subject: [PATCH 19/43] Update .eslintrc.yaml --- .eslintrc.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0fcb9182253..2b985b79825 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -219,10 +219,13 @@ rules: no-cond-assign: off no-constant-condition: off nonblock-statement-body-position: [error, below] + func-names: off + padded-blocks: [error, { 'classes': always }] + '@typescript-eslint/no-this-alias': [off] '@typescript-eslint/no-extra-parens': [error, all, { 'conditionalAssign': false, 'returnAssign': false, From dbf5ccd66d82684f5e8f24d81c35818533c2b0ba Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 25 Sep 2023 18:53:38 +0800 Subject: [PATCH 20/43] Update .eslintrc.yaml --- .eslintrc.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 2b985b79825..32f216ff85b 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -209,6 +209,7 @@ rules: 'align': colon } }] + func-names: off one-var: [error, never] eqeqeq: [error, always, {'null': ignore}] arrow-body-style: [error, as-needed] @@ -219,12 +220,10 @@ rules: no-cond-assign: off no-constant-condition: off nonblock-statement-body-position: [error, below] - - func-names: off - padded-blocks: [error, { 'classes': always }] + '@typescript-eslint/no-this-alias': [off] '@typescript-eslint/no-extra-parens': [error, all, { 'conditionalAssign': false, From eecf7d6f66dcee09e72e9a7fc037a2b38e79d378 Mon Sep 17 00:00:00 2001 From: finscn Date: Sat, 7 Oct 2023 22:05:01 -0500 Subject: [PATCH 21/43] Update .eslintrc.yaml --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 32f216ff85b..cc115fa558a 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -210,6 +210,7 @@ rules: } }] func-names: off + default-param-last: off one-var: [error, never] eqeqeq: [error, always, {'null': ignore}] arrow-body-style: [error, as-needed] From e5931f85892c2308058303675dec3bc864e2ec7a Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 27 Oct 2023 21:25:07 +0800 Subject: [PATCH 22/43] use `@typescript-eslint/indent` --- .eslintrc.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index cc115fa558a..de37ccd89da 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -70,14 +70,6 @@ rules: import/extensions: off # typescript doesn't support this import/no-unresolved: off # TODO: fix internal modules import/prefer-default-export: off # prefer named exports - indent: [error, 4, { - SwitchCase: 0, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', - ] - }] lines-between-class-members: off # be more lenient on member declarations max-classes-per-file: off # helper classes are common @@ -255,3 +247,11 @@ rules: } } }] + '@typescript-eslint/indent': [error, 4, { + SwitchCase: 0, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', + ] + }] From c5aafa728e8b0cbc7c08f8ad4adf66349fa5c3e0 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 27 Oct 2023 21:32:04 +0800 Subject: [PATCH 23/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'indent' 和 '@typescript-eslint/indent' 要分别定义 ,不能互相代替. --- .eslintrc.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index de37ccd89da..e901205a447 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -70,7 +70,17 @@ rules: import/extensions: off # typescript doesn't support this import/no-unresolved: off # TODO: fix internal modules import/prefer-default-export: off # prefer named exports - + indent: [error, 4, { + SwitchCase: 0 + }] + '@typescript-eslint/indent': [error, 4, { + SwitchCase: 0, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', + ] + }] lines-between-class-members: off # be more lenient on member declarations max-classes-per-file: off # helper classes are common @@ -247,11 +257,3 @@ rules: } } }] - '@typescript-eslint/indent': [error, 4, { - SwitchCase: 0, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', - ] - }] From e38fab6a6811c545be3f45f5cb22f2447115cb49 Mon Sep 17 00:00:00 2001 From: finscn Date: Sun, 29 Oct 2023 14:23:57 +0800 Subject: [PATCH 24/43] =?UTF-8?q?=E5=81=9C=E7=94=A8=20prefer-template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 字符串模板性能低, 总是强制使用未必合适. --- .eslintrc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index e901205a447..285eae29421 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -172,9 +172,8 @@ rules: # no-var: error # prefer-const: error # prefer-numeric-literals: off - # prefer-template: error - + prefer-template: off '@typescript-eslint/no-unsafe-argument': warn max-len: [warn, 250] # more lenient on max length per line @@ -211,6 +210,7 @@ rules: 'align': colon } }] + func-names: off default-param-last: off one-var: [error, never] From 236490a8e4efc9b4b1618c801cb0fce7ddeabf10 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 6 Nov 2023 15:35:18 +0800 Subject: [PATCH 25/43] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20ignoredNodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 经测试 indent.ignoredNodes 在 eslint标准规则里不能省略. --- .eslintrc.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 285eae29421..ed33e88f559 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -71,14 +71,19 @@ rules: import/no-unresolved: off # TODO: fix internal modules import/prefer-default-export: off # prefer named exports indent: [error, 4, { - SwitchCase: 0 + SwitchCase: 0, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' + ] }] '@typescript-eslint/indent': [error, 4, { SwitchCase: 0, ignoredNodes: [ # https://stackoverflow.com/a/72897089 'FunctionExpression > .params[decorators.length > 0]', 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' ] }] lines-between-class-members: off # be more lenient on member declarations @@ -206,8 +211,8 @@ rules: }, 'multiLine': { 'beforeColon': false, - 'afterColon': true, - 'align': colon + 'afterColon': true + # 'align': colon } }] From 2755afb074cedd993d500c4f09d459703f516db0 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 7 Nov 2023 03:30:32 +0800 Subject: [PATCH 26/43] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20member-delimiter-sty?= =?UTF-8?q?le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 确保 interface 中 声明成员变量后以分号结尾. --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index ed33e88f559..bdad79a9924 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -252,6 +252,7 @@ rules: }] '@typescript-eslint/keyword-spacing': [error] '@typescript-eslint/space-infix-ops': [error] + '@typescript-eslint/member-delimiter-style': [error] '@typescript-eslint/type-annotation-spacing': [error, { 'before': false, 'after': true, From 2149fd4dce32fb78823be9e73daec6ead1d130b9 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 13 Nov 2023 23:25:44 +0800 Subject: [PATCH 27/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用 ts plugin来处理 semi, 解决 eslint里 semi 的冲突问题. --- .eslintrc.yaml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index bdad79a9924..5ed0bbed6c7 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -75,17 +75,10 @@ rules: ignoredNodes: [ # https://stackoverflow.com/a/72897089 'FunctionExpression > .params[decorators.length > 0]', 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' - ] - }] - '@typescript-eslint/indent': [error, 4, { - SwitchCase: 0, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', ] }] + lines-between-class-members: off # be more lenient on member declarations max-classes-per-file: off # helper classes are common @@ -132,7 +125,7 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - '@typescript-eslint/no-empty-function': [error, { + '@typescript-eslint/no-empty-function': [off, { allow: [ private-constructors, protected-constructors, @@ -162,7 +155,7 @@ rules: # Prefer the interface style. '@typescript-eslint/consistent-type-definitions': [error, interface] - '@typescript-eslint/explicit-function-return-type': [error, { + '@typescript-eslint/explicit-function-return-type': [off, { allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful }] @@ -177,12 +170,13 @@ rules: # no-var: error # prefer-const: error # prefer-numeric-literals: off + # prefer-template: error + - prefer-template: off '@typescript-eslint/no-unsafe-argument': warn max-len: [warn, 250] # more lenient on max length per line - no-console: warn # prefer the uniform logging methods + no-console: off # prefer the uniform logging methods no-multi-spaces: [warn, { 'ignoreEOLComments': true, 'exceptions': { @@ -191,7 +185,7 @@ rules: } }] no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] - no-multi-assign: [error, { 'ignoreNonDeclaration': true }] + no-multi-assign: [off, { 'ignoreNonDeclaration': true }] max-statements-per-line: [error, { max: 1 }] comma-dangle: [error, { @@ -211,11 +205,10 @@ rules: }, 'multiLine': { 'beforeColon': false, - 'afterColon': true - # 'align': colon + 'afterColon': true, + 'align': colon } }] - func-names: off default-param-last: off one-var: [error, never] @@ -232,14 +225,22 @@ rules: 'classes': always }] + semi: off + no-extra-semi: ["error"] + "@typescript-eslint/semi": ["error", "always"] + "@typescript-eslint/member-delimiter-style": ["error", { + "multiline": { "delimiter": "semi" }, + "singleline": { "delimiter": "semi" }, + }] + '@typescript-eslint/no-this-alias': [off] '@typescript-eslint/no-extra-parens': [error, all, { - 'conditionalAssign': false, - 'returnAssign': false, - 'nestedBinaryExpressions': false, - 'enforceForArrowConditionals': false, - 'enforceForFunctionPrototypeMethods': false, - 'ignoreJSX': all + 'conditionalAssign': false, + 'returnAssign': false, + 'nestedBinaryExpressions': false, + 'enforceForArrowConditionals': false, + 'enforceForFunctionPrototypeMethods': false, + 'ignoreJSX': all }] '@typescript-eslint/no-unused-expressions': [error, { 'allowShortCircuit': true, @@ -252,7 +253,6 @@ rules: }] '@typescript-eslint/keyword-spacing': [error] '@typescript-eslint/space-infix-ops': [error] - '@typescript-eslint/member-delimiter-style': [error] '@typescript-eslint/type-annotation-spacing': [error, { 'before': false, 'after': true, From 8f679b800c5ee947dd6fbdb0d5b9eb451a76ea63 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 14 Nov 2023 00:27:39 +0800 Subject: [PATCH 28/43] Update .eslintrc.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 纠正上一个 commit 里的错误. --- .eslintrc.yaml | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 5ed0bbed6c7..248a53907e3 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -75,10 +75,17 @@ rules: ignoredNodes: [ # https://stackoverflow.com/a/72897089 'FunctionExpression > .params[decorators.length > 0]', 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' + ] + }] + '@typescript-eslint/indent': [error, 4, { + SwitchCase: 0, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' ] }] - lines-between-class-members: off # be more lenient on member declarations max-classes-per-file: off # helper classes are common @@ -125,7 +132,7 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - '@typescript-eslint/no-empty-function': [off, { + '@typescript-eslint/no-empty-function': [error, { allow: [ private-constructors, protected-constructors, @@ -155,7 +162,7 @@ rules: # Prefer the interface style. '@typescript-eslint/consistent-type-definitions': [error, interface] - '@typescript-eslint/explicit-function-return-type': [off, { + '@typescript-eslint/explicit-function-return-type': [error, { allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful }] @@ -170,13 +177,13 @@ rules: # no-var: error # prefer-const: error # prefer-numeric-literals: off - # prefer-template: error + prefer-template: off '@typescript-eslint/no-unsafe-argument': warn max-len: [warn, 250] # more lenient on max length per line - no-console: off # prefer the uniform logging methods + no-console: warn # prefer the uniform logging methods no-multi-spaces: [warn, { 'ignoreEOLComments': true, 'exceptions': { @@ -185,7 +192,7 @@ rules: } }] no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] - no-multi-assign: [off, { 'ignoreNonDeclaration': true }] + no-multi-assign: [error, { 'ignoreNonDeclaration': true }] max-statements-per-line: [error, { max: 1 }] comma-dangle: [error, { @@ -198,17 +205,17 @@ rules: quote-props: [error, consistent-as-needed] function-paren-newline: off space-unary-ops: error - key-spacing: [error, { - 'singleLine': { - 'beforeColon': false, - 'afterColon': true - }, - 'multiLine': { - 'beforeColon': false, - 'afterColon': true, - 'align': colon - } - }] + # key-spacing: [error, { + # 'singleLine': { + # 'beforeColon': false, + # 'afterColon': true + # }, + # 'multiLine': { + # 'beforeColon': false, + # 'afterColon': true, + # 'align': colon + # } + # }] func-names: off default-param-last: off one-var: [error, never] From e1989530f9faf06d554b8ac85efbec5cfede8e87 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 24 Nov 2023 19:21:25 +0800 Subject: [PATCH 29/43] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20@stylistic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 258 ++++++++++++++++++++++++------------------------- 1 file changed, 124 insertions(+), 134 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 248a53907e3..8abcfb29527 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -3,15 +3,15 @@ root: true parser: '@typescript-eslint/parser' parserOptions: - project: ./tsconfig.json + project: + - ./tsconfig.json extends: - eslint:recommended - - airbnb-base - plugin:@typescript-eslint/recommended - plugin:@typescript-eslint/recommended-requiring-type-checking -plugins: ['@typescript-eslint'] +plugins: ['@stylistic', '@stylistic/migrate', '@typescript-eslint'] settings: import/resolver: @@ -48,16 +48,13 @@ rules: ##### RECOMMENDED RULE OVERRIDES ##### camelcase: off # underscores may come in handy in some cases - - keyword-spacing: warn # we require this explicitly + eqeqeq: [error, always, {null: ignore}] # important check missing from recommended prefer-rest-params: off # we need ES5 to be fast too prefer-spread: off # we need ES5 to be fast too - space-before-function-paren: [warn, always] # we require this explicitly radix: off # we sometimes do not need to pass a second parameter # allow underscores, we still widely use pre-dangle naming in our naming convention # e.g. private properties, private functions, module scope shared variables etc. no-underscore-dangle: off - quotes: [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal no-else-return: off # else-return is a common pattern which clearly expresses the control flow no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions' no-empty-function: off # taken over by '@typescript-eslint/no-empty-function' @@ -70,29 +67,12 @@ rules: import/extensions: off # typescript doesn't support this import/no-unresolved: off # TODO: fix internal modules import/prefer-default-export: off # prefer named exports - indent: [error, 4, { - SwitchCase: 0, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' - ] - }] - '@typescript-eslint/indent': [error, 4, { - SwitchCase: 0, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' - ] - }] - lines-between-class-members: off # be more lenient on member declarations - max-classes-per-file: off # helper classes are common + max-classes-per-file: off # helper classes are common + no-console: warn # prefer the uniform logging methods no-plusplus: off # allow increment/decrement operators no-continue: off # allow unlabeled continues - no-mixed-operators: off # this is just cumbersome - + no-multi-assign: [warn, { ignoreNonDeclaration: true }] # it is handy sometimes no-nested-ternary: off # it is handy sometimes no-param-reassign: off # the output object is passed as parameters all the time no-restricted-syntax: off # for-in is a efficient choice for plain objects @@ -102,15 +82,47 @@ rules: no-bitwise: off # we use this extensively no-use-before-define: off # just too much work no-useless-constructor: off # gives false-positives for empty constructor with parameter properties - object-curly-newline: off # we want manual control over this - one-var-declaration-per-line: off # auto-fix has order issues with `one-var` prefer-destructuring: off # auto-fix is not smart enough to merge different instances - linebreak-style: off # we don't enforce this on everyone's dev environment for now - spaced-comment: off # for license declarations default-case-last: off # Place default case clause to first make it more clear that this switch statement has handled all cases + prefer-template: off + + func-names: off + default-param-last: off + one-var: [error, never] + arrow-body-style: [error, as-needed] + id-denylist: [error, any, unknown, Number, number, Boolean, boolean, String, Undefined] + id-match: off + no-cond-assign: off + no-constant-condition: off + + # constructor-super: error + # curly: [error, all] + # no-debugger: error + # no-duplicate-case: error + # no-eval: error + # no-sparse-arrays: error + # no-trailing-spaces: error + # no-var: error + # prefer-const: error + # prefer-numeric-literals: off + ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### + '@typescript-eslint/no-unused-expressions': [error, { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: false + }] + '@typescript-eslint/no-empty-function': [off, { + allow: [ + private-constructors, + protected-constructors, + decoratedFunctions, + overrideMethods, + ] + }] + '@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': true, 'ts-ignore': true, @@ -118,6 +130,12 @@ rules: 'ts-check': false, }] + '@typescript-eslint/explicit-function-return-type': [error, { + allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful + }] + '@typescript-eslint/no-unsafe-argument': warn + + # TODO: this is just too much work '@typescript-eslint/explicit-module-boundary-types': off @@ -132,15 +150,6 @@ rules: '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - '@typescript-eslint/no-empty-function': [error, { - allow: [ - private-constructors, - protected-constructors, - decoratedFunctions, - overrideMethods, - ] - }] - '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties @@ -152,6 +161,7 @@ rules: allowBoolean: true }] + # We choose to use style `... as foo` since it's more common. # In the other hand, angle bracket style can be ambiguous with j/tsx syntax. # For example, https://babeljs.io/docs/en/babel-plugin-transform-typescript#istsx @@ -162,111 +172,91 @@ rules: # Prefer the interface style. '@typescript-eslint/consistent-type-definitions': [error, interface] - '@typescript-eslint/explicit-function-return-type': [error, { - allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful - }] + '@typescript-eslint/no-this-alias': off + '@typescript-eslint/no-duplicate-type-constituents': [error, { + ignoreIntersections: false, + ignoreUnions: true + }] - # constructor-super: error - # curly: [error, all] - # no-debugger: error - # no-duplicate-case: error - # no-eval: error - # no-sparse-arrays: error - # no-trailing-spaces: error - # no-var: error - # prefer-const: error - # prefer-numeric-literals: off - - prefer-template: off - - '@typescript-eslint/no-unsafe-argument': warn - max-len: [warn, 250] # more lenient on max length per line - no-console: warn # prefer the uniform logging methods - no-multi-spaces: [warn, { - 'ignoreEOLComments': true, - 'exceptions': { - 'Property': true, - 'VariableDeclarator': false - } - }] - no-multiple-empty-lines: [warn, {max: 2, maxEOF: 1}] - no-multi-assign: [error, { 'ignoreNonDeclaration': true }] - max-statements-per-line: [error, { max: 1 }] - - comma-dangle: [error, { - 'arrays': always-multiline, - 'objects': always-multiline, - 'imports': never, - 'exports': never, - 'functions': never - }] - quote-props: [error, consistent-as-needed] - function-paren-newline: off - space-unary-ops: error - # key-spacing: [error, { - # 'singleLine': { - # 'beforeColon': false, - # 'afterColon': true + # '@stylistic/key-spacing': [error, { + # singleLine: { + # beforeColon: false, + # afterColon: true # }, - # 'multiLine': { - # 'beforeColon': false, - # 'afterColon': true, - # 'align': colon + # multiLine: { + # beforeColon: false, + # afterColon: true, + # align: colon # } # }] - func-names: off - default-param-last: off - one-var: [error, never] - eqeqeq: [error, always, {'null': ignore}] - arrow-body-style: [error, as-needed] - arrow-parens: [error, always] - brace-style: [error, 1tbs] - id-denylist: [error, any, unknown, Number, number, Boolean, boolean, String, Undefined] - id-match: off - no-cond-assign: off - no-constant-condition: off - nonblock-statement-body-position: [error, below] - padded-blocks: [error, { - 'classes': always - }] - - semi: off - no-extra-semi: ["error"] - "@typescript-eslint/semi": ["error", "always"] - "@typescript-eslint/member-delimiter-style": ["error", { - "multiline": { "delimiter": "semi" }, - "singleline": { "delimiter": "semi" }, - }] - - '@typescript-eslint/no-this-alias': [off] - '@typescript-eslint/no-extra-parens': [error, all, { - 'conditionalAssign': false, - 'returnAssign': false, - 'nestedBinaryExpressions': false, - 'enforceForArrowConditionals': false, - 'enforceForFunctionPrototypeMethods': false, - 'ignoreJSX': all - }] - '@typescript-eslint/no-unused-expressions': [error, { - 'allowShortCircuit': true, - 'allowTernary': true, - 'allowTaggedTemplates': false + '@stylistic/keyword-spacing': error # we require this explicitly + '@stylistic/no-multi-spaces': [warn, { + ignoreEOLComments: true, + exceptions: { + 'Property': true, + 'VariableDeclarator': false + } }] - '@typescript-eslint/no-duplicate-type-constituents': [error, { - 'ignoreIntersections': false, - 'ignoreUnions': true + '@stylistic/space-before-function-paren': [warn, always] # we require this explicitly + '@stylistic/quotes': [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal + '@stylistic/indent': [error, 4, { + SwitchCase: 1, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' + ] }] - '@typescript-eslint/keyword-spacing': [error] - '@typescript-eslint/space-infix-ops': [error] - '@typescript-eslint/type-annotation-spacing': [error, { - 'before': false, - 'after': true, - 'overrides' : { + '@stylistic/lines-between-class-members': off # be more lenient on member declarations + '@stylistic/max-len': [warn, 250] # more lenient on max length per line + '@stylistic/no-mixed-operators': off # this is just cumbersome + '@stylistic/object-curly-newline': off # we want manual control over this + '@stylistic/one-var-declaration-per-line': off # auto-fix has order issues with `one-var` + '@stylistic/linebreak-style': off # we don't enforce this on everyone's dev environment for now + '@stylistic/spaced-comment': off # for license declarations + '@stylistic/type-annotation-spacing': [error, { + before: false, + after: true, + overrides : { 'arrow': { 'before': true, 'after': true, } } }] + + '@stylistic/no-multiple-empty-lines': [warn, {max: 2, maxEOF: 1}] + '@stylistic/max-statements-per-line': [error, { max: 1 }] + '@stylistic/comma-dangle': [error, { + arrays: always-multiline, + objects: always-multiline, + imports: never, + exports: never, + functions: never + }] + '@stylistic/quote-props': [error, consistent-as-needed] + '@stylistic/function-paren-newline': off + '@stylistic/space-unary-ops': error + '@stylistic/arrow-parens': [error, always] + '@stylistic/brace-style': [error, 1tbs] + '@stylistic/nonblock-statement-body-position': [error, below] + '@stylistic/padded-blocks': [error, { + classes: always + }] + '@stylistic/no-extra-semi': error + '@stylistic/semi': [error, always] + '@stylistic/member-delimiter-style': [error, { + multiline: { 'delimiter': 'semi' }, + singleline: { 'delimiter': 'semi' }, + }] + '@stylistic/no-extra-parens': [error, all, { + conditionalAssign: false, + returnAssign: false, + nestedBinaryExpressions: false, + enforceForArrowConditionals: false, + enforceForFunctionPrototypeMethods: false, + ignoreJSX: all + }] + '@stylistic/space-infix-ops': [error] From 7a08d6f065b529523a0d5261cc0c970e43838d10 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 24 Nov 2023 20:20:24 +0800 Subject: [PATCH 30/43] =?UTF-8?q?=E5=85=B3=E9=97=AD=20no-prototype-builtin?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 90+%的 场景下, 打开此开关 只会带来更繁杂的代码和操作. 且 此开关并不能解决很多根本问题. 比如 obj+.... , String(obj) Number(obj) .... 所以 对于 原始object, 需要开发者自己去做处理即可. --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 8abcfb29527..0754e122731 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -95,6 +95,7 @@ rules: id-match: off no-cond-assign: off no-constant-condition: off + no-prototype-builtins: off # constructor-super: error # curly: [error, all] From fc77ff6b79ad18577533f902bae0c628312577f8 Mon Sep 17 00:00:00 2001 From: finscn Date: Sun, 26 Nov 2023 12:15:39 +0800 Subject: [PATCH 31/43] =?UTF-8?q?=E5=AE=8C=E5=96=84=20comma-dangle=20?= =?UTF-8?q?=E5=9C=A8ts=E9=87=8C=E7=9A=84=E8=AE=BE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0754e122731..b46085abe22 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -235,7 +235,10 @@ rules: objects: always-multiline, imports: never, exports: never, - functions: never + functions: never, + enums: always-multiline, + generics: never, + tuples: never, }] '@stylistic/quote-props': [error, consistent-as-needed] '@stylistic/function-paren-newline': off From 2c1a46f2a17f006b424df8666693ad3cd5c5e513 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 27 Nov 2023 15:18:24 +0800 Subject: [PATCH 32/43] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index b46085abe22..adce8394226 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -85,35 +85,43 @@ rules: prefer-destructuring: off # auto-fix is not smart enough to merge different instances default-case-last: off # Place default case clause to first make it more clear that this switch statement has handled all cases - prefer-template: off - func-names: off default-param-last: off one-var: [error, never] arrow-body-style: [error, as-needed] - id-denylist: [error, any, unknown, Number, number, Boolean, boolean, String, Undefined] + id-denylist: [error, + any, + unknown, + Number, number, + Boolean, boolean, + String, # string, + Undefined, undefined, + ] id-match: off no-cond-assign: off no-constant-condition: off no-prototype-builtins: off - # constructor-super: error - # curly: [error, all] - # no-debugger: error - # no-duplicate-case: error - # no-eval: error - # no-sparse-arrays: error - # no-trailing-spaces: error - # no-var: error - # prefer-const: error - # prefer-numeric-literals: off + constructor-super: error + curly: [error, all] + no-debugger: error + no-duplicate-case: error + no-eval: error + no-new-wrappers: error + no-sparse-arrays: error + no-trailing-spaces: error + no-var: error + prefer-const: error + prefer-numeric-literals: off + prefer-template: off + eol-last: error ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### '@typescript-eslint/no-unused-expressions': [error, { allowShortCircuit: true, allowTernary: true, - allowTaggedTemplates: false + allowTaggedTemplates: false, }] '@typescript-eslint/no-empty-function': [off, { allow: [ @@ -125,7 +133,7 @@ rules: }] '@typescript-eslint/ban-ts-comment': [error, { - 'ts-expect-error': true, + 'ts-expect-error': false, 'ts-ignore': true, 'ts-nocheck': true, 'ts-check': false, @@ -155,11 +163,11 @@ rules: '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties allowDeclarations: true, - allowDefinitionFiles: true + allowDefinitionFiles: true, }] '@typescript-eslint/restrict-template-expressions': [warn, { # concatenations of different types are common, e.g. hash calculations allowNumber: true, - allowBoolean: true + allowBoolean: true, }] @@ -168,7 +176,7 @@ rules: # For example, https://babeljs.io/docs/en/babel-plugin-transform-typescript#istsx # forbids angle bracket style if `isTSX` is enabled. '@typescript-eslint/consistent-type-assertions': [error, { - assertionStyle: 'as' + assertionStyle: 'as', }] # Prefer the interface style. @@ -177,8 +185,14 @@ rules: '@typescript-eslint/no-this-alias': off '@typescript-eslint/no-duplicate-type-constituents': [error, { ignoreIntersections: false, - ignoreUnions: true + ignoreUnions: true, + }] + '@typescript-eslint/explicit-member-accessibility': [error, { + accessibility: 'no-public', }] + '@typescript-eslint/member-ordering': off + '@typescript-eslint/naming-convention': off + '@typescript-eslint/no-unnecessary-boolean-literal-compare': off # '@stylistic/key-spacing': [error, { From 689a26074dada8b043a9efd2ac36c9b1913b6bf9 Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 27 Nov 2023 15:20:46 +0800 Subject: [PATCH 33/43] =?UTF-8?q?=E8=A1=A5=E5=85=85=20=20=20=20=20no-case-?= =?UTF-8?q?declarations:=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index adce8394226..50bd53112f6 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -115,6 +115,7 @@ rules: prefer-numeric-literals: off prefer-template: off eol-last: error + no-case-declarations: error ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### From c514ea697975f8468e2f45097194814c4e19788a Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 27 Nov 2023 18:05:44 +0800 Subject: [PATCH 34/43] Update .eslintrc.yaml --- .eslintrc.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 50bd53112f6..93f19522206 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -144,7 +144,9 @@ rules: allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful }] '@typescript-eslint/no-unsafe-argument': warn - + '@typescript-eslint/no-unsafe-return': error + '@typescript-eslint/no-var-requires': error + '@typescript-eslint/ban-types': error # TODO: this is just too much work '@typescript-eslint/explicit-module-boundary-types': off @@ -279,3 +281,4 @@ rules: ignoreJSX: all }] '@stylistic/space-infix-ops': [error] + From d4caf7584c5aa68ff3cc02583b728acfafe78d2b Mon Sep 17 00:00:00 2001 From: finscn Date: Mon, 27 Nov 2023 19:34:57 +0800 Subject: [PATCH 35/43] Update .eslintrc.yaml --- .eslintrc.yaml | 289 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 288 insertions(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 93f19522206..717ba39ce14 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -83,7 +83,7 @@ rules: no-use-before-define: off # just too much work no-useless-constructor: off # gives false-positives for empty constructor with parameter properties prefer-destructuring: off # auto-fix is not smart enough to merge different instances - default-case-last: off # Place default case clause to first make it more clear that this switch statement has handled all cases + func-names: off default-param-last: off @@ -115,8 +115,10 @@ rules: prefer-numeric-literals: off prefer-template: off eol-last: error + default-case-last: error no-case-declarations: error + ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### '@typescript-eslint/no-unused-expressions': [error, { @@ -282,3 +284,288 @@ rules: }] '@stylistic/space-infix-ops': [error] +root: true + +parser: '@typescript-eslint/parser' + +parserOptions: + project: + - ./tsconfig.json + +extends: + - eslint:recommended + - plugin:@typescript-eslint/recommended + - plugin:@typescript-eslint/recommended-requiring-type-checking + +plugins: ['@stylistic', '@stylistic/migrate', '@typescript-eslint'] + +settings: + import/resolver: + node: + extensions: + - .js + - .jsx + - .ts + - .tsx + - .d.ts + +env: + browser: true + node: true + es6: true + jest: true + +globals: + cc: false + wx: false + Editor: false + _Scene: false + _ccsg: false + +rules: + + # https://eslint.org/docs/rules/ + # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin + + # !!!!!!!!!!!!!!!!!!!!!!!!! + # BEFORE ADDING ANY RULES + # PLEASE EXPLAIN THE REASON IN THE COMMENT. + + ##### RECOMMENDED RULE OVERRIDES ##### + + camelcase: off # underscores may come in handy in some cases + eqeqeq: [error, always, {null: ignore}] # important check missing from recommended + prefer-rest-params: off # we need ES5 to be fast too + prefer-spread: off # we need ES5 to be fast too + radix: off # we sometimes do not need to pass a second parameter + # allow underscores, we still widely use pre-dangle naming in our naming convention + # e.g. private properties, private functions, module scope shared variables etc. + no-underscore-dangle: off + no-else-return: off # else-return is a common pattern which clearly expresses the control flow + no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions' + no-empty-function: off # taken over by '@typescript-eslint/no-empty-function' + + ##### AIRBNB-SPECIFIC RULE OVERRIDES ##### + + class-methods-use-this: off # so empty functions could work + guard-for-in: off # for-in is a efficient choice for plain objects + import/export: off # so export declare namespace could work + import/extensions: off # typescript doesn't support this + import/no-unresolved: off # TODO: fix internal modules + import/prefer-default-export: off # prefer named exports + + max-classes-per-file: off # helper classes are common + no-console: warn # prefer the uniform logging methods + no-plusplus: off # allow increment/decrement operators + no-continue: off # allow unlabeled continues + no-multi-assign: [warn, { ignoreNonDeclaration: true }] # it is handy sometimes + no-nested-ternary: off # it is handy sometimes + no-param-reassign: off # the output object is passed as parameters all the time + no-restricted-syntax: off # for-in is a efficient choice for plain objects + no-return-assign: off # it is handy sometimes + no-shadow: off # TODO: this throws false-positives? + no-sequences: off # it is handy sometimes + no-bitwise: off # we use this extensively + no-use-before-define: off # just too much work + no-useless-constructor: off # gives false-positives for empty constructor with parameter properties + prefer-destructuring: off # auto-fix is not smart enough to merge different instances + + + func-names: off + default-param-last: off + one-var: [error, never] + arrow-body-style: [error, as-needed] + id-denylist: [error, + any, + unknown, + Number, number, + Boolean, boolean, + String, # string, + Undefined, undefined, + ] + id-match: off + no-cond-assign: off + no-constant-condition: off + no-prototype-builtins: off + + constructor-super: error + curly: [error, all] + no-debugger: error + no-duplicate-case: error + no-eval: error + no-new-wrappers: error + no-sparse-arrays: error + no-trailing-spaces: error + no-var: error + prefer-const: error + prefer-numeric-literals: off + prefer-template: off + eol-last: error + default-case-last: error + no-case-declarations: error + + + ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### + + '@typescript-eslint/no-unused-expressions': [error, { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: false, + }] + '@typescript-eslint/no-empty-function': [off, { + allow: [ + private-constructors, + protected-constructors, + decoratedFunctions, + overrideMethods, + ] + }] + + '@typescript-eslint/ban-ts-comment': [error, { + 'ts-expect-error': false, + 'ts-ignore': true, + 'ts-nocheck': true, + 'ts-check': false, + }] + + '@typescript-eslint/explicit-function-return-type': [error, { + allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful + }] + '@typescript-eslint/no-unsafe-argument': warn + '@typescript-eslint/no-unsafe-return': error + '@typescript-eslint/no-var-requires': error + '@typescript-eslint/ban-types': error + + # TODO: this is just too much work + '@typescript-eslint/explicit-module-boundary-types': off + + # NOTE: We don't want to rely on TS automatic type inference + '@typescript-eslint/no-inferrable-types': off + + # TODO: sadly we still rely heavily on legacyCC + '@typescript-eslint/no-unsafe-assignment': off + '@typescript-eslint/no-unsafe-call': off + '@typescript-eslint/no-unsafe-member-access': off + + '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace + '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages + + '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes + '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler + '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties + allowDeclarations: true, + allowDefinitionFiles: true, + }] + '@typescript-eslint/restrict-template-expressions': [warn, { # concatenations of different types are common, e.g. hash calculations + allowNumber: true, + allowBoolean: true, + }] + + + # We choose to use style `... as foo` since it's more common. + # In the other hand, angle bracket style can be ambiguous with j/tsx syntax. + # For example, https://babeljs.io/docs/en/babel-plugin-transform-typescript#istsx + # forbids angle bracket style if `isTSX` is enabled. + '@typescript-eslint/consistent-type-assertions': [error, { + assertionStyle: 'as', + }] + + # Prefer the interface style. + '@typescript-eslint/consistent-type-definitions': [error, interface] + + '@typescript-eslint/no-this-alias': off + '@typescript-eslint/no-duplicate-type-constituents': [error, { + ignoreIntersections: false, + ignoreUnions: true, + }] + '@typescript-eslint/explicit-member-accessibility': [error, { + accessibility: 'no-public', + }] + '@typescript-eslint/member-ordering': off + '@typescript-eslint/naming-convention': off + '@typescript-eslint/no-unnecessary-boolean-literal-compare': off + + + # '@stylistic/key-spacing': [error, { + # singleLine: { + # beforeColon: false, + # afterColon: true + # }, + # multiLine: { + # beforeColon: false, + # afterColon: true, + # align: colon + # } + # }] + '@stylistic/keyword-spacing': error # we require this explicitly + '@stylistic/no-multi-spaces': [warn, { + ignoreEOLComments: true, + exceptions: { + 'Property': true, + 'VariableDeclarator': false + } + }] + '@stylistic/space-before-function-paren': [warn, always] # we require this explicitly + '@stylistic/quotes': [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal + '@stylistic/indent': [error, 4, { + SwitchCase: 1, + ignoredNodes: [ # https://stackoverflow.com/a/72897089 + 'FunctionExpression > .params[decorators.length > 0]', + 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' + ] + }] + '@stylistic/lines-between-class-members': off # be more lenient on member declarations + '@stylistic/max-len': [warn, 250] # more lenient on max length per line + '@stylistic/no-mixed-operators': off # this is just cumbersome + '@stylistic/object-curly-newline': off # we want manual control over this + '@stylistic/one-var-declaration-per-line': off # auto-fix has order issues with `one-var` + '@stylistic/linebreak-style': off # we don't enforce this on everyone's dev environment for now + '@stylistic/spaced-comment': off # for license declarations + '@stylistic/type-annotation-spacing': [error, { + before: false, + after: true, + overrides : { + 'arrow': { + 'before': true, + 'after': true, + } + } + }] + + '@stylistic/no-multiple-empty-lines': [warn, {max: 2, maxEOF: 1}] + '@stylistic/max-statements-per-line': [error, { max: 1 }] + '@stylistic/comma-dangle': [error, { + arrays: always-multiline, + objects: always-multiline, + imports: never, + exports: never, + functions: never, + enums: always-multiline, + generics: never, + tuples: never, + }] + '@stylistic/quote-props': [error, consistent-as-needed] + '@stylistic/function-paren-newline': off + '@stylistic/space-unary-ops': error + '@stylistic/arrow-parens': [error, always] + '@stylistic/brace-style': [error, 1tbs] + '@stylistic/nonblock-statement-body-position': [error, below] + '@stylistic/padded-blocks': [error, { + classes: always + }] + '@stylistic/no-extra-semi': error + '@stylistic/semi': [error, always] + '@stylistic/member-delimiter-style': [error, { + multiline: { 'delimiter': 'semi' }, + singleline: { 'delimiter': 'semi' }, + }] + '@stylistic/no-extra-parens': [error, all, { + conditionalAssign: false, + returnAssign: false, + nestedBinaryExpressions: false, + enforceForArrowConditionals: false, + enforceForFunctionPrototypeMethods: false, + ignoreJSX: all + }] + '@stylistic/space-infix-ops': [error] From 2caf27cc2d68f13f95b5ab991b82030ba3e1657c Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 28 Nov 2023 15:48:44 +0800 Subject: [PATCH 36/43] Update .eslintrc.yaml --- .eslintrc.yaml | 313 +++---------------------------------------------- 1 file changed, 16 insertions(+), 297 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 717ba39ce14..0b827e1b3b3 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -72,7 +72,7 @@ rules: no-console: warn # prefer the uniform logging methods no-plusplus: off # allow increment/decrement operators no-continue: off # allow unlabeled continues - no-multi-assign: [warn, { ignoreNonDeclaration: true }] # it is handy sometimes + no-multi-assign: [off, { ignoreNonDeclaration: true }] # it is handy sometimes no-nested-ternary: off # it is handy sometimes no-param-reassign: off # the output object is passed as parameters all the time no-restricted-syntax: off # for-in is a efficient choice for plain objects @@ -109,14 +109,13 @@ rules: no-eval: error no-new-wrappers: error no-sparse-arrays: error - no-trailing-spaces: error no-var: error prefer-const: error prefer-numeric-literals: off prefer-template: off - eol-last: error default-case-last: error no-case-declarations: error + no-irregular-whitespace: error ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### @@ -200,303 +199,23 @@ rules: '@typescript-eslint/no-unnecessary-boolean-literal-compare': off - # '@stylistic/key-spacing': [error, { - # singleLine: { - # beforeColon: false, - # afterColon: true - # }, - # multiLine: { - # beforeColon: false, - # afterColon: true, - # align: colon - # } - # }] - '@stylistic/keyword-spacing': error # we require this explicitly - '@stylistic/no-multi-spaces': [warn, { - ignoreEOLComments: true, - exceptions: { - 'Property': true, - 'VariableDeclarator': false - } - }] - '@stylistic/space-before-function-paren': [warn, always] # we require this explicitly - '@stylistic/quotes': [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal - '@stylistic/indent': [error, 4, { - SwitchCase: 1, - ignoredNodes: [ # https://stackoverflow.com/a/72897089 - 'FunctionExpression > .params[decorators.length > 0]', - 'FunctionExpression > .params > :matches(Decorator, :not(:first-child))', - 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key' - ] - }] - '@stylistic/lines-between-class-members': off # be more lenient on member declarations - '@stylistic/max-len': [warn, 250] # more lenient on max length per line - '@stylistic/no-mixed-operators': off # this is just cumbersome - '@stylistic/object-curly-newline': off # we want manual control over this - '@stylistic/one-var-declaration-per-line': off # auto-fix has order issues with `one-var` - '@stylistic/linebreak-style': off # we don't enforce this on everyone's dev environment for now - '@stylistic/spaced-comment': off # for license declarations - '@stylistic/type-annotation-spacing': [error, { - before: false, - after: true, - overrides : { - 'arrow': { - 'before': true, - 'after': true, - } - } - }] - - '@stylistic/no-multiple-empty-lines': [warn, {max: 2, maxEOF: 1}] - '@stylistic/max-statements-per-line': [error, { max: 1 }] - '@stylistic/comma-dangle': [error, { - arrays: always-multiline, - objects: always-multiline, - imports: never, - exports: never, - functions: never, - enums: always-multiline, - generics: never, - tuples: never, - }] - '@stylistic/quote-props': [error, consistent-as-needed] - '@stylistic/function-paren-newline': off - '@stylistic/space-unary-ops': error - '@stylistic/arrow-parens': [error, always] - '@stylistic/brace-style': [error, 1tbs] - '@stylistic/nonblock-statement-body-position': [error, below] - '@stylistic/padded-blocks': [error, { - classes: always - }] - '@stylistic/no-extra-semi': error - '@stylistic/semi': [error, always] - '@stylistic/member-delimiter-style': [error, { - multiline: { 'delimiter': 'semi' }, - singleline: { 'delimiter': 'semi' }, - }] - '@stylistic/no-extra-parens': [error, all, { - conditionalAssign: false, - returnAssign: false, - nestedBinaryExpressions: false, - enforceForArrowConditionals: false, - enforceForFunctionPrototypeMethods: false, - ignoreJSX: all - }] - '@stylistic/space-infix-ops': [error] - -root: true - -parser: '@typescript-eslint/parser' - -parserOptions: - project: - - ./tsconfig.json - -extends: - - eslint:recommended - - plugin:@typescript-eslint/recommended - - plugin:@typescript-eslint/recommended-requiring-type-checking - -plugins: ['@stylistic', '@stylistic/migrate', '@typescript-eslint'] - -settings: - import/resolver: - node: - extensions: - - .js - - .jsx - - .ts - - .tsx - - .d.ts - -env: - browser: true - node: true - es6: true - jest: true - -globals: - cc: false - wx: false - Editor: false - _Scene: false - _ccsg: false - -rules: - - # https://eslint.org/docs/rules/ - # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin - - # !!!!!!!!!!!!!!!!!!!!!!!!! - # BEFORE ADDING ANY RULES - # PLEASE EXPLAIN THE REASON IN THE COMMENT. - - ##### RECOMMENDED RULE OVERRIDES ##### - - camelcase: off # underscores may come in handy in some cases - eqeqeq: [error, always, {null: ignore}] # important check missing from recommended - prefer-rest-params: off # we need ES5 to be fast too - prefer-spread: off # we need ES5 to be fast too - radix: off # we sometimes do not need to pass a second parameter - # allow underscores, we still widely use pre-dangle naming in our naming convention - # e.g. private properties, private functions, module scope shared variables etc. - no-underscore-dangle: off - no-else-return: off # else-return is a common pattern which clearly expresses the control flow - no-unused-expressions: off # taken over by '@typescript-eslint/no-unused-expressions' - no-empty-function: off # taken over by '@typescript-eslint/no-empty-function' - - ##### AIRBNB-SPECIFIC RULE OVERRIDES ##### + ##### eslint-stylistic rules ##### - class-methods-use-this: off # so empty functions could work - guard-for-in: off # for-in is a efficient choice for plain objects - import/export: off # so export declare namespace could work - import/extensions: off # typescript doesn't support this - import/no-unresolved: off # TODO: fix internal modules - import/prefer-default-export: off # prefer named exports - - max-classes-per-file: off # helper classes are common - no-console: warn # prefer the uniform logging methods - no-plusplus: off # allow increment/decrement operators - no-continue: off # allow unlabeled continues - no-multi-assign: [warn, { ignoreNonDeclaration: true }] # it is handy sometimes - no-nested-ternary: off # it is handy sometimes - no-param-reassign: off # the output object is passed as parameters all the time - no-restricted-syntax: off # for-in is a efficient choice for plain objects - no-return-assign: off # it is handy sometimes - no-shadow: off # TODO: this throws false-positives? - no-sequences: off # it is handy sometimes - no-bitwise: off # we use this extensively - no-use-before-define: off # just too much work - no-useless-constructor: off # gives false-positives for empty constructor with parameter properties - prefer-destructuring: off # auto-fix is not smart enough to merge different instances - - - func-names: off - default-param-last: off - one-var: [error, never] - arrow-body-style: [error, as-needed] - id-denylist: [error, - any, - unknown, - Number, number, - Boolean, boolean, - String, # string, - Undefined, undefined, - ] - id-match: off - no-cond-assign: off - no-constant-condition: off - no-prototype-builtins: off - - constructor-super: error - curly: [error, all] - no-debugger: error - no-duplicate-case: error - no-eval: error - no-new-wrappers: error - no-sparse-arrays: error - no-trailing-spaces: error - no-var: error - prefer-const: error - prefer-numeric-literals: off - prefer-template: off - eol-last: error - default-case-last: error - no-case-declarations: error - - - ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES ##### + '@stylistic/no-trailing-spaces': error + '@stylistic/eol-last': error + '@stylistic/space-before-blocks': error - '@typescript-eslint/no-unused-expressions': [error, { - allowShortCircuit: true, - allowTernary: true, - allowTaggedTemplates: false, - }] - '@typescript-eslint/no-empty-function': [off, { - allow: [ - private-constructors, - protected-constructors, - decoratedFunctions, - overrideMethods, - ] - }] - - '@typescript-eslint/ban-ts-comment': [error, { - 'ts-expect-error': false, - 'ts-ignore': true, - 'ts-nocheck': true, - 'ts-check': false, - }] - - '@typescript-eslint/explicit-function-return-type': [error, { - allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful - }] - '@typescript-eslint/no-unsafe-argument': warn - '@typescript-eslint/no-unsafe-return': error - '@typescript-eslint/no-var-requires': error - '@typescript-eslint/ban-types': error - - # TODO: this is just too much work - '@typescript-eslint/explicit-module-boundary-types': off - - # NOTE: We don't want to rely on TS automatic type inference - '@typescript-eslint/no-inferrable-types': off - - # TODO: sadly we still rely heavily on legacyCC - '@typescript-eslint/no-unsafe-assignment': off - '@typescript-eslint/no-unsafe-call': off - '@typescript-eslint/no-unsafe-member-access': off - - '@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace - '@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages - - '@typescript-eslint/no-unused-vars': off # may become useful in some parent classes - '@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler - '@typescript-eslint/no-namespace': [warn, { # we need to declare static properties - allowDeclarations: true, - allowDefinitionFiles: true, - }] - '@typescript-eslint/restrict-template-expressions': [warn, { # concatenations of different types are common, e.g. hash calculations - allowNumber: true, - allowBoolean: true, - }] - - - # We choose to use style `... as foo` since it's more common. - # In the other hand, angle bracket style can be ambiguous with j/tsx syntax. - # For example, https://babeljs.io/docs/en/babel-plugin-transform-typescript#istsx - # forbids angle bracket style if `isTSX` is enabled. - '@typescript-eslint/consistent-type-assertions': [error, { - assertionStyle: 'as', - }] - - # Prefer the interface style. - '@typescript-eslint/consistent-type-definitions': [error, interface] - - '@typescript-eslint/no-this-alias': off - '@typescript-eslint/no-duplicate-type-constituents': [error, { - ignoreIntersections: false, - ignoreUnions: true, - }] - '@typescript-eslint/explicit-member-accessibility': [error, { - accessibility: 'no-public', + '@stylistic/key-spacing': [error, { + singleLine: { + beforeColon: false, + afterColon: true + }, + multiLine: { + beforeColon: false, + afterColon: true, + # align: colon + } }] - '@typescript-eslint/member-ordering': off - '@typescript-eslint/naming-convention': off - '@typescript-eslint/no-unnecessary-boolean-literal-compare': off - - - # '@stylistic/key-spacing': [error, { - # singleLine: { - # beforeColon: false, - # afterColon: true - # }, - # multiLine: { - # beforeColon: false, - # afterColon: true, - # align: colon - # } - # }] '@stylistic/keyword-spacing': error # we require this explicitly '@stylistic/no-multi-spaces': [warn, { ignoreEOLComments: true, From 858fd3742d791c4dbe2f8cf3b0e64586322825c8 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 28 Nov 2023 19:17:17 +0800 Subject: [PATCH 37/43] Update .eslintrc.yaml --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0b827e1b3b3..0519d9949d6 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -204,6 +204,7 @@ rules: '@stylistic/no-trailing-spaces': error '@stylistic/eol-last': error '@stylistic/space-before-blocks': error + '@stylistic/semi-spacing': [error, {before: false, after: true}] '@stylistic/key-spacing': [error, { singleLine: { From 2365ce0722c4c0e93022d8dcdd5eb5368f1fae50 Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 28 Nov 2023 20:03:29 +0800 Subject: [PATCH 38/43] Update .eslintrc.yaml --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0519d9949d6..92e00f7ee3e 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -205,6 +205,7 @@ rules: '@stylistic/eol-last': error '@stylistic/space-before-blocks': error '@stylistic/semi-spacing': [error, {before: false, after: true}] + '@stylistic/arrow-spacing': [error, {before: true, after: true}] '@stylistic/key-spacing': [error, { singleLine: { From f5f9fe51367d6b10fd28f841eef0e8e90a82a60a Mon Sep 17 00:00:00 2001 From: finscn Date: Tue, 28 Nov 2023 21:15:00 +0800 Subject: [PATCH 39/43] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20comma-spacing=20?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 92e00f7ee3e..297099858d4 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -205,6 +205,7 @@ rules: '@stylistic/eol-last': error '@stylistic/space-before-blocks': error '@stylistic/semi-spacing': [error, {before: false, after: true}] + '@stylistic/comma-spacing': [error, {before: false, after: true}] '@stylistic/arrow-spacing': [error, {before: true, after: true}] '@stylistic/key-spacing': [error, { From 50fcc3ef1a6b06ae1f2e8808e924138fceb7f9e5 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 1 Dec 2023 12:44:03 +0800 Subject: [PATCH 40/43] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=85=B3=E4=BA=8E=E7=A9=BA=E6=A0=BC=E7=9A=84=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 60 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 297099858d4..8cd1fe4f95e 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -127,10 +127,10 @@ rules: }] '@typescript-eslint/no-empty-function': [off, { allow: [ - private-constructors, - protected-constructors, - decoratedFunctions, - overrideMethods, + 'private-constructors', + 'protected-constructors', + 'decoratedFunctions', + 'overrideMethods', ] }] @@ -201,13 +201,19 @@ rules: ##### eslint-stylistic rules ##### - '@stylistic/no-trailing-spaces': error '@stylistic/eol-last': error + '@stylistic/no-trailing-spaces': error '@stylistic/space-before-blocks': error + '@stylistic/space-before-function-paren': [warn, always] # we require this explicitl + '@stylistic/space-unary-ops': error + '@stylistic/space-infix-ops': error + '@stylistic/space-in-parens': [error, never, { exceptions: [] }] '@stylistic/semi-spacing': [error, {before: false, after: true}] '@stylistic/comma-spacing': [error, {before: false, after: true}] '@stylistic/arrow-spacing': [error, {before: true, after: true}] - + '@stylistic/block-spacing': error + '@stylistic/array-bracket-spacing': error + '@stylistic/object-curly-spacing': off '@stylistic/key-spacing': [error, { singleLine: { beforeColon: false, @@ -220,14 +226,32 @@ rules: } }] '@stylistic/keyword-spacing': error # we require this explicitly + '@stylistic/type-annotation-spacing': [error, { + before: false, + after: true, + overrides : { + arrow: { + before: true, + after: true, + } + } + }] + '@stylistic/rest-spread-spacing': [error, never] + '@stylistic/switch-colon-spacing': error + '@stylistic/template-curly-spacing': [error, never] + '@stylistic/template-tag-spacing': [error, always] + '@stylistic/yield-star-spacing': [error, both] '@stylistic/no-multi-spaces': [warn, { ignoreEOLComments: true, exceptions: { - 'Property': true, - 'VariableDeclarator': false + Property: true, + VariableDeclarator: false } }] - '@stylistic/space-before-function-paren': [warn, always] # we require this explicitly + '@stylistic/spaced-comment': off # for license declarations + '@stylistic/no-whitespace-before-property': error + + '@stylistic/quotes': [warn, single, { allowTemplateLiterals: true }] # force single, but allow template literal '@stylistic/indent': [error, 4, { SwitchCase: 1, @@ -243,17 +267,7 @@ rules: '@stylistic/object-curly-newline': off # we want manual control over this '@stylistic/one-var-declaration-per-line': off # auto-fix has order issues with `one-var` '@stylistic/linebreak-style': off # we don't enforce this on everyone's dev environment for now - '@stylistic/spaced-comment': off # for license declarations - '@stylistic/type-annotation-spacing': [error, { - before: false, - after: true, - overrides : { - 'arrow': { - 'before': true, - 'after': true, - } - } - }] + '@stylistic/no-multiple-empty-lines': [warn, {max: 2, maxEOF: 1}] '@stylistic/max-statements-per-line': [error, { max: 1 }] @@ -269,7 +283,6 @@ rules: }] '@stylistic/quote-props': [error, consistent-as-needed] '@stylistic/function-paren-newline': off - '@stylistic/space-unary-ops': error '@stylistic/arrow-parens': [error, always] '@stylistic/brace-style': [error, 1tbs] '@stylistic/nonblock-statement-body-position': [error, below] @@ -279,8 +292,8 @@ rules: '@stylistic/no-extra-semi': error '@stylistic/semi': [error, always] '@stylistic/member-delimiter-style': [error, { - multiline: { 'delimiter': 'semi' }, - singleline: { 'delimiter': 'semi' }, + multiline: { delimiter: 'semi' }, + singleline: { delimiter: 'semi' }, }] '@stylistic/no-extra-parens': [error, all, { conditionalAssign: false, @@ -290,4 +303,3 @@ rules: enforceForFunctionPrototypeMethods: false, ignoreJSX: all }] - '@stylistic/space-infix-ops': [error] From 366e8ea94f0f69502d424cadd31c673003a64127 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 1 Dec 2023 12:53:08 +0800 Subject: [PATCH 41/43] Update .eslintrc.yaml --- .eslintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 8cd1fe4f95e..dcca49dc4a4 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -201,7 +201,6 @@ rules: ##### eslint-stylistic rules ##### - '@stylistic/eol-last': error '@stylistic/no-trailing-spaces': error '@stylistic/space-before-blocks': error '@stylistic/space-before-function-paren': [warn, always] # we require this explicitl @@ -303,3 +302,4 @@ rules: enforceForFunctionPrototypeMethods: false, ignoreJSX: all }] + '@stylistic/eol-last': error From ddaaa5ea6d057a59656f39e48e3217111d559da1 Mon Sep 17 00:00:00 2001 From: finscn Date: Fri, 1 Dec 2023 13:39:09 +0800 Subject: [PATCH 42/43] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20function-call-spacin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index dcca49dc4a4..8163094fc0d 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -202,15 +202,16 @@ rules: ##### eslint-stylistic rules ##### '@stylistic/no-trailing-spaces': error - '@stylistic/space-before-blocks': error - '@stylistic/space-before-function-paren': [warn, always] # we require this explicitl '@stylistic/space-unary-ops': error '@stylistic/space-infix-ops': error '@stylistic/space-in-parens': [error, never, { exceptions: [] }] + '@stylistic/block-spacing': error + '@stylistic/space-before-blocks': error + '@stylistic/space-before-function-paren': [warn, always] # we require this explicitl + '@stylistic/function-call-spacing': [error, never] '@stylistic/semi-spacing': [error, {before: false, after: true}] '@stylistic/comma-spacing': [error, {before: false, after: true}] '@stylistic/arrow-spacing': [error, {before: true, after: true}] - '@stylistic/block-spacing': error '@stylistic/array-bracket-spacing': error '@stylistic/object-curly-spacing': off '@stylistic/key-spacing': [error, { From 31ce9b2dfb3f812767926ac0a43fb92f68e9dc66 Mon Sep 17 00:00:00 2001 From: finscn Date: Wed, 20 Dec 2023 19:24:46 +0800 Subject: [PATCH 43/43] =?UTF-8?q?=E5=85=B3=E9=97=AD=20no-inner-declaration?= =?UTF-8?q?s=20=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在内部声明函数 是一种常规操作. 没必要禁止. --- .eslintrc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 8163094fc0d..3ab1a03ab27 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -116,6 +116,7 @@ rules: default-case-last: error no-case-declarations: error no-irregular-whitespace: error + no-inner-declarations: off ##### TYPESCRIPT-SPECIFIC RULE OVERRIDES #####