添加tslint检测d.ts规范

This commit is contained in:
yangdan8 2019-03-20 13:04:50 +08:00
parent 1011bd411a
commit f6ca27da30
4 changed files with 285 additions and 132 deletions

View file

@ -29,8 +29,9 @@
"dist:locale": "webpack --config build/webpack.dist.locale.config.js",
"dist": "npm run dist:style && npm run dist:dev && npm run dist:prod && npm run dist:locale",
"lint": "eslint --fix --ext .js,.vue src",
"tslint": "tslint --type-check --fix --project .",
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
"test": "npm run lint && npm run unit",
"test": "npm run lint && npm run tslint && npm run unit",
"prepare": "npm run dist"
},
"repository": {
@ -103,6 +104,7 @@
"sinon": "^4.4.2",
"sinon-chai": "^3.3.0",
"style-loader": "^0.20.2",
"tslint": "^5.14.0",
"uglifyjs-webpack-plugin": "^1.3.0",
"url-loader": "^1.1.2",
"vue": "^2.5.17",

24
tsconfig.json Normal file
View file

@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": ["node"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"types/*.ts",
],
"exclude": ["node_modules"]
}

127
tslint.json Normal file
View file

@ -0,0 +1,127 @@
{
"defaultSeverity": "warning",
"extends": ["tslint:recommended"],
"linterOptions": {
"exclude": ["node_modules/**"]
},
"rules": {
"jsx-boolean-value": false,
"jsx-curly-spacing": false,
"jsx-no-multiline-js": false,
"jsx-wrap-multiline": false,
"jsx-alignment": false,
"jsx-no-lambda": true,
"jsx-no-string-ref": false,
"class-name": false,
"max-line-length": [true, 180],
"member-ordering": [true, "statics-first"],
"new-parens": true,
"no-consecutive-blank-lines": true,
"no-mergeable-namespace": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-variable": [true],
"no-var-keyword": true,
"one-variable-per-declaration": [false, "ignore-for-loop"],
"triple-equals": [false, "allow-null-check"],
"use-isnan": false,
//ts
"prefer-const": false, //true, //const
"adjacent-overload-signatures": true, //Enforces function overloads to be consecutive.
"ban-comma-operator": true, //
"ban-type": [true, ["object", "User {} instead."], ["string"]], //
//"member-access": [true, "no-public" || "check-accessor" || "check-constructor" || "check-parameter-property"], // private public ....
"member-order": [false], //
"no-any": false, //true, //使any
"no-empty-interface": true, // {}
"no-import-side-effect": [
true,
{
"ignore-module": "(\\.html|\\.css)$"
}
], //
"no-inferrable-types": [true, "ignore-params", "ignore-properties"], //,
"no-internal-module": true, //
"no-magic-numbers": false, //[true, 1, 2, 3], //使,-1,01
"no-namespace": false, //[true, "allpw-declarations"], //使modules
"no-non-null-assertion": true, //使!
"no-parameter-reassignment": false, //true, //
"no-reference": false, //true, // 使/// <reference path=> ,使import
"no-unnecessary-type-assertion": true, //
"no-var-requires": true, //使var module = require("module"), import foo = require('foo')
"only-arrow-functions": false, //[true, "allow-declarations", "allow-named-functions"], //, ,function foo() {}function() {}
"prefer-for-of": true, //使for(..of)
"promise-function-async": true, //promise
"typedef": false, //[true, "call-signature", "parameter", "member-variable-declaration"], //
"typedef-whitespace": true, //,使, 使false,
"unified-signatures": true, //
//function
"await-promise": true, //promiseawait
// "ban": [
// true,
// "eval",
// {
// "name": "$",
// "message": "please don't"
// },
// ["describe", "only"],
// {
// "name": ["it", "only"],
// "message": "don't focus tests"
// },
// {
// "name": ["chai", "assert", "equal"],
// "message": "Use 'strictEqual' instead."
// },
// {
// "name": ["*", "forEach"],
// "message": "Use a regular for loop instead."
// }
// ],
"curly": true, //for if do while
"forin": false, //true, //for in if
"import-blacklist": true, //使import require
"label-postion": true, //do/for/while/swith使label
"no-arg": true, //使 argument.callee
"no-bitwise": false, //true, //使
"no-conditional-assignmen": true, //do-while/for/if/while使
"no-console": [true, "time", "timeEnd"], //使console
"no-construct": true, //使 String/Number/Boolean
"no-debugger": true, //使debugger
"no-duplicate-super": true, //super
"no-empty": false, //true, //
"no-eval": true, //使eval
"no-floating-promises": true, //promise
"no-for-in-array": true, //使for in
"no-implicit-dependencies": true, //package.json
"no-inferred-empty-object-type": true, //使{}
"no-invalid-template-strings": true, //使${
"no-invalid-this": false, //true, //class使 this
"no-misused-new": true, //new class
"no-null-keyword": false, // true, //使null
"no-object-literal-type-assertion": false, //true, //objext
"no-return-await": true, //return await
"arrow-parens": false, //true, //
"quotemark": [true, "single", "jsx-double", "avoid-escape"], //使
"semicolon": false, //[true, "never", "ignore-interfaces"], //使
"indent": false, //[true, "tabs", 2], //使Tab2
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-type"
], //
"member-access": false, //public | static
"one-line": false //, //
// "trailing-comma": [true, { //
// "multiline": {
// "objects": "ignore",
// "arrays": "never",
// "functions": "never",
// "typeLiterals": "ignore"
// },
//"esSpecCompliant": true //
// }]
}
}

2
types/layout.d.ts vendored
View file

@ -70,4 +70,4 @@ export declare interface Layout extends Vue {
* methods, Sider展开-
*/
toggleCollapse(): void;
}·
}