Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into indent-walk
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-hanson committed May 25, 2017
2 parents ef6f8c9 + d52d587 commit 6db275d
Show file tree
Hide file tree
Showing 296 changed files with 6,499 additions and 4,221 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
*.fix text eol=lf
/test/rules/linebreak-style/**/CRLF/*.lint text eol=crlf
/test/rules/linebreak-style/**/LF/*.fix text eol=crlf
/test/rules/jsdoc-format/**/jsdoc-windows.ts.lint text eol=crlf
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"editor.wrappingIndent": "none",

// The folders to exclude when doing a full text search in the workspace.
"files.exclude": {
"search.exclude": {
".git": true,
".tscache": true,
"bower_components": true,
Expand Down
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,64 @@
Change Log
===

<!-- TODO: for 5.4, add
[new-rule] [`type-literal-delimiter`](https://palantir.github.io/tslint/rules/type-literal-delimiter/) (#2374)
5.3 will be published without it since it's still discussed
-->

v5.3.0
---

## This change may require a change to tslint.json
- [enhancement] [`prefer-switch`](https://palantir.github.io/tslint/rules/prefer-switch/): Change default `min-cases` to 3. (#2669)

## :tada: Notable features & enhancements
- [new-cli-option] cli: Add `outputAbsolutePaths` option (#2667)
- [new-rule] [`prefer-object-spread`](https://palantir.github.io/tslint/rules/prefer-object-spread/) (#2624)
- [new-rule] [`encoding`](https://palantir.github.io/tslint/rules/encoding/) (#2368)
- [new-rule] [`prefer-conditional-expression`](https://palantir.github.io/tslint/rules/prefer-conditional-expression/) (#2363)
- [new-rule-option] [`indent`](https://palantir.github.io/tslint/rules/indent/) support indent size (#2723)
- [new-rule-option] [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/) adds `ignore-case` (#2592)
- [new-rule-option] [`quotemark`](https://palantir.github.io/tslint/rules/quotemark/): Add `avoid-template` option (#2766)
- [new-rule-option] [`await-promise`](https://palantir.github.io/tslint/rules/await-promise): What's considered a "Promise" is now configurable. (#2661)
- [new-fixer] [`indent`](https://palantir.github.io/tslint/rules/indent/) (#2723)
- [new-fixer] [`typedef-whitespace`](https://palantir.github.io/tslint/rules/typedef-whitespace/) (#2718)
- [enhancement] better error messages in [`variable-name`](https://palantir.github.io/tslint/rules/variable-name/) (#2672)
- [enhancement] [`typedef`](https://palantir.github.io/tslint/rules/typedef/): Use name or parameters for error location (#2460)
- [enhancement] [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/): check shorthand properties (#2592)
- [enhancement] [`space-before-function-paren`](https://palantir.github.io/tslint/rules/space-before-function-paren/): Handle `get`/`set` accessor (#2700)
- [enhancement] [`typedef-whitespace`](https://palantir.github.io/tslint/rules/typedef-whitespace/) added checks for arrow function, call and construct signature (#2718)
- [enhancement] [`no-object-literal-type-assertion`](https://palantir.github.io/tslint/rules/no-object-literal-type-assertion/): Allow cast to `any` (#2671)
- [enhancement] cli: `-p` option handles directories (#2756)
- [develop] testing rules with type information is enabled when a `tsconfig.json` is found next to `tslint.json` (#2769)
- [configuration] deprecate mixed case tslint.json (#2713)
- [bugfix] [`return-undefined`](https://palantir.github.io/tslint/rules/return-undefined/): Treat a return type `void | undefined` same as `void` (#2731)
- [bugfix] [`no-unnecessary-initializer`](https://palantir.github.io/tslint/rules/no-unnecessary-initializer/): Handle `BindingElement` anywhere, not just in a `VariableDeclaration`. (#2707)
- [bugfix] [`jsdoc-format`](https://palantir.github.io/tslint/rules/jsdoc-format/): correctly handle alignment in files with BOM (#2619)
- [bugfix] [`jsdoc-format`](https://palantir.github.io/tslint/rules/jsdoc-format/): don't treat empty comments (`/**/`) as jsdoc (#2619)
- [bugfix] [`typedef-whitespace`](https://palantir.github.io/tslint/rules/typedef-whitespace/) don't warn for leading whitespace if token is preceded by line break (#2718)
- [bugfix] Make "completed-docs" rule respect "public" privacy (or lack thereof) (#2749)
- [bugfix] [`jsdoc-format`](https://palantir.github.io/tslint/rules/jsdoc-format/): fixed error position if line ends with `\r\n` (#2619)
- [bugfix] [`prefer-switch`](https://palantir.github.io/tslint/rules/prefer-switch/): add missing checks for some expressions (#2686)
- [bugfix] [`prefer-template`](https://palantir.github.io/tslint/rules/prefer-template/): Allow `"a" + "b" + "c"`. (#2741)
- [bugfix] [`prefer-const`](https://palantir.github.io/tslint/rules/prefer-const/): fix false positive with variable declared outside of for-of or for-in (#2760)
- [bugfix] `--project`: fix file matching with relative path to `tsconfig.json` (#2688)
- [bugfix] [`no-default-export`](https://palantir.github.io/tslint/rules/no-default-export/): correctly handle `export default abstract class {...}` (#2630)
- [bugfix] [`no-mergeable-namespace`](https://palantir.github.io/tslint/rules/no-mergeable-namespace/): display correct line in error message (#2656)
- [bugfix] [`object-literal-sort-keys`](https://palantir.github.io/tslint/rules/object-literal-sort-keys/): handle object spread correctly (#2592)
- [bugfix] Consistently output absolute/relative paths (#2667)
- [bugfix] [`await-promise`](https://palantir.github.io/tslint/rules/await-promise): Consider types derived from a Promise in union types too. (#2661)
- [bugfix] [`no-unsafe-any`](https://palantir.github.io/tslint/rules/no-unsafe-any/): Fix bug where number literal in type position was flagged as an unsafe `any`. (#2712)
- [api] Deprecate `Lint.Utils.objectify` (#2764)

Thanks to our contributors!
- Andy Hanson
- Klaus Meinhardt
- Martin Probst
- Filipe Silva
- walkerburgin
- René Scheibe

v5.2.0
---

Expand Down
2 changes: 2 additions & 0 deletions docs/develop/testing-rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ The following part can be any [version range](https://github.com/npm/node-semver
* You can use this system to test rules outside of the TSLint build! Use the `tslint --test path/to/dir` command to test your own custom rules.
The directory you pass should contain a `tslint.json` file and `.ts.lint` files. You can try this out on the TSLint rule test cases, for example, `tslint --test path/to/tslint-code/test/rules/quotemark/single`.

* To test rules that need type information, you can simply add a `tsconfig.json` with the desired configuration next to `tslint.json`.

* Lint failures sometimes span over multiple lines. To handle this case, don't specify a message until the end of the error. For example:

```
Expand Down
4 changes: 4 additions & 0 deletions docs/usage/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Options:
-h, --help display detailed help
-i, --init generate a tslint.json config file in the current working directory
-o, --out output file
--outputAbsolutePaths whether or not outputted file paths are absolute
-p, --project tsconfig.json file
-r, --rules-dir rules directory
-s, --formatters-dir formatters directory
Expand Down Expand Up @@ -89,6 +90,9 @@ tslint accepts the following command-line options:
A filename to output the results to. By default, tslint outputs to
stdout, which is usually the console where you're running it from.
--outputAbsolutePaths:
Indicates whether or not outputted file paths are absolute paths.
-r, --rules-dir:
An additional rules directory, for user-created rules.
tslint will always check its default rules directory, in
Expand Down
28 changes: 28 additions & 0 deletions docs/usage/library/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ yarn add tslint typescript

Please ensure that the TypeScript source files compile correctly _before_ running the linter.

#### TypeScript

This code will need to be transpiled to JavaScript to run under Node.js.

```ts
import { Linter, Configuration } from "tslint";
import * as fs from "fs";

const fileName = "Specify input file name";
const configurationFilename = "Specify configuration file name";
const options = {
fix: false,
formatter: "json",
rulesDirectory: "customRules/",
formattersDirectory: "customFormatters/"
Expand All @@ -36,3 +41,26 @@ const configuration = Configuration.findConfiguration(configurationFilename, fil
linter.lint(fileName, fileContents, configuration);
const result = linter.getResult();
```

#### JavaScript (ES5)

This code will run directly under Node.js, including if it's called from the command line.

```js
"use strict";
var tslint = require("tslint");
var fs = require("fs");
var fileName = "Specify input file name";
var configurationFilename = "Specify configuration file name";
var options = {
fix: false,
formatter: "json",
rulesDirectory: "customRules/",
formattersDirectory: "customFormatters/"
};
var fileContents = fs.readFileSync(fileName, "utf8");
var linter = new tslint.Linter(options);
var configuration = tslint.Configuration.findConfiguration(configurationFilename, fileName).results;
linter.lint(fileName, fileContents, configuration);
var result = linter.getResult();
```
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tslint",
"version": "5.2.0",
"version": "5.3.0",
"description": "An extensible static analysis linter for the TypeScript language",
"bin": {
"tslint": "./bin/tslint"
Expand Down Expand Up @@ -43,8 +43,8 @@
"optimist": "~0.6.0",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.6.0",
"tsutils": "^1.8.0"
"tslib": "^1.7.1",
"tsutils": "^2.1.0"
},
"peerDependencies": {
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev"
Expand All @@ -53,20 +53,21 @@
"@types/babel-code-frame": "^6.20.0",
"@types/chai": "^3.5.0",
"@types/colors": "^1.1.3",
"@types/diff": "0.0.31",
"@types/diff": "^3.2.0",
"@types/glob": "^5.0.30",
"@types/js-yaml": "^3.5.29",
"@types/mocha": "^2.2.35",
"@types/node": "^7.0.16",
"@types/optimist": "0.0.29",
"@types/resolve": "0.0.4",
"@types/optimist": "^0.0.29",
"@types/resolve": "^0.0.4",
"@types/semver": "^5.3.30",
"chai": "^3.5.0",
"github": "^8.1.1",
"github": "^8.2.1",
"js-yaml": "^3.7.0",
"json-stringify-pretty-compact": "^1.0.3",
"memory-streams": "^0.1.2",
"mocha": "^3.2.0",
"npm-run-all": "^3.1.0",
"npm-run-all": "^4.0.2",
"nyc": "^10.2.0",
"rimraf": "^2.5.4",
"tslint": "latest",
Expand Down
48 changes: 31 additions & 17 deletions src/configs/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,23 @@ export const rules = {
"variable-declaration",
"member-variable-declaration",
],
"typedef-whitespace": [true, {
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace",
}, {
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace",
}],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace",
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace",
},
],
"unified-signatures": true,

// Functionality
Expand Down Expand Up @@ -117,6 +121,7 @@ export const rules = {
"no-use-before-declare": true,
"no-var-keyword": true,
"no-void-expression": true,
"prefer-conditional-expression": true,
"radix": true,
"restrict-plus-operands": true,
"strict-boolean-expressions": true,
Expand Down Expand Up @@ -148,7 +153,8 @@ export const rules = {

// Style

"align": [true,
"align": [
true,
"parameters",
"arguments",
"statements",
Expand Down Expand Up @@ -188,7 +194,8 @@ export const rules = {
"number-literal-format": true,
"object-literal-key-quotes": [true, "consistent-as-needed"],
"object-literal-shorthand": true,
"one-line": [true,
"one-line": [
true,
"check-catch",
"check-else",
"check-finally",
Expand All @@ -202,9 +209,15 @@ export const rules = {
}],
"prefer-function-over-method": true,
"prefer-method-signature": true,
"prefer-object-spread": true,
"prefer-switch": true,
"prefer-template": true,
"quotemark": [true, "double", "avoid-escape"],
"quotemark": [
true,
"double",
"avoid-escape",
"avoid-template",
],
"return-undefined": true,
"semicolon": [true, "always"],
"space-before-function-paren": [true, {
Expand All @@ -214,6 +227,7 @@ export const rules = {
"method": "never",
"named": "never",
}],
"type-literal-delimiter": true,
"variable-name": [
true,
"ban-keywords",
Expand Down Expand Up @@ -243,7 +257,7 @@ for (const key in rules) {
}

const Rule = findRule(key, joinPaths(__dirname, "..", "rules"));
if (Rule === "not-found") {
if (Rule === undefined) {
throw new Error(`Couldn't find rule '${key}'.`);
}
if (!Rule.metadata.typescriptOnly) {
Expand Down
4 changes: 4 additions & 0 deletions src/configs/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const rules = {

// added in v5.2
"no-object-literal-type-assertion": true,

// added in v5.3
"prefer-conditional-expression": true,
"prefer-object-spread": true,
};
// tslint:enable object-literal-sort-keys

Expand Down
29 changes: 16 additions & 13 deletions src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,22 @@ export const rules = {
},
"typedef": false,
"typedef-whitespace": {
options: [{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace",
}, {
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace",
}],
options: [
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace",
},
{
"call-signature": "onespace",
"index-signature": "onespace",
"parameter": "onespace",
"property-declaration": "onespace",
"variable-declaration": "onespace",
},
],
},
"typeof-compare": true,
"unified-signatures": true,
Expand Down
Loading

0 comments on commit 6db275d

Please sign in to comment.