A collection of TypeScript & Angular lint rules for Terminus frontend codebases.
For ESLint configuration, see: https://github.com/GetTerminus/eslint-config-frontend
Table of Contents
$ yarn add tslint @terminus/tslint-config-frontend -D
There are 3 rulesets defined for TSLint:
no-non-null-assertion
, component naming requirements, etc).You will need to set up separate configs and scripts for each ruleset: ci
, development
and testing
. Creating a custom script call for
each within your package.json
will allow for easy composability of commands once all linters are set up.
Create a TSLint config file at the root level named tslint.ci.json
and extend the base ruleset:
{
"extends": "@terminus/tslint-config-frontend"
}
Linting during the CI process is the most strict and will fail if any issues are found. The only way a linting issue makes it to CI is because someone didn't lint before commiting.
package.json
--project
flag reference should point to the primary app tsconfig
file.--config
flag reference should point to the ci tslint
file.{
"name": "My Project",
"scripts": {
"lint:tslint:ci": "npx tslint --project ./src/tsconfig.app.json --config ./tslint.ci.json"
}
}
This ruleset extends the ci
ruleset but softens the rules to turn many stylistic issues into warnings in order to not impede development.
Create a TSLint config file at the root level named tslint.json
and extend the development ruleset:
{
"extends": "@terminus/tslint-config-frontend/development"
}
NOTE: When adjusting a TSLint rule, the entire rule must be defined again.
{
"extends": "@terminus/tslint-config-frontend/development",
"rules": {
"component-selector": [
true,
"element",
"foo",
"kebab-case"
],
"directive-selector": [
true,
"attribute",
"foo",
"camelCase"
],
"pipe-prefix": [
true,
"foo"
]
}
}
package.json
After the --project
flag, the reference should point to your primary app tsconfig
file.
{
"name": "My Project",
"scripts": {
"lint:tslint": "npx tslint --project ./src/tsconfig.app.json"
}
}
Create a TSLint config file at the root level named tslint.spec.json
and extend the testing ruleset:
{
"extends": "@terminus/tslint-config-frontend/testing"
}
package.json
--project
flag reference should point to the spec tsconfig
file.--config
flag reference should point to the spec tslint
file.{
"name": "My Project",
"scripts": {
"lint:tslint:spec": "npx tslint --project ./src/tsconfig.spec.json --config ./tslint.spec.json"
}
}
Each rule is accompanied by a comment outlining the reasoning behind the decision to include the rule.
For most rules, see ci.js
.