Skip to content

Commit

Permalink
chore: config eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwong committed Dec 26, 2019
1 parent 1892d46 commit 36f63d7
Show file tree
Hide file tree
Showing 5 changed files with 968 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
lib/
node_modules/
public/
config/
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const eslintrc = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'@typescript-eslint',
],
env: {
browser: true,
node: true,
es6: true,
},
parserOptions: {
project: './tsconfig.eslint.json',
ecmaVersion: 2019,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true
}
},
rules: {
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules
'@typescript-eslint/consistent-type-definitions': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/generic-type-naming': 0,
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/member-ordering': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-extra-parens': 0,
'@typescript-eslint/no-magic-numbers': 0,
'@typescript-eslint/no-parameter-properties': 0,
'@typescript-eslint/no-type-alias': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/prefer-for-of': 1,
'@typescript-eslint/prefer-interface': 0,
'@typescript-eslint/interface-name-prefix': [0, {
prefixWithI: 'always'
}], // 接口名称首字母 I
'@typescript-eslint/member-delimiter-style': [0, {
delimiter: 'none'
}], // 成员分隔符
'@typescript-eslint/semi': ['error', 'never'],

'space-infix-ops': ['error'],
'comma-dangle': ['error', {
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'never'
}],
'space-before-function-paren': ['error', 'always'], // 方法名后空格
'semi': ['error', 'never'], // 无分号
'indent': ['error', 2], // 缩进2
'quotes': ['error', 'single'], // 单引号
'no-param-reassign': 0, // 传入参数可修改
'no-restricted-globals': ['error', 'event'] // 部分全局变量禁止直接使用
},
}

module.exports = eslintrc
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"version": "0.0.1",
"description": "工具库",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/simonwong/fly-helper.git"
Expand All @@ -16,7 +13,14 @@
"url": "https://github.com/simonwong/fly-helper/issues"
},
"homepage": "https://github.com/simonwong/fly-helper#readme",
"scripts": {
"lint": "eslint --ext .js,.ts ./src",
"lint:fix": "eslint --fix --ext .js,.ts ./src"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0",
"eslint": "^6.8.0",
"typescript": "^3.7.4"
}
}
10 changes: 10 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"resolveJsonModule": true,
},
"include": [
"**/*.ts",
"**/*.js"
]
}
Loading

0 comments on commit 36f63d7

Please sign in to comment.