Skip to content
Permalink
Browse files

chore: config eslint

  • Loading branch information
simonwong committed Dec 26, 2019
1 parent 1892d46 commit 36f63d7ae4140ed32388b5111d0f537909e7c81d
Showing with 968 additions and 3 deletions.
  1. +5 −0 .eslintignore
  2. +63 −0 .eslintrc.js
  3. +7 −3 package.json
  4. +10 −0 tsconfig.eslint.json
  5. +883 −0 yarn.lock
@@ -0,0 +1,5 @@
dist/
lib/
node_modules/
public/
config/
@@ -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
@@ -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"
@@ -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"
}
}
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"resolveJsonModule": true,
},
"include": [
"**/*.ts",
"**/*.js"
]
}

0 comments on commit 36f63d7

Please sign in to comment.
You can’t perform that action at this time.