精华内容
下载资源
问答
  • TSLint 规则

    2020-06-15 19:35:28
    除了在全局配置中使用TSLint规则,还可以在文件中使用TSLint规则。所以在不方便修改全局配置中的TSLint规则时,可以在文件中对TSLint规则进行调整。

    除了在全局配置中使用TSLint规则,还可以在文件中使用TSLint规则。

    当不想修改全局配置中的TSLint规则时,可以在文件中使用以下注释规则标志对TSLint规则进行修改。


    // tslint:disable —— 忽略该行以下所有代码出现的错误提示,可以在文件首行添加达到忽略整个文件的格式提示。


    /* tslint:enable */ —— 为当前文件启动所有规则。


    // tslint:disable-line —— 忽略当前行代码出现的错误提示。


    // tslint:disable-next-line —— 忽略下一行代码出现的错误提示。

    // tslint:disable-next-line:rule1 rule2 rule3 —— 忽略下一行代码中出现的rule1、rule2、rule3。
    (当有多条规则检查需要进行忽略时,多条规则之间用空格隔开)


    展开全文
  • tslint 检查规则

    2017-11-21 11:11:00
    tslint是一个可扩展的静态分析工具,检查 ...它广泛支持在现代编辑和编译系统,可以自定义编码规则,配置,和格式化。 目前写的前端工程都加入了tslint检查,大致了解下这个东东的功能 git 地址:https://github.c...

    tslint是一个可扩展的静态分析工具,检查 typescript 代码的可读性、可维护性和功能上的错误。它广泛支持在现代编辑和编译系统,可以自定义编码规则,配置,和格式化。

    目前写的前端工程都加入了tslint检查,大致了解下这个东东的功能

    git 地址:https://github.com/palantir/tslint

    tslint 核心规则:https://palantir.github.io/tslint/rules/

    转载于:https://my.oschina.net/u/2499632/blog/1576518

    展开全文
  • TS Eslint规则说明

    2020-01-14 12:05:59
    "no-irregular-whitespace": 2,//不能有不规则的空格 "no-iterator": 2,//禁止使用__iterator__ 属性 "no-label-var": 2,//label名不能与var声明的变量名相同 "no-labels": 2,//禁止标签声明 "no-lone-blocks": ...

    "no-alert": 0,//禁止使用alert confirm prompt
    "no-array-constructor": 2,//禁止使用数组构造器
    "no-bitwise": 0,//禁止使用按位运算符
    "no-caller": 1,//禁止使用arguments.caller或arguments.callee
    "no-catch-shadow": 2,//禁止catch子句参数与外部作用域变量同名
    "no-class-assign": 2,//禁止给类赋值
    "no-cond-assign": 2,//禁止在条件表达式中使用赋值语句
    "no-console": 2,//禁止使用console
    "no-const-assign": 2,//禁止修改const声明的变量
    "no-constant-condition": 2,//禁止在条件中使用常量表达式 if(true) if(1)
    "no-continue": 0,//禁止使用continue
    "no-control-regex": 2,//禁止在正则表达式中使用控制字符
    "no-debugger": 2,//禁止使用debugger
    "no-delete-var": 2,//不能对var声明的变量使用delete操作符
    "no-div-regex": 1,//不能使用看起来像除法的正则表达式/=foo/
    "no-dupe-keys": 2,//在创建对象字面量时不允许键重复 {a:1,a:1}
    "no-dupe-args": 2,//函数参数不能重复
    "no-duplicate-case": 2,//switch中的case标签不能重复
    "no-else-return": 2,//如果if语句里面有return,后面不能跟else语句
    "no-empty": 2,//块语句中的内容不能为空
    "no-empty-character-class": 2,//正则表达式中的[]内容不能为空
    "no-empty-label": 2,//禁止使用空label
    "no-eq-null": 2,//禁止对null使用==或!=运算符
    "no-eval": 1,//禁止使用eval
    "no-ex-assign": 2,//禁止给catch语句中的异常参数赋值
    "no-extend-native": 2,//禁止扩展native对象
    "no-extra-bind": 2,//禁止不必要的函数绑定
    "no-extra-boolean-cast": 2,//禁止不必要的bool转换
    "no-extra-parens": 2,//禁止非必要的括号
    "no-extra-semi": 2,//禁止多余的冒号
    "no-fallthrough": 1,//禁止switch穿透
    "no-floating-decimal": 2,//禁止省略浮点数中的0 .5 3.
    "no-func-assign": 2,//禁止重复的函数声明
    "no-implicit-coercion": 1,//禁止隐式转换
    "no-implied-eval": 2,//禁止使用隐式eval
    "no-inline-comments": 0,//禁止行内备注
    "no-inner-declarations": [2, "functions"],//禁止在块语句中使用声明(变量或函数)
    "no-invalid-regexp": 2,//禁止无效的正则表达式
    "no-invalid-this": 2,//禁止无效的this,只能用在构造器,类,对象字面量
    "no-irregular-whitespace": 2,//不能有不规则的空格
    "no-iterator": 2,//禁止使用__iterator__ 属性
    "no-label-var": 2,//label名不能与var声明的变量名相同
    "no-labels": 2,//禁止标签声明
    "no-lone-blocks": 2,//禁止不必要的嵌套块
    "no-lonely-if": 2,//禁止else语句内只有if语句
    "no-loop-func": 1,//禁止在循环中使用函数(如果没有引用外部变量不形成闭包就可以)
    "no-mixed-requires": [0, false],//声明时不能混用声明类型
    "no-mixed-spaces-and-tabs": [2, false],//禁止混用tab和空格
    "linebreak-style": [0, "windows"],//换行风格
    "no-multi-spaces": 1,//不能用多余的空格
    "no-multi-str": 2,//字符串不能用\换行
    "no-multiple-empty-lines": [1, {"max": 2}],//空行最多不能超过2行
    "no-native-reassign": 2,//不能重写native对象
    "no-negated-in-lhs": 2,//in 操作符的左边不能有!
    "no-nested-ternary": 0,//禁止使用嵌套的三目运算
    "no-new": 1,//禁止在使用new构造一个实例后不赋值
    "no-new-func": 1,//禁止使用new Function
    "no-new-object": 2,//禁止使用new Object()
    "no-new-require": 2,//禁止使用new require
    "no-new-wrappers": 2,//禁止使用new创建包装实例,new String new Boolean new Number
    "no-obj-calls": 2,//不能调用内置的全局对象,比如Math() JSON()
    "no-octal": 2,//禁止使用八进制数字
    "no-octal-escape": 2,//禁止使用八进制转义序列
    "no-param-reassign": 2,//禁止给参数重新赋值
    "no-path-concat": 0,//node中不能使用__dirname或__filename做路径拼接
    "no-plusplus": 0,//禁止使用++,--
    "no-process-env": 0,//禁止使用process.env
    "no-process-exit": 0,//禁止使用process.exit()
    "no-proto": 2,//禁止使用__proto__属性
    "no-redeclare": 2,//禁止重复声明变量
    "no-regex-spaces": 2,//禁止在正则表达式字面量中使用多个空格 /foo bar/
    "no-restricted-modules": 0,//如果禁用了指定模块,使用就会报错
    "no-return-assign": 1,//return 语句中不能有赋值表达式
    "no-script-url": 0,//禁止使用javascript:void(0)
    "no-self-compare": 2,//不能比较自身
    "no-sequences": 0,//禁止使用逗号运算符
    "no-shadow": 2,//外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
    "no-shadow-restricted-names": 2,//严格模式中规定的限制标识符不能作为声明时的变量名使用
    "no-spaced-func": 2,//函数调用时 函数名与()之间不能有空格
    "no-sparse-arrays": 2,//禁止稀疏数组, [1,,2]
    "no-sync": 0,//nodejs 禁止同步方法
    "no-ternary": 0,//禁止使用三目运算符
    "no-trailing-spaces": 1,//一行结束后面不要有空格
    "no-this-before-super": 0,//在调用super()之前不能使用this或super
    "no-throw-literal": 2,//禁止抛出字面量错误 throw "error";
    "no-undef": 1,//不能有未定义的变量
    "no-undef-init": 2,//变量初始化时不能直接给它赋值为undefined
    "no-undefined": 2,//不能使用undefined
    "no-unexpected-multiline": 2,//避免多行表达式
    "no-underscore-dangle": 1,//标识符不能以_开头或结尾
    "no-unneeded-ternary": 2,//禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
    "no-unreachable": 2,//不能有无法执行的代码
    "no-unused-expressions": 2,//禁止无用的表达式
    "no-unused-vars": [2, {"vars": "all", "args": "after-used"}],//不能有声明后未被使用的变量或参数
    "no-use-before-define": 2,//未定义前不能使用
    "no-useless-call": 2,//禁止不必要的call和apply
    "no-void": 2,//禁用void操作符
    "no-var": 0,//禁用var,用let和const代替
    "no-warning-comments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],//不能有警告备注
    "no-with": 2,//禁用with

    "array-bracket-spacing": [2, "never"],//是否允许非空数组里面有多余的空格
    "arrow-parens": 0,//箭头函数用小括号括起来
    "arrow-spacing": 0,//=>的前/后括号
    "accessor-pairs": 0,//在对象中使用getter/setter
    "block-scoped-var": 0,//块语句中使用var
    "brace-style": [1, "1tbs"],//大括号风格
    "callback-return": 1,//避免多次调用回调什么的
    "camelcase": 2,//强制驼峰法命名
    "comma-dangle": [2, "never"],//对象字面量项尾不能有逗号
    "comma-spacing": 0,//逗号前后的空格
    "comma-style": [2, "last"],//逗号风格,换行时在行首还是行尾
    "complexity": [0, 11],//循环复杂度
    "computed-property-spacing": [0, "never"],//是否允许计算后的键名什么的
    "consistent-return": 0,//return 后面是否允许省略
    "consistent-this": [2, "that"],//this别名
    "constructor-super": 0,//非派生类不能调用super,派生类必须调用super
    "curly": [2, "all"],//必须使用 if(){} 中的{}
    "default-case": 2,//switch语句最后必须有default
    "dot-location": 0,//对象访问符的位置,换行的时候在行首还是行尾
    "dot-notation": [0, { "allowKeywords": true }],//避免不必要的方括号
    "eol-last": 0,//文件以单一的换行符结束
    "eqeqeq": 2,//必须使用全等
    "func-names": 0,//函数表达式必须有名字
    "func-style": [0, "declaration"],//函数风格,规定只能使用函数声明/函数表达式
    "generator-star-spacing": 0,//生成器函数*的前后空格
    "guard-for-in": 0,//for in循环要用if语句过滤
    "handle-callback-err": 0,//nodejs 处理错误
    "id-length": 0,//变量名长度
    "indent": [2, 4],//缩进风格
    "init-declarations": 0,//声明时必须赋初值
    "key-spacing": [0, { "beforeColon": false, "afterColon": true }],//对象字面量中冒号的前后空格
    "lines-around-comment": 0,//行前/行后备注
    "max-depth": [0, 4],//嵌套块深度
    "max-len": [0, 80, 4],//字符串最大长度
    "max-nested-callbacks": [0, 2],//回调嵌套深度
    "max-params": [0, 3],//函数最多只能有3个参数
    "max-statements": [0, 10],//函数内最多有几个声明
    "new-cap": 2,//函数名首行大写必须使用new方式调用,首行小写必须用不带new方式调用
    "new-parens": 2,//new时必须加小括号
    "newline-after-var": 2,//变量声明后是否需要空一行
    "object-curly-spacing": [0, "never"],//大括号内是否允许不必要的空格
    "object-shorthand": 0,//强制对象字面量缩写语法
    "one-var": 1,//连续声明
    "operator-assignment": [0, "always"],//赋值运算符 += -=什么的
    "operator-linebreak": [2, "after"],//换行时运算符在行尾还是行首
    "padded-blocks": 0,//块语句内行首行尾是否要空行
    "prefer-const": 0,//首选const
    "prefer-spread": 0,//首选展开运算
    "prefer-reflect": 0,//首选Reflect的方法
    "quotes": [1, "single"],//引号类型 `` "" ''
    "quote-props":[2, "always"],//对象字面量中的属性名是否强制双引号
    "radix": 2,//parseInt必须指定第二个参数
    "id-match": 0,//命名检测
    "require-yield": 0,//生成器函数必须有yield
    "semi": [2, "always"],//语句强制分号结尾
    "semi-spacing": [0, {"before": false, "after": true}],//分号前后空格
    "sort-vars": 0,//变量声明时排序
    "space-after-keywords": [0, "always"],//关键字后面是否要空一格
    "space-before-blocks": [0, "always"],//不以新行开始的块{前面要不要有空格
    "space-before-function-paren": [0, "always"],//函数定义时括号前面要不要有空格
    "space-in-parens": [0, "never"],//小括号里面要不要有空格
    "space-infix-ops": 0,//中缀操作符周围要不要有空格
    "space-return-throw-case": 2,//return throw case后面要不要加空格
    "space-unary-ops": [0, { "words": true, "nonwords": false }],//一元运算符的前/后要不要加空格
    "spaced-comment": 0,//注释风格要不要有空格什么的
    "strict": 2,//使用严格模式
    "use-isnan": 2,//禁止比较时使用NaN,只能用isNaN()
    "valid-jsdoc": 0,//jsdoc规则
    "valid-typeof": 2,//必须使用合法的typeof的值
    "vars-on-top": 2,//var必须放在作用域顶部
    "wrap-iife": [2, "inside"],//立即执行函数表达式的小括号风格
    "wrap-regex": 0,//正则表达式字面量用小括号包起来
    "yoda": [2, "never"]//禁止尤达条件

    展开全文
  • TSLint 配置规则

    万次阅读 2019-01-31 19:27:03
    TSLint core rules Lint rules encode logic for syntactic & semantic checks of TypeScript source code. TypeScript-specific These rules find errors related to TypeScript features: ...

    TSLint core rules

    原文:https://palantir.github.io/tslint/rules/

    Lint rules encode logic for syntactic & semantic checks of TypeScript source code.

    TypeScript-specific

    These rules find errors related to TypeScript features:

    adjacent-overload-signatures - Enforces function overloads to be consecutive.

    ban-ts-ignore - Bans “// @ts-ignore” comments from being used.

    ban-types - Bans specific types from being used. Does not ban the corresponding runtime objects from being used.

    member-access - Requires explicit visibility declarations for class members.

    member-ordering - Enforces member ordering.

    no-any - Disallows usages of any as a type declaration.

    no-empty-interface - Forbids empty interfaces.
    no-import-side-effect - Avoid import statements with side-effect.

    no-inferrable-types - Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean.

    no-internal-module - Disallows internal module
    no-magic-numbers - Disallows the use constant number values outside of variable assignments. When no list of allowed values is specified, -1, 0 and 1 are allowed by default.

    no-namespace - Disallows use of internal modules and namespaces.

    no-non-null-assertion - Disallows non-null assertions using the ! postfix operator.
    no-parameter-reassignment - Disallows reassigning parameters.
    no-reference - Disallows /// <reference path=> imports (use ES6-style imports instead).

    Requires Type Info
    no-unnecessary-type-assertion - Warns if a type assertion does not change the type of an expression.

    no-var-requires - Disallows the use of require statements except in import statements.
    only-arrow-functions - Disallows traditional (non-arrow) function expressions.
    prefer-for-of - Recommends a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated.
    Requires Type Info
    promise-function-async - Requires any function or method that returns a promise to be marked async.

    typedef - Requires type definitions to exist.

    typedef-whitespace - Requires or disallows whitespace for type definitions.

    unified-signatures - Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter.
    Functionality
    These rules catch common errors in JS programming or otherwise confusing constructs that are prone to producing bugs:

    Requires Type Info
    await-promise - Warns for an awaited value that is not a Promise.
    ban-comma-operator - Disallows the comma operator to be used.
    ban - Bans the use of specific functions or global methods.

    curly - Enforces braces for if/for/do/while statements.
    forin - Requires a for … in statement to be filtered with an if statement.
    function-constructor - Prevents using the built-in Function constructor.
    import-blacklist - Disallows importing the specified modules via import and require, or importing specific named exports of the specified modules.
    label-position - Only allows labels in sensible locations.
    no-arg - Disallows use of arguments.callee.
    no-bitwise - Disallows bitwise operators.
    no-conditional-assignment - Disallows any type of assignment in conditionals.
    no-console - Bans the use of specified console methods.
    no-construct - Disallows access to the constructors of String, Number, and Boolean.
    no-debugger - Disallows debugger statements.
    no-duplicate-super - Warns if ‘super()’ appears twice in a constructor.
    no-duplicate-switch-case - Prevents duplicate cases in switch statements.
    no-duplicate-variable - Disallows duplicate variable declarations in the same block scope.
    no-dynamic-delete - Bans usage of the delete operator with computed key expressions.
    no-empty - Disallows empty blocks.
    no-eval - Disallows eval function invocations.

    Requires Type Info
    no-floating-promises - Promises returned by functions must be handled appropriately.
    Requires Type Info
    no-for-in-array - Disallows iterating over an array with a for-in loop.
    no-implicit-dependencies - Disallows importing modules that are not listed as dependency in the project’s package.json

    Requires Type Info
    no-inferred-empty-object-type - Disallow type inference of {} (empty object type) at function and constructor call sites
    no-invalid-template-strings - Warns on use of ${ in non-template strings.
    no-invalid-this - Disallows using the this keyword outside of classes.

    no-misused-new - Warns on apparent attempts to define constructors for interfaces or new for classes.

    no-null-keyword - Disallows use of the null keyword literal.

    no-object-literal-type-assertion - Forbids an object literal to appear in a type assertion expression. Casting to any or to unknown is still allowed.

    no-return-await - Disallows unnecessary return await.
    no-shadowed-variable - Disallows shadowing variable declarations.
    no-sparse-arrays - Forbids array literals to contain missing elements.

    no-string-literal - Forbids unnecessary string literal property access. Allows obj[“prop-erty”] (can’t be a regular property access). Disallows obj[“property”] (should be obj.property).

    no-string-throw - Flags throwing plain strings or concatenations of strings.
    no-submodule-imports - Disallows importing any submodule.
    no-switch-case-fall-through - Disallows falling through case statements.
    no-this-assignment - Disallows unnecessary references to this.

    Requires Type Info
    no-unbound-method - Warns when a method is used outside of a method call.
    no-unnecessary-class - Disallows classes that are not strictly necessary.

    Requires Type Info
    no-unsafe-any - Warns when using an expression of type ‘any’ in a dynamic way. Uses are only allowed if they would work for {} | null | undefined. Type casts and tests are allowed. Expressions that work on all values (such as “” + x) are allowed.
    no-unsafe-finally - Disallows control flow statements, such as return, continue, break and throws in finally blocks.
    no-unused-expression - Disallows unused expression statements.

    Requires Type Info
    no-unused-variable - Disallows unused imports, variables, functions and private class members. Similar to tsc’s –noUnusedParameters and –noUnusedLocals options, but does not interrupt code compilation.
    Requires Type Info
    no-use-before-declare - Disallows usage of variables before their declaration.

    no-var-keyword - Disallows usage of the var keyword.
    Requires Type Info
    no-void-expression - Requires expressions of type void to appear in statement position.
    prefer-conditional-expression - Recommends to use a conditional expression instead of assigning to the same thing in each branch of an if statement.

    prefer-object-spread - Enforces the use of the ES2018 object spread operator over Object.assign() where appropriate.
    radix - Requires the radix parameter to be specified when calling parseInt.
    Requires Type Info
    restrict-plus-operands - When adding two variables, operands must both be of type number or of type string.

    Requires Type Info
    strict-boolean-expressions - Restricts the types allowed in boolean expressions. By default only booleans are allowed. The following nodes are checked:
    Arguments to the !, &&, and || operators
    The condition in a conditional expression (cond ? x : y)
    Conditions for if, for, while, and do-while statements.

    Requires Type Info
    strict-type-predicates - Warns for type predicates that are always true or always false. Works for ‘typeof’ comparisons to constants (e.g. ‘typeof foo === “string”’), and equality comparison to ‘null’/’undefined’. (TypeScript won’t let you compare ‘1 === 2’, but it has an exception for ‘1 === undefined’.) Does not yet work for ‘instanceof’. Does not warn for ‘if (x.y)’ where ‘x.y’ is always truthy. For that, see strict-boolean-expressions. This rule requires strictNullChecks to work properly.
    switch-default - Require a default case in all switch statements.
    triple-equals - Requires === and !== in place of == and !=.
    typeof-compare - Makes sure result of typeof is compared to correct string values
    unnecessary-constructor - Prevents blank constructors, as they are redundant.

    Requires Type Info
    use-default-type-parameter - Warns if an explicitly specified type argument is the default for that type parameter.
    use-isnan - Enforces use of the isNaN() function to check for NaN references instead of a comparison to the NaN constant.
    Maintainability
    These rules make code maintenance easier:

    cyclomatic-complexity - Enforces a threshold of cyclomatic complexity.
    Requires Type Info
    deprecation - Warns when deprecated APIs are used.

    eofline - Ensures the file ends with a newline.

    indent - Enforces indentation with tabs or spaces.

    linebreak-style - Enforces a consistent linebreak style.
    max-classes-per-file - A file may not contain more than the specified number of classes
    max-file-line-count - Requires files to remain under a certain number of lines
    max-line-length - Requires lines to be under a certain max length.
    no-default-export - Disallows default exports in ES6-style modules.
    no-default-import - Disallows importing default members from certain ES6-style modules.
    no-duplicate-imports - Disallows multiple import statements from the same module.

    no-mergeable-namespace - Disallows mergeable namespaces in the same file.
    no-require-imports - Disallows invocation of require().
    object-literal-sort-keys - Checks ordering of keys in object literals. When using the default alphabetical ordering, additional blank lines may be used to group object properties together while keeping the elements within each group in alphabetical order.

    prefer-const - Requires that variable declarations use const instead of let and var if possible.

    Requires Type Info
    prefer-readonly - Requires that private variables are marked as readonly if they’re never modified outside of the constructor.

    trailing-comma - Requires or disallows trailing commas in array and object literals, destructuring assignments, function typings, named imports and exports and function parameters.
    Style
    These rules enforce consistent style across your codebase:

    align - Enforces vertical alignment.

    array-type - Requires using either ‘T[]’ or ‘Array’ for arrays.

    arrow-parens - Requires parentheses around the parameters of arrow function definitions.

    arrow-return-shorthand - Suggests to convert () => { return x; } to () => x.
    binary-expression-operand-order - In a binary expression, a literal should always be on the right-hand side if possible. For example, prefer ‘x + 1’ over ‘1 + x’.

    callable-types - An interface or literal type with just a call signature can be written as a function type.
    class-name - Enforces PascalCased class and interface names.

    comment-format - Enforces formatting rules for single-line comments.
    comment-type - Allows a limited set of comment types
    Requires Type Info
    completed-docs - Enforces JSDoc comments for important items be filled out.
    encoding - Enforces UTF-8 file encoding.

    file-header - Enforces a certain header comment for all files, matched by a regular expression.
    file-name-casing - Enforces a consistent file naming convention
    import-spacing - Ensures proper spacing between import statement keywords
    increment-decrement - Enforces using explicit += 1 or -= 1 operators.

    interface-name - Requires interface names to begin with a capital ‘I’

    interface-over-type-literal - Prefer an interface declaration over a type literal (type T = { … })
    jsdoc-format - Enforces basic format rules for JSDoc comments.

    Requires Type Info
    match-default-export-name - Requires that a default import have the same name as the declaration it imports. Does nothing for anonymous default exports.
    newline-before-return - Enforces blank line before return when not the only line in the block.
    newline-per-chained-call - Requires that chained method calls be broken apart onto separate lines.
    new-parens - Requires parentheses when invoking a constructor via the new keyword.

    no-angle-bracket-type-assertion - Requires the use of as Type for type assertions instead of .

    Requires Type Info
    no-boolean-literal-compare - Warns on comparison to a boolean literal, as in x === true.

    no-consecutive-blank-lines - Disallows one or more blank lines in a row.

    no-irregular-whitespace - Disallow irregular whitespace within a file, including strings and comments.

    no-parameter-properties - Disallows parameter properties in class constructors.

    no-redundant-jsdoc - Forbids JSDoc which duplicates TypeScript functionality.

    no-reference-import - Don’t if you import foo anyway.

    no-trailing-whitespace - Disallows trailing whitespace at the end of a line.
    no-unnecessary-callback-wrapper - Replaces x => f(x) with just f. To catch more cases, enable only-arrow-functions and arrow-return-shorthand too.

    no-unnecessary-initializer - Forbids a ‘var’/’let’ statement or destructuring initializer to be initialized to ‘undefined’.

    Requires Type Info
    no-unnecessary-qualifier - Warns when a namespace qualifier (A.x) is unnecessary.
    number-literal-format - Checks that decimal literals should begin with ‘0.’ instead of just ‘.’, and should not end with a trailing ‘0’.

    object-literal-key-quotes - Enforces consistent object literal property quote style.

    object-literal-shorthand - Enforces/disallows use of ES6 object literal shorthand.

    one-line - Requires the specified tokens to be on the same line as the expression preceding them.
    one-variable-per-declaration - Disallows multiple variable definitions in the same declaration statement.

    ordered-imports - Requires that import statements be alphabetized and grouped.
    prefer-function-over-method - Warns for class methods that do not use ‘this’.

    prefer-method-signature - Prefer foo(): void over foo: () => void in interfaces and types.
    prefer-switch - Prefer a switch statement to an if statement with simple === comparisons.
    prefer-template - Prefer a template expression over string literal concatenation.

    prefer-while - Prefer while loops instead of for loops without an initializer and incrementor.

    quotemark - Enforces quote character for string literals.
    Requires Type Info
    return-undefined - Prefer return; in void functions and return undefined; in value-returning functions.

    semicolon - Enforces consistent semicolon usage at the end of every statement.

    space-before-function-paren - Require or disallow a space before function parenthesis

    space-within-parens - Enforces spaces within parentheses or disallow them. Empty parentheses () are always allowed.

    switch-final-break - Checks whether the final clause of a switch statement ends in break;.

    type-literal-delimiter - Checks that type literal members are separated by semicolons. Enforces a trailing semicolon for multiline type literals.
    Requires Type Info
    unnecessary-bind - Prevents unnecessary and/or misleading scope bindings on functions.
    variable-name - Checks variable names for various errors.

    whitespace - Enforces whitespace style conventions.

    展开全文
  • 本文将通过一个简单的例子介绍如何为 TSLint 编写自定义规则,在开始之前默认读者对 Typescript 有所了解。本文例子源码前言它是什么?与 ESLint 一样属于程序静态分析工具(linter),不过因为 Typescript 与 ...
  • tslint不可变的 规则禁用TypeScript中的突变。 :warning_selector: TSLint将在2019年的某个时候被弃用。 有关更多详细信息,问题: 。 :rocket: 已经开始在库这些规则移植到新的eslint插件上。 请到那边给它一...
  • NativeScript TSLint规则 该项目包含对NativeScript应用程序有用的tslint规则。 prefer-mapped-imports规则 导入外部模块或ES6导入声明时,建议使用映射路径。 注意:此规则适用于 选件 prefix指定映射的导入的...
  • 从Angular库的提取的有用的TSLint规则。 安装 # npm npm i -D ng-tslint # yarn yarn add -D ng-tslint 规则 类列表签名 该规则捕获使用classList情况无法在我们支持的所有浏览器中使用的情况。 强制类型 TSLint...
  • TSLint导入组排序规则 强制进口组订购 高度可配置 使用正则表达式配置哪些导入语句进入哪个导入组。 支持确定package.json依赖项(或从node_modules读取所有依赖node_modules ) 有一个自动修复程序 保留评论 ...
  • TSLint挂钩规则 一个TSLint规则,用于为React挂钩强制实施。 该规则基于的。 产品特点 在潜在条件分支内检测使用React钩子: 如果陈述 短路条件表达式( && , || ) 三元表达式 循环( while , for , do ... ...
  • TSLint JSX必需属性规则 tslint的自定义规则 当JSX元素匹配指定的元素类型或指定的属性时,要求它们包含指定的属性。 npm i -D tslint-jsx-required-attributes tslint.json "rulesDirectory" : [ "node_...
  • TSLint规则,用于检测React Hooks的无效使用
  • 在某些Microsoft项目上使用的一组规则。 注意 该项目处于只读和模式。 安装 npm install tslint-microsoft-contrib --save-dev TSLint和相应的tslint-microsoft-contrib版本 TSLint版本 tslint-microsoft-contrib...
  • 一组用于ng-alain项目的静态代码分析tslint规则
  • codelyzer:一组用于Angular TypeScript项目静态代码分析的tslint规则
  • 与React&JSX相关的Lint规则。 用法 tslint-react对TSLint和TypeScript具有同级依赖。 要将这些lint规则与默认预设一起使用,请通过extends关键字使用配置继承。 这是一个示例配置,其中tslint.json与node_modules...
  • 带有规则规则TS模糊逻辑系统对一类非线性系统的自适应控制
  • 自定义TSlint检测规则

    2019-07-16 11:41:00
    不检测隐式类型 "arrow-parens": [ false, "as-needed" ], 转载于:https://www.cnblogs.com/liubingboke/p/11193900.html
  • TSLint重要规则Top 10

    2018-10-29 04:43:11
    详情参考ts手册函数部分的this小节。 no-namespace ES6风格的模块是模块化代码的标准方式。使用module {}和namespace {}来组织TypeScript代码是过时的方式。这里有一个webpack+ts示例项目。 no-var-key...
  • VSCode用格式化插件格式化.ts文件后,会将单引号转换成...想让tslint去掉这条规则怎么办呢? 按快捷键Ctrl+Shift+P,输入tslint,选择TSLint: Create a 'tslint.json' file打开配置文件 将"quotemark":[true,...
  • { "defaultSeverity": "warning", "extends": [ "tslint:recommended" ], "linterOptions": { "exclude": [ "node_modules/**"...
  • 本文将通过一个简单的例子介绍如何为 TSLint 编写自定义规则,在开始之前默认读者对 Typescript 有所了解。本文例子源码前言它是什么?与 ESLint 一样属于程序静态分析工具(linter),不过因为 Typescript 与 ...
  • 团队自定义 tslint & eslint 详细规则

    千次阅读 2018-07-01 04:44:45
    符合自身场景的就是最好...tslint.json { "defaultSeverity": "error", "extends": [ "tslint:recommended" ], "jsRules": { "no-unused-expression&quo
  • 另一个TSLint配置它禁用它已经被处理的所有规则 , , 或 。 将在2019年的某个时候被,但尚未完成。 因此,也许您将与它一起使用,然后两次重复执行lint代码会很糟糕,尤其是对于那些具有 , , 或等效规则规则 ...
  • ts

    2019-07-09 13:47:00
    ts文件中使用以下注释来临时忽略规则出现的错误。如在定义变量是为定义类型就报错误 // tslint:disable——忽略该行以下所有代码出现的错误提示 //tslint:enable——当前ts文件重新启用tslint //tslint:disable-...
  • } // index.ts(2,22): error TS2339: Property 'length' does not exist on type 'string | number'. // Property 'length' does not exist on type 'number'. 而有时候,我们确实需要在还不确定类型的时候就访问...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 464
精华内容 185
关键字:

ts规则