Skip to content

Commit

Permalink
Rule adptations (#173)
Browse files Browse the repository at this point in the history
* adapt some rules are are too strict

Signed-off-by: Kangrui Ye <[email protected]>

* update dependencies

Signed-off-by: Kangrui Ye <[email protected]>

* bump version

Signed-off-by: Kangrui Ye <[email protected]>

---------

Signed-off-by: Kangrui Ye <[email protected]>
  • Loading branch information
strawberry-choco authored Aug 9, 2023
1 parent 4f4954c commit a29c134
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 95 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin",
"version": "0.19.0",
"version": "0.19.1",
"private": true,
"volta": {
"node": "18.16.0",
Expand Down Expand Up @@ -33,13 +33,13 @@
"@angular-eslint/eslint-plugin-template": "16.1.0",
"@angular-eslint/template-parser": "16.1.0",
"@angular/compiler": "16.1.8",
"@rushstack/eslint-patch": "1.3.2",
"@types/eslint": "8.44.1",
"@rushstack/eslint-patch": "1.3.3",
"@types/eslint": "8.44.2",
"@types/estree": "1.0.1",
"@types/jest": "29.5.3",
"@types/node": "18.17.2",
"@typescript-eslint/eslint-plugin": "6.2.1",
"@typescript-eslint/parser": "6.2.1",
"@types/node": "18.17.4",
"@typescript-eslint/eslint-plugin": "6.3.0",
"@typescript-eslint/parser": "6.3.0",
"@vue/eslint-config-typescript": "11.0.3",
"eslint": "8.46.0",
"eslint-plugin-import": "2.28.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can find the directory of all rules including their reasoning [here](src/con
The following dependencies are required:

```
"@cloudflight/eslint-plugin-typescript": ">=0.19.0",
"@cloudflight/eslint-plugin-typescript": ">=0.19.1",
"@rushstack/eslint-patch": "1.2.0",
"eslint": ">=8.0.0 <9.0.0"
```
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-angular",
"version": "0.19.0",
"version": "0.19.1",
"description": "Cloudflight eslint-plugin & eslint-config for angular",
"volta": {
"extends": "../../package.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Linter} from 'eslint';

import {angularEslintRules} from './rules/angular-eslint';
import {typescriptEslintRules} from './rules/typescript-eslint';

export const RecommendedTypescriptConfig: Linter.BaseConfig = {
plugins: ['@cloudflight/angular', '@cloudflight/typescript', '@angular-eslint'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@cloudflight/typescript/recommended'],
rules: {
...angularEslintRules,
...typescriptEslintRules,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type {Linter} from 'eslint';

const pluginPrefix = '@typescript-eslint';

export const typescriptEslintRules: Linter.RulesRecord = {
// angular modules are usually empty, so this rule is turned off just for them
[`${pluginPrefix}/no-extraneous-class`]: 'off',
};
2 changes: 1 addition & 1 deletion packages/eslint-plugin-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can find the directory of all rules including their reasoning [here](src/con
The following dependencies are required:

```
"@cloudflight/eslint-plugin-typescript": ">=0.19.0",
"@cloudflight/eslint-plugin-typescript": ">=0.19.1",
"@rushstack/eslint-patch": "1.2.0",
"eslint": ">=8.0.0 <9.0.0"
```
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-node",
"version": "0.19.0",
"version": "0.19.1",
"description": "Cloudflight eslint-plugin & eslint-config for node",
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can find the directory of all rules including their reasoning [here](src/con
The following dependencies are required:

```
"@cloudflight/eslint-plugin-typescript": ">=0.19.0",
"@cloudflight/eslint-plugin-typescript": ">=0.19.1",
"@rushstack/eslint-patch": "1.2.0",
"eslint": ">=8.0.0 <9.0.0"
```
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-react",
"version": "0.19.0",
"version": "0.19.1",
"description": "Cloudflight eslint-plugin & eslint-config for React",
"volta": {
"extends": "../../package.json"
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-typescript",
"version": "0.19.0",
"version": "0.19.1",
"description": "Cloudflight eslint-plugin & eslint-config for typescript",
"volta": {
"extends": "../../package.json"
Expand All @@ -27,8 +27,8 @@
"test-package": "jest"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-json-es": "^1.5.7",
"eslint-plugin-rxjs": "^5.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import type {Linter} from 'eslint';

export const eslintRules: Linter.RulesRecord = {
complexity: ['error', {max: 20}],
// this rule conflicts with switch-exhaustiveness-check and should not be turned on
// with typescript, this would not become an issue either
'consistent-return': 'off',
curly: ['error'],
// this rule conflicts with switch-exhaustiveness-check and should not be turned on
'default-case': 'off',
eqeqeq: ['error', 'always', {null: 'ignore'}],
'max-classes-per-file': ['error', 1],
'new-parens': ['error'],
Expand All @@ -15,7 +20,6 @@ export const eslintRules: Linter.RulesRecord = {
'no-duplicate-imports': ['error'],
'no-empty': ['error'],
'no-eval': ['error'],
'no-void': ['error'],
'no-with': ['error'],
'no-ex-assign': ['error'],
'no-fallthrough': ['error'],
Expand All @@ -30,7 +34,6 @@ export const eslintRules: Linter.RulesRecord = {
'no-unsafe-finally': ['error'],
'no-unsafe-negation': ['error'],
'no-unused-labels': ['error'],
'no-return-await': ['error'],
'no-return-assign': ['error', 'always'],
'no-script-url': ['error'],
'no-throw-literal': ['error'],
Expand Down Expand Up @@ -78,12 +81,6 @@ export const eslintRules: Linter.RulesRecord = {
'no-tabs': ['error'],
'semi-style': ['error', 'last'],
'default-case-last': ['error'],
'default-case': [
'error',
{
commentPattern: '^no default$',
},
],
'unicode-bom': ['error', 'never'],
'for-direction': ['error'],
'block-scoped-var': ['error'],
Expand All @@ -105,7 +102,6 @@ export const eslintRules: Linter.RulesRecord = {
},
],
'prefer-template': ['error'],
'consistent-return': ['error'],
'symbol-description': ['error'],
strict: ['error', 'never'],
yoda: ['error'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const typescriptEslintRules: Linter.RulesRecord = {
'error',
{default: ['static-field', 'field', 'signature', 'constructor', 'static-method', 'method']},
],
// this rule prevents oneliner functions, which are very useful in component templates
[`${pluginPrefix}/no-confusing-void-expression`]: 'off',
[`${pluginPrefix}/no-floating-promises`]: ['error', {ignoreVoid: true}],
[`${pluginPrefix}/no-inferrable-types`]: ['error', {ignoreParameters: true}],
'no-invalid-this': 'off',
Expand All @@ -58,6 +60,11 @@ export const typescriptEslintRules: Linter.RulesRecord = {
// typescript offers the compiler setting 'noPropertyAccessFromIndexSignature' which would solve this issue,
// but it is not perfect. It also adds 'undefined' to the type even if there was a bounds-check already.
[`${pluginPrefix}/no-unnecessary-condition`]: ['off', {allowConstantLoopConditions: true}],
// this rule makes it hard to work with the default functionalities of js itself, thus disabled
[`${pluginPrefix}/no-unsafe-argument`]: 'off',
// enums can be used as a holder of constants, working
// with external APIs can be painful if this is not allowed
[`${pluginPrefix}/no-unsafe-enum-comparison`]: 'off',
'no-unused-vars': 'off',
[`${pluginPrefix}/no-unused-vars`]: ['error', {args: 'none', ignoreRestSiblings: true}],
[`${pluginPrefix}/promise-function-async`]: ['error'],
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can find the directory of all rules including their reasoning [here](src/con
The following dependencies are required:

```
"@cloudflight/eslint-plugin-typescript": ">=0.19.0",
"@cloudflight/eslint-plugin-typescript": ">=0.19.1",
"@rushstack/eslint-patch": "1.2.0",
"eslint": ">=8.0.0 <9.0.0"
```
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-vue",
"version": "0.19.0",
"version": "0.19.1",
"description": "Cloudflight eslint-plugin & eslint-config for vue",
"volta": {
"extends": "../../package.json"
Expand Down
Loading

0 comments on commit a29c134

Please sign in to comment.