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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: palantir/tslint
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.16.0
Choose a base ref
...
head repository: palantir/tslint
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.17.0
Choose a head ref
  • 18 commits
  • 34 files changed
  • 13 contributors

Commits on Apr 16, 2019

  1. Update docs config file

    adidahiya committed Apr 16, 2019
    Copy the full SHA
    d4699fd View commit details

Commits on Apr 17, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3546c8b View commit details
  2. VSCode plugin link updated (#4670)

    mrfrac authored and Josh Goldberg committed Apr 17, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a5f563d View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2720cf3 View commit details

Commits on Apr 18, 2019

  1. Copy the full SHA
    d233a83 View commit details

Commits on Apr 19, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    59f8942 View commit details

Commits on Apr 29, 2019

  1. Copy the full SHA
    60a397f View commit details

Commits on Apr 30, 2019

  1. Copy the full SHA
    1cb1a0a View commit details

Commits on May 5, 2019

  1. Add a fixer for "unnecessary-constructor" rule. (#4694)

    * Add a fixer for "unnecessary-constructor" rule.
    
    * Handle decorated parameters.
    bowenni authored and Josh Goldberg committed May 5, 2019
    Copy the full SHA
    be293b0 View commit details
  2. Copy the full SHA
    5a3a640 View commit details

Commits on May 7, 2019

  1. Allow const assertions in no-object-literal-type-assertion (#4681)

    * Ignore const assertions
    
    These are not normal type assertions and asserting that literal objects
    are immutable is a normal usage pattern.
    
    * Bump typescript to get utility function for const assert
    
    * Make sure tests pass on older typescripts
    
    * Clean up tests and doc
    asmundg authored and Josh Goldberg committed May 7, 2019
    Copy the full SHA
    d79cd18 View commit details
  2. [quotemark] Exclude some cases from backtick rule (#4693)

    * [quotemark] Exclude some cases from backtick rule
    
    This commit makes quotemark backtick ignore use strict declarations, enum members, lookup types, and strings containing octal escape sequences.
    
    * [quotemark] Fix comment on use strict check call
    
    I had copy pasted and forgotten to change it. This changes that comment.
    
    * Revert unrelated change, fix octal escape sequence check
    
    This commit makes it so that if a string has a literal backslash instead of an actual octal escape sequence, it is not flagged.
    ericbf authored and Josh Goldberg committed May 7, 2019
    Copy the full SHA
    c98a859 View commit details
  3. quiet describe typo (#4688)

    --quiet hide warnings instead of errors
    dawncold authored and Josh Goldberg committed May 7, 2019
    Copy the full SHA
    3efdfe5 View commit details

Commits on May 15, 2019

  1. Copy the full SHA
    8ef652e View commit details

Commits on May 16, 2019

  1. Copy the full SHA
    726a65c View commit details
  2. Copy the full SHA
    94dafa0 View commit details

Commits on May 21, 2019

  1. Add "cd tslint" to README quick start (#4735)

    zachkirsch authored and Josh Goldberg committed May 21, 2019
    Copy the full SHA
    b986082 View commit details

Commits on May 30, 2019

  1. Prepare v5.17.0 (#4751)

    adidahiya authored May 30, 2019
    Copy the full SHA
    92c9f36 View commit details
Showing with 957 additions and 503 deletions.
  1. +6 −4 .nycrc
  2. +28 −0 CHANGELOG.md
  3. +1 −0 README.md
  4. +19 −0 docs/.circle/config.yml
  5. +0 −7 docs/circle.yml
  6. +2 −2 docs/usage/third-party-tools/index.md
  7. +7 −7 package.json
  8. +40 −44 scripts/generate-changelog.ts
  9. +1 −1 src/language/rule/rule.ts
  10. +1 −1 src/linter.ts
  11. +5 −1 src/rules/noObjectLiteralTypeAssertionRule.ts
  12. +1 −0 src/rules/noRedundantJsdocRule.ts
  13. +2 −2 src/rules/noUnusedVariableRule.ts
  14. +4 −0 src/rules/noUseBeforeDeclareRule.ts
  15. +64 −19 src/rules/quotemarkRule.ts
  16. +15 −1 src/rules/unnecessaryConstructorRule.ts
  17. +36 −21 src/rules/variableNameRule.ts
  18. +1 −1 src/tslintCli.ts
  19. +2 −2 test/executable/executableTests.ts
  20. +2 −1 test/rules/no-inferred-empty-object-type/test.ts.lint
  21. +1 −1 test/rules/no-null-undefined-union/test.ts.lint
  22. +12 −0 test/rules/no-null-undefined-union/ts350.ts.lint
  23. +6 −0 test/rules/no-object-literal-type-assertion/default/test.ts.lint
  24. +14 −3 test/rules/no-redundant-jsdoc/test.ts.lint
  25. 0 test/rules/quotemark/backtick/{test>=2.7.1.ts.fix → test-post-2.7.1-syntax.ts.fix}
  26. 0 test/rules/quotemark/backtick/{test>=2.7.1.ts.lint → test-post-2.7.1-syntax.ts.lint}
  27. 0 test/rules/quotemark/backtick/{test<2.7.1.ts.fix → test-pre-2.7.1-syntax.ts.fix}
  28. 0 test/rules/quotemark/backtick/{test<2.7.1.ts.lint → test-pre-2.7.1-syntax.ts.lint}
  29. +48 −0 test/rules/quotemark/backtick/test.ts.fix
  30. +57 −0 test/rules/quotemark/backtick/test.ts.lint
  31. +69 −0 test/rules/unnecessary-constructor/test.ts.fix
  32. +4 −0 test/rules/unnecessary-constructor/test.ts.lint
  33. +4 −0 tslint-vscode.json
  34. +505 −385 yarn.lock
10 changes: 6 additions & 4 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"include": [
"build/**/*.js"
"build/**/*.js",
"src/**/*.ts"
],
"extension": [
".js"
".js",
".ts"
],
"exclude": [
"build/test"
"**/test"
],
"reporter": [
"text-summary",
"html"
],
"sourceMap": true,
"all": true
}
}
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Change Log

## v5.17.0

- [bugfix] [`quotemark`](https://palantir.github.io/tslint/rules/quotemark/) backtic option now ignores enum members, use strict declarations, lookup types, and strings containing octal escape sequences. (#4693)
- [bugfix] [`no-redundant-jsdoc`](https://palantir.github.io/tslint/rules/no-redundant-jsdoc/) no longer errors on `JSDocThisTag` (#4690)
- [chore] Update devDependency mocha from v3.2.0 to v6.1.4 (#4669) (#4674)
- [chore] Update devDependency js-yaml from ^3.13.0 to ^3.13.1 (#4663)
- [chore] Update deprecated devDependency github to @octokit/rest (#4673)
- [chore] Update devDependency nyc from v13.3.0 to v14.1.1 (#4699)
- [deprecation] [`no-use-before-declare`](https://palantir.github.io/tslint/rules/no-use-before-declare/) rule for typescript >= 2.9.0 (#4695)
- [documentation] Minor fix for [`variable-name`](https://palantir.github.io/tslint/rules/variable-name/) rule metadata (#4731)
- [documentation] Fixed [`no-unused-variable`](https://palantir.github.io/tslint/rules/no-unused-variable/) argument count (#4683)
- [enhancement] Allow const assertions in [`no-object-literal-type-assertion`](https://palantir.github.io/tslint/rules/no-object-literal-type-assertion/) (#4681)
- [new-fixer] [`unnecessary-constructor`](https://palantir.github.io/tslint/rules/unnecessary-constructor/) (#4694)

Thanks to our contributors!

- Bjorn Stromberg
- Vitaliy Agoshkov
- knafteN
- Bowen Ni
- Waseem Ahmad
- Åsmund Grammeltvedt
- Eric Ferreira
- Zhen Tian
- Tom Lakesman
- zachkirsch


## v5.16.0

- [bugfix] Excuse more [`quotemark`](https://palantir.github.io/tslint/rules/quotemark/) backtick edge cases and fix behavior for TS < 2.7.1 (#4642)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ Prerequisites:

```bash
git clone git@github.com:palantir/tslint.git --config core.autocrlf=input --config core.eol=lf
cd tslint
yarn
yarn compile
yarn test
19 changes: 19 additions & 0 deletions docs/.circle/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.3-jessie-node-browsers-legacy
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "Gemfile.lock" }}
- run:
name: Install dependencies
command: bundle check || bundle install
- save_cache:
key: dependency-cache-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Build documentation
command: bundle exec jekyll build
7 changes: 0 additions & 7 deletions docs/circle.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docs/usage/third-party-tools/index.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ _Note: Most of these tools are not maintained by TSLint._
* [gulp-tslint][2] ([Gulp][3])
* [eclipse-tslint][4] ([Eclipse][5])
* [linter-tslint][6] ([Atom][7])
* [vscode-tslint][8] ([Visual Studio Code][9])
* [vscode-typescript-tslint-plugin][8] ([Visual Studio Code][9])
* [syntastic][10] ([VIM][11])
* [Web Analyzer][12] ([Visual Studio][13])
* [Webstorm][14]
@@ -32,7 +32,7 @@ _Note: Most of these tools are not maintained by TSLint._
[5]: http://www.eclipse.org/
[6]: https://github.com/AtomLinter/linter-tslint
[7]: https://atom.io/
[8]: https://github.com/Microsoft/vscode-tslint/tree/master/tslint
[8]: https://github.com/Microsoft/vscode-typescript-tslint-plugin
[9]: https://code.visualstudio.com/
[10]: https://github.com/scrooloose/syntastic
[11]: http://www.vim.org/
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tslint",
"version": "5.16.0",
"version": "5.17.0",
"description": "An extensible static analysis linter for the TypeScript language",
"bin": {
"tslint": "./bin/tslint"
@@ -35,7 +35,7 @@
"commander": "^2.12.1",
"diff": "^3.2.0",
"glob": "^7.1.1",
"js-yaml": "^3.13.0",
"js-yaml": "^3.13.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"resolve": "^1.3.2",
@@ -47,33 +47,33 @@
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev"
},
"devDependencies": {
"@octokit/rest": "^16.24.3",
"@types/babel__code-frame": "^7.0.1",
"@types/chai": "^3.5.0",
"@types/diff": "^3.2.0",
"@types/glob": "^5.0.30",
"@types/js-yaml": "^3.5.31",
"@types/minimatch": "^2.0.29",
"@types/mkdirp": "^0.5.2",
"@types/mocha": "^2.2.35",
"@types/mocha": "^5.2.6",
"@types/node": "^7.0.29",
"@types/resolve": "^0.0.4",
"@types/rimraf": "^2.0.2",
"@types/semver": "^5.3.30",
"chai": "^3.5.0",
"github": "^8.2.1",
"husky": "^0.14.3",
"json-stringify-pretty-compact": "^1.2.0",
"mocha": "^3.2.0",
"mocha": "^6.1.4",
"npm-run-all": "^4.0.2",
"nyc": "^13.3.0",
"nyc": "^14.1.1",
"prettier": "~1.16.4",
"rimraf": "^2.5.4",
"ts-node": "^3.3.0",
"tslint": "~5.13.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~3.1.6",
"typescript": "~3.4.0",
"yarn-deduplicate": "^1.1.1"
},
"engines": {
84 changes: 40 additions & 44 deletions scripts/generate-changelog.ts
Original file line number Diff line number Diff line change
@@ -23,65 +23,63 @@

// tslint:disable:no-console

import GitHubApi = require("github");
import * as Octokit from "@octokit/rest";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

import { camelize } from "../lib/utils";

const github = new GitHubApi({
// ignores TLS certificate error
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

const tokenFile = path.join(os.homedir(), "github_token.txt");
const authToken = fs
.readFileSync(tokenFile, "utf8")
.toString()
.trim();
console.log(`Using OAuth token ${authToken}\n`);

const octokit = new Octokit({
auth: authToken,
host: "api.github.com",
protocol: "https",
timeout: 5000,
request: {
timeout: 5000,
},
});

const repoInfo = {
owner: "palantir",
repo: "tslint",
};

const tokenFile = path.join(os.homedir(), "github_token.txt");

// authenticate
const auth: GitHubApi.Auth = {
token: fs
.readFileSync(tokenFile, "utf8")
.toString()
.trim(),
type: "oauth",
};
console.log("Using OAuth token " + auth.token + "\n");

// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // ignores TLS certificate error
github.authenticate(auth);

const commits: ICommit[] = [];
github.repos
const commitList: ICommit[] = [];
octokit.repos
.getLatestRelease(repoInfo)
.then(value => {
console.log("Getting commits " + value.tag_name + "..master");
.then(({ data: { tag_name } }) => {
console.log(`Getting commits ${tag_name}..master`);
// get the commits between the most recent release and the head of master
return github.repos.compareCommits({
base: value.tag_name,
return octokit.repos.compareCommits({
base: tag_name,
head: "master",
...repoInfo,
});
})
.then(value => {
.then(({ data: { commits } }) => {
// for each commit, get the PR, and extract changelog entries
const promises: Array<Promise<any>> = [];
for (const commitInfo of value.commits) {
for (const commitInfo of commits) {
const commit: ICommit = {
fields: [],
sha: commitInfo.sha,
submitter:
commitInfo.commit.author.name != null
commitInfo.commit.author.name !== null
? commitInfo.commit.author.name
: commitInfo.author.login,
title: commitInfo.commit.message,
};
commits.push(commit);
commitList.push(commit);

// check for a pull request number in the commit title
const match = (commitInfo.commit.message as string).match(/\(#(\d+)\)/);
@@ -90,20 +88,20 @@ github.repos

// get the PR text
promises.push(
github.issues
octokit.issues
.get({
number: commit.pushRequestNum,
issue_number: commit.pushRequestNum,
...repoInfo,
})
.then(comment => {
.then(({ data: { body } }) => {
// extract the changelog entries
const lines = (comment.body as string).split("\r\n");
const lines = body.split("\r\n");
for (const line of lines) {
const fieldMatch = line.match(/^(\[[a-z\-]+\])/);
if (fieldMatch) {
commit.fields.push({
tag: fieldMatch[1],
text: addLinks(line) + " (#" + commit.pushRequestNum + ")",
text: `${addLinks(line)} (#${commit.pushRequestNum})`,
});
}
}
@@ -117,7 +115,7 @@ github.repos
const entries: IField[] = [];
const noFields: string[] = [];
const contributors = new Set<string>();
for (const commit of commits) {
for (const commit of commitList) {
if (commit.fields.length > 0) {
for (const field of commit.fields) {
if (field.tag !== "[no-log]") {
@@ -129,28 +127,26 @@ github.repos
}
contributors.add(commit.submitter);
}
entries.sort((a, b) => {
return a.tag.localeCompare(b.tag);
});
entries.sort((a, b) => a.tag.localeCompare(b.tag));

console.log("\n---- formatted changelog entries: ----");
for (const entry of entries) {
console.log("- " + entry.text);
console.log(`- ${entry.text}`);
}

console.log("\n---- PRs with missing changelog entries: ----");
for (const missing of noFields) {
console.log("- " + missing.replace(/[\r\n]+/, "\r\n "));
console.log(`- ${missing.replace(/[\r\n]+/, "\r\n ")}`);
}

console.log("\n---- thanks ----");
console.log("Thanks to our contributors!");
contributors.forEach(contributor => {
console.log("- " + contributor);
console.log(`- ${contributor}`);
});
})
.catch(error => {
console.log("Error:" + error);
console.log(`Error: ${error}`);
});

const cache = new Map<string, boolean>();
@@ -173,9 +169,9 @@ function addLinks(text: string): string {
let match = regex.exec(text);
while (match !== null) {
if (isRule(match[1])) {
result +=
text.slice(lastIndex, match.index) +
`[${match[0]}](https://palantir.github.io/tslint/rules/${match[1]}/)`;
result += `${text.slice(lastIndex, match.index)}[${
match[0]
}](https://palantir.github.io/tslint/rules/${match[1]}/)`;
lastIndex = regex.lastIndex;
}
match = regex.exec(text);
2 changes: 1 addition & 1 deletion src/language/rule/rule.ts
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ export interface IRuleMetadata {
* Examples of what a standard config for the rule might look like.
* Using a string[] here is deprecated. Write the options as a JSON object instead.
*/
optionExamples?: Array<true | any[]> | string[];
optionExamples?: Array<true | any[]> | string[] | Array<{ options: any }>;

/**
* An explanation of why the rule is useful.
2 changes: 1 addition & 1 deletion src/linter.ts
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ import { arrayify, dedent, flatMap, mapDefined } from "./utils";
* Linter that can lint multiple files in consecutive runs.
*/
export class Linter {
public static VERSION = "5.16.0";
public static VERSION = "5.17.0";

public static findConfiguration = findConfiguration;
public static findConfigurationPath = findConfigurationPath;
6 changes: 5 additions & 1 deletion src/rules/noObjectLiteralTypeAssertionRule.ts
Original file line number Diff line number Diff line change
@@ -48,7 +48,9 @@ export class Rule extends Lint.Rules.AbstractRule {
The type assertion in the latter case is either unnecessary or hides an error.
The compiler will warn for excess properties with this syntax, but not missing required fields.
For example: \`const x: { foo: number } = {}\` will fail to compile, but
\`const x = {} as { foo: number }\` will succeed.`,
\`const x = {} as { foo: number }\` will succeed.
Additionally, the const assertion \`const x = { foo: 1 } as const\`,
introduced in TypeScript 3.4, is considered beneficial and is ignored by this rule.`,
optionsDescription: Lint.Utils.dedent`
One option may be configured:
@@ -86,6 +88,8 @@ function walk(ctx: Lint.WalkContext<Options>): void {
if (
isAssertionExpression(node) &&
node.type.kind !== ts.SyntaxKind.AnyKeyword &&
// Allow const assertions, introduced in TS 3.4
!(ts.isConstTypeReference !== undefined && ts.isConstTypeReference(node.type)) &&
// Compare with UnknownKeyword if using TS 3.0 or above
(!!(ts.SyntaxKind as any).UnknownKeyword
? node.type.kind !== (ts.SyntaxKind as any).UnknownKeyword
1 change: 1 addition & 0 deletions src/rules/noRedundantJsdocRule.ts
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ function walk(ctx: Lint.WalkContext): void {
break;

case ts.SyntaxKind.JSDocClassTag:
case ts.SyntaxKind.JSDocThisTag:
case ts.SyntaxKind.JSDocTypeTag:
case ts.SyntaxKind.JSDocTypedefTag:
case ts.SyntaxKind.JSDocPropertyTag:
Loading