Skip to content

Commit

Permalink
升级 eslint, typescript-eslint, husky, rimraf
Browse files Browse the repository at this point in the history
  • Loading branch information
xcatliu committed Aug 30, 2019
1 parent 92eafb9 commit 559b96f
Show file tree
Hide file tree
Showing 43 changed files with 627 additions and 221 deletions.
10 changes: 10 additions & 0 deletions await-thenable/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* 禁止对没有 then 方法的对象使用 await
* @category TypeScript
* @requires-types-information
*/
'@typescript-eslint/await-thenable': 'off'
}
};
2 changes: 1 addition & 1 deletion docs/index.html
@@ -1 +1 @@
<html><head><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><title>AlloyTeam ESLint 规则</title><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="shortcut icon" type="image/png" href="alloy.f4abfc6f.png"><link rel="stylesheet" href="site.127e0b37.css"></head><body> <div id="app"></div> <script src="site.08fcf7bc.js"></script> </body></html>
<html><head><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="ie=edge"><title>AlloyTeam ESLint 规则</title><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="shortcut icon" type="image/png" href="alloy.f4abfc6f.png"><link rel="stylesheet" href="site.127e0b37.css"></head><body> <div id="app"></div> <script src="site.8cf4e64e.js"></script> </body></html>
1 change: 0 additions & 1 deletion docs/site.08fcf7bc.js.map

This file was deleted.

6 changes: 3 additions & 3 deletions docs/site.08fcf7bc.js → docs/site.8cf4e64e.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/site.8cf4e64e.js.map

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions index.js
Expand Up @@ -10,13 +10,13 @@
* Swan <noreply@github.com>
*
* 依赖版本:
* eslint ^5.16.0
* eslint ^6.2.2
* babel-eslint ^10.0.1
* eslint-plugin-react ^7.14.2
* vue-eslint-parser ^5.0.0
* eslint-plugin-vue ^5.2.3
* @typescript-eslint/parser ^1.10.2
* @typescript-eslint/eslint-plugin ^1.10.2
* @typescript-eslint/parser ^2.0.0
* @typescript-eslint/eslint-plugin ^2.0.0
*
* 此文件是由脚本 scripts/build.ts 自动生成
*
Expand All @@ -32,6 +32,12 @@ module.exports = {
* @category Possible Errors
*/
'for-direction': 'error',
/**
* 函数参数之间的换行模式必须保持一致
* @category Possible Errors
* @fixable
*/
'function-call-argument-newline': ['error', 'consistent'],
/**
* getter 必须有返回值,并且禁止返回空
* @category Possible Errors
Expand Down
392 changes: 295 additions & 97 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -62,24 +62,24 @@
"dependencies": {},
"devDependencies": {
"@types/doctrine": "0.0.3",
"@types/eslint": "^4.16.6",
"@types/eslint": "^4.16.8",
"@types/node": "^12.0.2",
"@types/prettier": "^1.16.4",
"@types/react": "^16.8.18",
"@types/react-dom": "^16.8.4",
"@types/react-tooltip": "^3.9.3",
"@types/xml-escape": "^1.1.0",
"@typescript-eslint/eslint-plugin": "^1.10.2",
"@typescript-eslint/parser": "^1.10.2",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"axios": "^0.19.0",
"babel-eslint": "^10.0.1",
"doctrine": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0",
"eslint-config-prettier": "^5.0.0",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-vue": "^5.2.3",
"husky": "^2.3.0",
"husky": "^3.0.4",
"insert-tag": "^0.1.2",
"mobi-plugin-color": "^1.0.0",
"mobi.css": "^3.1.1",
Expand All @@ -90,7 +90,7 @@
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-tooltip": "^3.10.0",
"rimraf": "^2.6.3",
"rimraf": "^3.0.0",
"ts-node": "^7.0.1",
"typescript": "^3.4.5",
"vue-eslint-parser": "^5.0.0",
Expand Down
6 changes: 3 additions & 3 deletions react.js
Expand Up @@ -10,13 +10,13 @@
* Swan <noreply@github.com>
*
* 依赖版本:
* eslint ^5.16.0
* eslint ^6.2.2
* babel-eslint ^10.0.1
* eslint-plugin-react ^7.14.2
* vue-eslint-parser ^5.0.0
* eslint-plugin-vue ^5.2.3
* @typescript-eslint/parser ^1.10.2
* @typescript-eslint/eslint-plugin ^1.10.2
* @typescript-eslint/parser ^2.0.0
* @typescript-eslint/eslint-plugin ^2.0.0
*
* 此文件是由脚本 scripts/build.ts 自动生成
*
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.ts
Expand Up @@ -26,8 +26,8 @@ const pkg = require('../package.json');
class Builder {
private namespace: RuleNamespaces = 'index';
private ruleList: Rule[] = [];
private rulesContent: string = '';
private namespaceEslintrcContent: string = '';
private rulesContent = '';
private namespaceEslintrcContent = '';

public build(namespace: RuleNamespaces) {
this.namespace = namespace;
Expand Down
13 changes: 11 additions & 2 deletions site/config/index.json

Large diffs are not rendered by default.

119 changes: 83 additions & 36 deletions site/config/typescript.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions test/index/function-call-argument-newline/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* 函数参数之间的换行模式必须保持一致
* @category Possible Errors
* @fixable
*/
'function-call-argument-newline': ['error', 'consistent']
}
};
2 changes: 2 additions & 0 deletions test/index/function-call-argument-newline/bad.js
@@ -0,0 +1,2 @@
foo('one', 'two',
'three');
6 changes: 6 additions & 0 deletions test/index/function-call-argument-newline/good.js
@@ -0,0 +1,6 @@
foo('one', 'two', 'three');
bar(
'one',
'two',
'three'
);
16 changes: 16 additions & 0 deletions test/typescript/consistent-type-assertions/.eslintrc.js
@@ -0,0 +1,16 @@
module.exports = {
rules: {
/**
* 类型断言必须使用 as Type,禁止使用 <Type>,禁止对对象字面量进行类型断言(断言成 any 是允许的)
* @category TypeScript
* @reason <Type> 容易被理解为 jsx
*/
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never'
}
]
}
};
@@ -1,2 +1,6 @@
let bar1: string | number;
const foo1 = <string>bar1;

const baz1 = {
bar: 1
} as object;
@@ -1,2 +1,6 @@
let bar2: string | number;
const foo2 = bar2 as string;

const baz2 = {
bar: 1
} as any;
Expand Up @@ -6,6 +6,6 @@ module.exports = {
* @reason 接口可以 implement extend 和 merge
* @fixable
*/
'@typescript-eslint/prefer-interface': 'error'
'@typescript-eslint/consistent-type-definitions': ['error', 'interface']
}
};
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions test/typescript/no-angle-bracket-type-assertion/.eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions test/typescript/no-misused-promises/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* 避免错误的使用 Promise
* @category TypeScript
* @requires-types-information
*/
'@typescript-eslint/no-misused-promises': 'off'
}
};
9 changes: 0 additions & 9 deletions test/typescript/no-object-literal-type-assertion/.eslintrc.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/typescript/no-object-literal-type-assertion/bad.ts

This file was deleted.

3 changes: 0 additions & 3 deletions test/typescript/no-object-literal-type-assertion/good.ts

This file was deleted.

10 changes: 0 additions & 10 deletions test/typescript/no-triple-slash-reference/.eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions test/typescript/prefer-readonly/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* 私有变量如果没有在构造函数外被赋值,则必须设为 readonly
* @category TypeScript
* @requires-types-information
*/
'@typescript-eslint/prefer-readonly': 'off'
}
};
10 changes: 10 additions & 0 deletions test/typescript/require-await/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* async 函数中必须存在 await 语句
* @category TypeScript
* @requires-types-information
*/
'@typescript-eslint/require-await': 'off'
}
};
10 changes: 10 additions & 0 deletions test/typescript/strict-boolean-expressions/.eslintrc.js
@@ -0,0 +1,10 @@
module.exports = {
rules: {
/**
* 条件判断必须传入布尔值
* @category TypeScript
* @requires-types-information
*/
'@typescript-eslint/strict-boolean-expressions': 'off'
}
};
13 changes: 13 additions & 0 deletions test/typescript/triple-slash-reference/.eslintrc.js
@@ -0,0 +1,13 @@
module.exports = {
rules: {
/**
* 禁止使用三斜杠导入文件
* @category TypeScript
* @reason 三斜杠是已废弃的语法,但在类型声明文件中还是可以使用的
*/
'@typescript-eslint/triple-slash-reference': [
'error',
{ path: 'never', types: 'always', lib: 'always' }
]
}
};
20 changes: 20 additions & 0 deletions test/typescript/typedef/.eslintrc.js
@@ -0,0 +1,20 @@
module.exports = {
rules: {
/**
* interface 和 type 定义时必须声明成员的类型
* @category TypeScript
*/
'@typescript-eslint/typedef': [
'error',
{
arrayDestructuring: false,
arrowParameter: false,
memberVariableDeclaration: false,
objectDestructuring: false,
parameter: false,
propertyDeclaration: true,
variableDeclaration: false
}
]
}
};
4 changes: 4 additions & 0 deletions test/typescript/typedef/bad.ts
@@ -0,0 +1,4 @@
type Foo1 = {
bar;
baz;
};
4 changes: 4 additions & 0 deletions test/typescript/typedef/good.ts
@@ -0,0 +1,4 @@
type Foo2 = {
bar: boolean;
baz: string;
};
File renamed without changes.

0 comments on commit 559b96f

Please sign in to comment.