feat: add ts config

This commit is contained in:
Anthony Fu 2019-07-18 04:11:55 +08:00
parent 25922716ee
commit b025b09a5f
8 changed files with 77 additions and 28 deletions

2
.gitignore vendored
View File

@ -78,4 +78,4 @@ dist
.idea .idea
package-lock.json package-lock.json
*.learna_backup *.lerna_backup

View File

@ -5,9 +5,24 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"postinstall": "lerna bootstrap", "postinstall": "lerna bootstrap",
"lint": "lerna run lint",
"lint:fix": "lerna run lint -- -- --fix",
"release": "lerna publish --conventional-commits" "release": "lerna publish --conventional-commits"
}, },
"devDependencies": { "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"
} }
} }

View File

@ -4,23 +4,18 @@ module.exports = {
browser: true, browser: true,
node: true, node: true,
}, },
plugins: [
'@typescript-eslint',
],
parser: '@typescript-eslint/parser',
extends: [ extends: [
'standard', 'standard',
'plugin:import/errors', 'plugin:import/errors',
'plugin:import/warnings', 'plugin:import/warnings',
'plugin:@typescript-eslint/recommended',
], ],
plugins: [ plugins: [
'unicorn', 'unicorn',
], ],
settings: { settings: {
'import/resolver': { 'import/resolver': {
node: { extensions: ['.js', '.mjs'] } node: { extensions: ['.js', '.mjs'] },
} },
}, },
rules: { rules: {
// import // import
@ -59,10 +54,6 @@ module.exports = {
'no-spaced-func': 'error', 'no-spaced-func': 'error',
'object-curly-spacing': ['error', 'always'], 'object-curly-spacing': ['error', 'always'],
'no-return-await': 'off', 'no-return-await': 'off',
'prefer-const': ['error', {
'destructuring': 'any',
'ignoreReadBeforeAssign': false
}],
// es6 // es6
'no-var': 'error', 'no-var': 'error',
@ -103,16 +94,6 @@ module.exports = {
'no-return-assign': 'off', 'no-return-assign': 'off',
'operator-linebreak': [2, 'before'], '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 // unicorns
// Pass error message when throwing errors // Pass error message when throwing errors
'unicorn/error-message': 'error', 'unicorn/error-message': 'error',
@ -138,5 +119,5 @@ module.exports = {
'unicorn/prefer-type-error': 'error', 'unicorn/prefer-type-error': 'error',
// Use new when throwing error // Use new when throwing error
'unicorn/throw-new-error': 'error', 'unicorn/throw-new-error': 'error',
} },
} }

View File

@ -29,8 +29,7 @@
"eslint-plugin-unicorn": "^9.1.1" "eslint-plugin-unicorn": "^9.1.1"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^6.0.1", "eslint": "^6.0.1"
"standard-version": "^6.0.1"
}, },
"gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0" "gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0"
} }

View File

@ -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',
}
}

View File

@ -0,0 +1,32 @@
{
"name": "@antfu/eslint-config-ts",
"version": "0.1.5",
"description": "",
"main": "index.js",
"keywords": [],
"author": "Anthony Fu <anthonyfu117@hotmail.com> (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"
}

View File

@ -4,7 +4,7 @@ module.exports = {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
}, },
extends: [ extends: [
'@antfu/eslint-config', '@antfu/eslint-config-ts',
'plugin:vue/recommended', 'plugin:vue/recommended',
], ],
plugins: [ plugins: [

View File

@ -24,7 +24,8 @@
"eslint-plugin-vue": "5.2.3" "eslint-plugin-vue": "5.2.3"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^6.0.1" "eslint": "^6.0.1",
"typescript": "^3.5.3"
}, },
"gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0" "gitHead": "bd0460759c73f7fcdf32570f40a13e37ab6961c0"
} }