From b025b09a5fb7ebc55af0c4d8be7fe4a98cabdd06 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 18 Jul 2019 04:11:55 +0800 Subject: [PATCH] feat: add ts config --- .gitignore | 2 +- package.json | 17 ++++++++++++++++- packages/common/index.js | 25 +++---------------------- packages/common/package.json | 3 +-- packages/typescript/index.js | 21 +++++++++++++++++++++ packages/typescript/package.json | 32 ++++++++++++++++++++++++++++++++ packages/vue/index.js | 2 +- packages/vue/package.json | 3 ++- 8 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 packages/typescript/index.js create mode 100644 packages/typescript/package.json diff --git a/.gitignore b/.gitignore index ff3496c..37a92c3 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,4 @@ dist .idea package-lock.json -*.learna_backup \ No newline at end of file +*.lerna_backup \ No newline at end of file diff --git a/package.json b/package.json index 37c47b9..6134248 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,24 @@ "license": "MIT", "scripts": { "postinstall": "lerna bootstrap", + "lint": "lerna run lint", + "lint:fix": "lerna run lint -- -- --fix", "release": "lerna publish --conventional-commits" }, "devDependencies": { - "lerna": "^3.14.1" + "@antfu/eslint-config": "^0.1.5", + "@typescript-eslint/eslint-plugin": "1.11.0", + "@typescript-eslint/parser": "^1.10.2", + "eslint": "^6.0.1", + "eslint-config-standard": "^12.0.0", + "eslint-plugin-import": "^2.18.0", + "eslint-plugin-node": "^9.1.0", + "eslint-plugin-nuxt": "0.4.3", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.0", + "eslint-plugin-unicorn": "^9.1.1", + "eslint-plugin-vue": "5.2.3", + "lerna": "^3.14.1", + "typescript": "^3.5.3" } } diff --git a/packages/common/index.js b/packages/common/index.js index 2ba04bc..69691d7 100644 --- a/packages/common/index.js +++ b/packages/common/index.js @@ -4,23 +4,18 @@ module.exports = { browser: true, node: true, }, - plugins: [ - '@typescript-eslint', - ], - parser: '@typescript-eslint/parser', extends: [ 'standard', 'plugin:import/errors', 'plugin:import/warnings', - 'plugin:@typescript-eslint/recommended', ], plugins: [ 'unicorn', ], settings: { 'import/resolver': { - node: { extensions: ['.js', '.mjs'] } - } + node: { extensions: ['.js', '.mjs'] }, + }, }, rules: { // import @@ -59,10 +54,6 @@ module.exports = { 'no-spaced-func': 'error', 'object-curly-spacing': ['error', 'always'], 'no-return-await': 'off', - 'prefer-const': ['error', { - 'destructuring': 'any', - 'ignoreReadBeforeAssign': false - }], // es6 'no-var': 'error', @@ -103,16 +94,6 @@ module.exports = { 'no-return-assign': 'off', 'operator-linebreak': [2, 'before'], - // TS - '@typescript-eslint/no-unused-vars': [2, { args: 'none' }], - '@typescript-eslint/indent': ['error', 2], - '@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }], - '@typescript-eslint/type-annotation-spacing': ['error', {}], - '@typescript-eslint/camelcase': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-member-accessibility': 'off', - '@typescript-eslint/no-explicit-any': 'off', - // unicorns // Pass error message when throwing errors 'unicorn/error-message': 'error', @@ -138,5 +119,5 @@ module.exports = { 'unicorn/prefer-type-error': 'error', // Use new when throwing error 'unicorn/throw-new-error': 'error', - } + }, } diff --git a/packages/common/package.json b/packages/common/package.json index 9f9533f..5c42b32 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -29,8 +29,7 @@ "eslint-plugin-unicorn": "^9.1.1" }, "devDependencies": { - "eslint": "^6.0.1", - "standard-version": "^6.0.1" + "eslint": "^6.0.1" }, "gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0" } diff --git a/packages/typescript/index.js b/packages/typescript/index.js new file mode 100644 index 0000000..7d94269 --- /dev/null +++ b/packages/typescript/index.js @@ -0,0 +1,21 @@ +module.exports = { + plugins: [ + '@typescript-eslint', + ], + parser: '@typescript-eslint/parser', + extends: [ + '@antfu/eslint-config', + 'plugin:@typescript-eslint/recommended', + ], + rules: { + // TS + '@typescript-eslint/no-unused-vars': [2, { args: 'none' }], + '@typescript-eslint/indent': ['error', 2], + '@typescript-eslint/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }], + '@typescript-eslint/type-annotation-spacing': ['error', {}], + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-member-accessibility': 'off', + '@typescript-eslint/no-explicit-any': 'off', + } +} diff --git a/packages/typescript/package.json b/packages/typescript/package.json new file mode 100644 index 0000000..b4a4e90 --- /dev/null +++ b/packages/typescript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@antfu/eslint-config-ts", + "version": "0.1.5", + "description": "", + "main": "index.js", + "keywords": [], + "author": "Anthony Fu (https://github.com/antfu/)", + "license": "MIT", + "scripts": { + "lint": "eslint . --config=index.js" + }, + "files": [ + "index.js" + ], + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "eslint": ">=5.16.0", + "typescript": ">=3.5" + }, + "dependencies": { + "@antfu/eslint-config": "^0.1.5", + "@typescript-eslint/eslint-plugin": "1.11.0", + "@typescript-eslint/parser": "^1.10.2" + }, + "devDependencies": { + "eslint": "^6.0.1", + "typescript": "^3.5.3" + }, + "gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0" +} diff --git a/packages/vue/index.js b/packages/vue/index.js index 0daae3b..dea3379 100644 --- a/packages/vue/index.js +++ b/packages/vue/index.js @@ -4,7 +4,7 @@ module.exports = { parser: '@typescript-eslint/parser', }, extends: [ - '@antfu/eslint-config', + '@antfu/eslint-config-ts', 'plugin:vue/recommended', ], plugins: [ diff --git a/packages/vue/package.json b/packages/vue/package.json index 822757d..96c831a 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -24,7 +24,8 @@ "eslint-plugin-vue": "5.2.3" }, "devDependencies": { - "eslint": "^6.0.1" + "eslint": "^6.0.1", + "typescript": "^3.5.3" }, "gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0" }