From cf1d1c09d6bd81c8271b3d3f7017aa635a31d6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Sun, 20 Dec 2020 07:18:23 -0600 Subject: [PATCH] less lint config (#72) * fast eslint * close some rules * close some rules * fix test * fix ts * fix lint * fix demo types * close some types * add new config * prettier all code * add ts config * add ts config * add ts config * add ts config * add ts config * add ts config * fix ts * close import * close import * close import --- example/package.json | 2 +- package.json | 6 +++-- src/eslint.ts | 51 +++++++++++++++---------------------------- src/tsEslintConfig.ts | 8 +++---- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/example/package.json b/example/package.json index 7edf468..f3244e0 100644 --- a/example/package.json +++ b/example/package.json @@ -8,7 +8,7 @@ "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style", - "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", + "lint:js": "cross-env TIMING=1 eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", "lint:prettier": "prettier --check \"**/*\" --end-of-line auto", "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", "prettier": "prettier -c --write \"**/*\"" diff --git a/package.json b/package.json index 98183d8..e7515cd 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "scripts": { "build": "tsc --build tsconfig.json", "deps": "yarn upgrade-interactive --latest", + "lib": "cross-env TIMING=1 eslint lib", "lint": "npm run build && cd example && npm run lint", "prepublishOnly": "npm run build && npm test && np --no-cleanup --yolo --no-publish --any-branch", - "test": "npm run build && cd example && npm run lint", - "prettier": "prettier -c --write \"**/*\"" + "prettier": "prettier -c --write \"**/*\"", + "test": "npm run build && cd example && npm run lint" }, "dependencies": { "@typescript-eslint/eslint-plugin": "^4.10.0", @@ -61,6 +62,7 @@ "typescript": "^4.0.2" }, "devDependencies": { + "cross-env": "^7.0.3", "np": "^6.2.5", "prettier": "^2.2.1" } diff --git a/src/eslint.ts b/src/eslint.ts index 5c8cbac..11ddfd0 100644 --- a/src/eslint.ts +++ b/src/eslint.ts @@ -37,49 +37,34 @@ module.exports = { 'react/jsx-one-expression-per-line': 0, 'generator-star-spacing': 0, 'function-paren-newline': 0, - 'import/no-unresolved': [ - 2, - { - ignore: ['^@/', '^@@/', '^@alipay/bigfish/'], - caseSensitive: true, - commonjs: true, - }, - ], - 'import/order': 'warn', - 'react/jsx-props-no-spreading': 0, - 'react/state-in-constructor': 0, - 'no-confusing-arrow': 1, - 'react/static-property-placement': 0, - 'import/no-extraneous-dependencies': [ - 2, - { - optionalDependencies: true, - devDependencies: [ - '**/tests/**.{ts,js,jsx,tsx}', - '**/_test_/**.{ts,js,jsx,tsx}', - '/mock/**/**.{ts,js,jsx,tsx}', - '**/**.test.{ts,js,jsx,tsx}', - '**/_mock.{ts,js,jsx,tsx}', - '**/example/**.{ts,js,jsx,tsx}', - '**/examples/**.{ts,js,jsx,tsx}', - ], - }, - ], + 'import/no-unresolved': 0, + 'import/order': 0, + 'import/no-named-as-default': 0, + 'import/no-cycle': 0, + 'import/prefer-default-export': 0, + 'import/no-default-export': 0, + 'import/no-extraneous-dependencies': 0, + 'import/named': 0, + 'import/no-named-as-default-member': 0, + 'import/no-duplicates': 0, + 'import/no-self-import': 0, + 'import/no-useless-path-segments': 0, 'jsx-a11y/no-noninteractive-element-interactions': 0, 'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/no-static-element-interactions': 0, 'jsx-a11y/anchor-is-valid': 0, + 'sort-imports': 0, + 'no-confusing-arrow': 1, 'linebreak-style': 0, // Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins 'no-prototype-builtins': 'off', - 'import/prefer-default-export': 'off', - 'import/no-default-export': [0, 'camel-case'], + 'unicorn/prevent-abbreviations': 'off', + 'react/jsx-props-no-spreading': 0, + 'react/state-in-constructor': 0, + 'react/static-property-placement': 0, // Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md 'react/destructuring-assignment': 'off', 'react/jsx-filename-extension': 'off', - 'unicorn/prevent-abbreviations': 'off', - 'sort-imports': 0, - 'import/no-cycle': 0, 'react/no-array-index-key': 'warn', 'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks 'react-hooks/exhaustive-deps': 'warn', // Checks deps of Hooks diff --git a/src/tsEslintConfig.ts b/src/tsEslintConfig.ts index db28a71..cd162be 100644 --- a/src/tsEslintConfig.ts +++ b/src/tsEslintConfig.ts @@ -34,9 +34,9 @@ export default { '@typescript-eslint/method-signature-style': 'error', 'no-array-constructor': 'off', '@typescript-eslint/no-array-constructor': 0, - '@typescript-eslint/no-base-to-string': 'error', + '@typescript-eslint/no-base-to-string': 0, '@typescript-eslint/no-confusing-non-null-assertion': 'error', - '@typescript-eslint/no-confusing-void-expression': 1, + '@typescript-eslint/no-confusing-void-expression': 0, 'no-dupe-class-members': 'off', '@typescript-eslint/no-dupe-class-members': 'error', 'no-duplicate-imports': 'off', @@ -55,7 +55,7 @@ export default { '@typescript-eslint/no-for-in-array': 'error', '@typescript-eslint/no-implicit-any-catch': 0, 'no-implied-eval': 'off', - '@typescript-eslint/no-implied-eval': 'error', + '@typescript-eslint/no-implied-eval': 0, '@typescript-eslint/no-inferrable-types': 0, 'no-invalid-this': 'off', '@typescript-eslint/no-invalid-this': 'error', @@ -67,7 +67,7 @@ export default { 'no-magic-numbers': 'off', '@typescript-eslint/no-magic-numbers': 0, '@typescript-eslint/no-misused-new': 'error', - '@typescript-eslint/no-misused-promises': 'error', + '@typescript-eslint/no-misused-promises': 0, '@typescript-eslint/no-namespace': 1, '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', '@typescript-eslint/no-parameter-properties': 'error',