Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Externalise ts-lint rules #112

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ts-jest": "^20.0.7",
"ts-loader": "^2.2.1",
"tslint": "^5.2.0",
"tslint-create-react-app-typescript": "^1.0.0",
"tslint-loader": "^3.5.3",
"tslint-react": "^3.0.0",
"typescript": "~2.4.0",
Expand Down
98 changes: 1 addition & 97 deletions packages/react-scripts/template/tslint.json
Original file line number Diff line number Diff line change
@@ -1,99 +1,3 @@
{
"extends": ["tslint-react"],
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": false,
"forin": true,
"indent": [ true, "spaces" ],
"interface-name": [true, "never-prefix"],
"jsdoc-format": true,
"jsx-no-lambda": false,
"jsx-no-multiline-js": false,
"label-position": true,
"max-line-length": [ true, 120 ],
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": true,
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"log",
"error",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unused-expression": true,
"no-use-before-declare": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-open-brace",
"check-whitespace"
],
"quotemark": [true, "single", "jsx-double"],
"radix": true,
"semicolon": [true, "always"],
"switch-default": true,

"trailing-comma": false,

"triple-equals": [ true, "allow-null-check" ],
"typedef": [
true,
"parameter",
"property-declaration"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-module",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
}
"extends": ["tslint-react", "tslint-create-react-app-typescript"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest i'd be happier to just extend from tslint-react and let people write their own rules? Would be interested to hear how people are actually using this file, whether they just delete their own and start again, or leave as-is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make things a lot simpler

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample tslint-react config suggests extending tslint:latest

The latest preset extends tslint:recommended and adds features supported by tslint 2.4

Many reasonable defaults

Quite strict

Helps keep consistent style across projects

Angular contributors have an issue and a pull request considering its usage in their bootstrapping tools

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree this is a good starting point!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having all the tslint config rules that someone else thought through, but some of the rules are out of date.

Project is a day or so old, here's my tslint: https://github.com/Falieson/typescript-react-asteroid-meteor/blob/master/client/tslint.json

}
12 changes: 12 additions & 0 deletions packages/tslint-create-react-app-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tslint-create-react-app-typescript",
"version": "1.0.0",
"description": "TS Lint configuration for create-react-app-typescript",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
},
"bugs": {
"url": "https://github.com/wmonk/create-react-app/issues"
}
}
98 changes: 98 additions & 0 deletions packages/tslint-create-react-app-typescript/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"rules": {
"align": [
true,
"parameters",
"arguments",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": false,
"forin": true,
"indent": [ true, "spaces" ],
"interface-name": [true, "never-prefix"],
"jsdoc-format": true,
"jsx-no-lambda": false,
"jsx-no-multiline-js": false,
"label-position": true,
"max-line-length": [ true, 120 ],
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": true,
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"log",
"error",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-consecutive-blank-lines": true,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": false,
"no-unused-expression": true,
"no-use-before-declare": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-open-brace",
"check-whitespace"
],
"quotemark": [true, "single", "jsx-double"],
"radix": true,
"semicolon": [true, "always"],
"switch-default": true,

"trailing-comma": false,

"triple-equals": [ true, "allow-null-check" ],
"typedef": [
true,
"parameter",
"property-declaration"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-module",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
}
}