tslint-config-valorsoft v2.2.1
Welcome to the most strict tslint config ever
Follow me to be notified about new releases.
Philosophy
- contains all rules explicitly
- almost all rules enabled
Before install
Check version of your code editor, highly recommended to use latest version.
If you use angular-cli:
- check that you have latest version, at least 1.0.2, and local and global versions of cli are the same.
- disable ts lint for polyfill.ts and test.ts(in
srcfolder). Add/* tslint:disable */at the beginning. For more info: https://palantir.github.io/tslint/usage/rule-flags/
Install
- Install package
npm install -D tslint-config-valorsoft- check install log for errors and warnings about wrong versions of required packages (tslint, codelyzer etc.)
- if needed install or update required packages
- Example. You can have this situation in the end of log after installing:
npm WARN tslint-config-valorsoft@2.0.0 requires a peer of codelyzer@^3.0.0 but none was installed.
npm WARN tslint-config-valorsoft@2.0.0 requires a peer of tslint@^5.1.0 but none was installed.It means that you have to update codelyzer and tslint to ^3.0.0 and ^5.1.0 versions (or higher).
- Edit your tslint.json:
- add
"extends": "tslint-config-valorsoft"or"extends": ["tslint-config-valorsoft", "tslint-config-valorsoft/tslint-angular.json"],for angular projects at the beginning, beforerulesDirectory - remove all rules inside
"rules"object - add your custom rules
- add rules with editable shortname of your project.
"component-selector": [true, "element", "MP", "kebab-case"],
"directive-selector": [true, "attribute", "MP", "camelCase"],
"pipe-naming": [true, "camelCase", "MP"]Note: MP is a placeholder, it is your prefix for components. If you don't need it you should change MP to empty string - [true, "camelCase", ""]
Example:
// tslint.json
{
"extends": ["tslint-config-valorsoft", "tslint-config-valorsoft/tslint-angular.json"],
"rulesDirectory": "node_modules/codelyzer",
"rules": {
// your customization
// THIS IS IMPORTANT
// ADD THIS RULES TO YOUR `tslint.json`
// AND CHANGE `MP` with short name of your project
"directive-selector": [true, "attribute", "MP", "camelCase"],
"component-selector": [true, "element", "MP", "kebab-case"],
"pipe-naming": [true, "camelCase", "MP"]
}
}After install
Setup lint command:
- add
--type-checkparameter to lint command inpackage.json. Example:"lint": "ng lint --type-check";
Note: If you have warning Warning: Cannot read property 'some' of undefined after running tslint, update
codelyzer and tslint to latest versions. For now they are codelyzer@^3.0.1 and tslint@^5.2.0
You could configure:
ban-types- https://palantir.github.io/tslint/rules/ban-types/ban- https://palantir.github.io/tslint/rules/ban/import-blacklist- https://palantir.github.io/tslint/rules/import-blacklist/
Disabled:
no-parameter-propertiesbecause it is very convenient to useconstructor(private inject:Service)no-null-keywordnull should be used to clean referencesno-require-imports-requireis sometimes usefulobject-literal-sort-keysnot really usefulcompleted-docsforcing writing a docs, usually leads to low or harmful copy paste style documentationfile-headerup to youno-parameter-propertiesreading the docs is the best way to avoid confusionprefer-for-ofbad performanceprefer-object-spreadbad performanceno-magic-numbersup to you
TBD:
promise-function-asynchttps://palantir.github.io/tslint/rules/promise-function-async/strict-boolean-expressionshttps://palantir.github.io/tslint/rules/strict-boolean-expressions/no-boolean-literal-comparehttps://palantir.github.io/tslint/rules/no-boolean-literal-compare/
What is disabled
no-eq-null- duplicateseqeqeq:smartno-restricted-imports,no-restricted-modules,no-restricted-globals- dependant on project requirementsid-match- not found any particular use of this rule,camelCaseis enoughjsx-quotes- I don't use jsx so I don't careno-plusplus- why not++? It's nice to use when you know what you are doingno-restricted-syntax- duplicatesno-withand disabled functional expressionsno-ternary- why not? but not nested ternary pleaserequire-jsdoc- nice thing, but hard to followspaced-comment- nice for meaningful comments, bad for quick code commentingwrap-regex- no needprefer-reflect- compatibility is to low to usenewline-before-return- TBD
What is tweaked
indent- 2 spaces rulezzz!max-len- extended to 120 charsnewline-per-chained-call- extendedignoreChainWithDepthto 3eqeqeq-smartmode enableddot-location-propertymode enabledno-implicit-coercion- boolean implicit coercion enabledfunc-style-declarationonly pleaseno-use-before-define- usage offunctionbefore declarations are allowedno-mixed-requires-groupingandallowCallchecks enabledlinebreak-style- unix onlyone-var-neveruse onevar|let|constper blockpadded-blocks-neveradd useless paddingquote-props- quote properties onlyas-neededandkeywordsno-magic-numbers-ignore-1,0,1as most often used numbers andignoreArrayIndexes,enforceConstare enabled -->
Contribution
- what I really appreciate is configs for IDEs
- to change any rule you should have strong arguments and not only opinion
LICENSE
MIT
7 years ago
7 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago