Skip to content

Commit

Permalink
chore: merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
princjef committed Jun 9, 2019
2 parents 534809c + b16409a commit 9b2c4e6
Show file tree
Hide file tree
Showing 223 changed files with 26,638 additions and 2,901 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -5,5 +5,4 @@ fixtures
shared-fixtures
coverage

packages/typescript-estree/src/estree
packages/eslint-plugin-tslint/tests
8 changes: 7 additions & 1 deletion .eslintrc.json
Expand Up @@ -5,11 +5,17 @@
"es6": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"comma-dangle": ["error", "always-multiline"],
"curly": ["error", "all"],
"no-mixed-operators": "error",
"no-console": "off",
"no-dupe-class-members": "off",
"no-undef": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/eslint-plugin-typescript.md
Expand Up @@ -36,7 +36,7 @@ The more irrelevant code/config you give, the harder it is for us to investigate
```JSON
{
"rules": {
"typescript/<rule>": ["<setting>"]
"@typescript-eslint/<rule>": ["<setting>"]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Expand Up @@ -3,8 +3,8 @@
**/coverage
**/shared-fixtures
**/tests/integration/fixtures/**/*
**/lib/configs/recommended.json
**/.vscode
**/.nyc_output
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
.github
packages/eslint-plugin/src/configs/*.json
39 changes: 39 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,45 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.8.0...v1.9.0) (2019-05-12)

### Bug Fixes

- **eslint-plugin:** Add missing dependency ([89c87cc](https://github.com/typescript-eslint/typescript-eslint/commit/89c87cc)), closes [#516](https://github.com/typescript-eslint/typescript-eslint/issues/516)
- **eslint-plugin:** Fix exported name of eslint-recommended ([#513](https://github.com/typescript-eslint/typescript-eslint/issues/513)) ([5c65350](https://github.com/typescript-eslint/typescript-eslint/commit/5c65350))

### Features

- **eslint-plugin:** add prefer-regexp-exec rule ([#305](https://github.com/typescript-eslint/typescript-eslint/issues/305)) ([f61d421](https://github.com/typescript-eslint/typescript-eslint/commit/f61d421))

# [1.8.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.7.0...v1.8.0) (2019-05-10)

### Bug Fixes

- **eslint-plugin:** [array-type] support readonly operator ([#429](https://github.com/typescript-eslint/typescript-eslint/issues/429)) ([8e2d2f5](https://github.com/typescript-eslint/typescript-eslint/commit/8e2d2f5))
- **eslint-plugin:** [explicit-function-return-type] Add handling for class properties ([#502](https://github.com/typescript-eslint/typescript-eslint/issues/502)) ([2c36325](https://github.com/typescript-eslint/typescript-eslint/commit/2c36325))
- **eslint-plugin:** [no-extra-parens] Fix build error ([298d66c](https://github.com/typescript-eslint/typescript-eslint/commit/298d66c))
- **eslint-plugin:** [unbound-method] Work around class prototype bug ([#499](https://github.com/typescript-eslint/typescript-eslint/issues/499)) ([3219aa7](https://github.com/typescript-eslint/typescript-eslint/commit/3219aa7))
- **eslint-plugin:** correct eslint-recommended settings ([d52a683](https://github.com/typescript-eslint/typescript-eslint/commit/d52a683))
- **eslint-plugin:** explicit-func-return-type: support object types and as expressions ([#459](https://github.com/typescript-eslint/typescript-eslint/issues/459)) ([d19e512](https://github.com/typescript-eslint/typescript-eslint/commit/d19e512))
- **eslint-plugin:** restrict-plus-operands: generic constraint support ([#440](https://github.com/typescript-eslint/typescript-eslint/issues/440)) ([3f305b1](https://github.com/typescript-eslint/typescript-eslint/commit/3f305b1))
- upgrade lockfile versions ([#487](https://github.com/typescript-eslint/typescript-eslint/issues/487)) ([f029dba](https://github.com/typescript-eslint/typescript-eslint/commit/f029dba))
- **eslint-plugin:** Support more nodes [no-extra-parens](<[#465](https://github.com/typescript-eslint/typescript-eslint/issues/465)>) ([2d15644](https://github.com/typescript-eslint/typescript-eslint/commit/2d15644))
- **eslint-plugin:** support switch statement [unbound-method](<[#485](https://github.com/typescript-eslint/typescript-eslint/issues/485)>) ([e99ca81](https://github.com/typescript-eslint/typescript-eslint/commit/e99ca81))
- **typescript-estree:** ensure parents are defined during subsequent parses ([#500](https://github.com/typescript-eslint/typescript-eslint/issues/500)) ([665278f](https://github.com/typescript-eslint/typescript-eslint/commit/665278f))

### Features

- **eslint-plugin:** (EXPERIMENTAL) begin indent rewrite ([#439](https://github.com/typescript-eslint/typescript-eslint/issues/439)) ([6eb97d4](https://github.com/typescript-eslint/typescript-eslint/commit/6eb97d4))
- **eslint-plugin:** Add better non-null handling [no-unnecessary-type-assertion](<[#478](https://github.com/typescript-eslint/typescript-eslint/issues/478)>) ([4cd5590](https://github.com/typescript-eslint/typescript-eslint/commit/4cd5590))
- **eslint-plugin:** Add func-call-spacing ([#448](https://github.com/typescript-eslint/typescript-eslint/issues/448)) ([92e65ec](https://github.com/typescript-eslint/typescript-eslint/commit/92e65ec))
- **eslint-plugin:** Add new config "eslint-recommended" ([#488](https://github.com/typescript-eslint/typescript-eslint/issues/488)) ([2600a9f](https://github.com/typescript-eslint/typescript-eslint/commit/2600a9f))
- **eslint-plugin:** add no-magic-numbers rule ([#373](https://github.com/typescript-eslint/typescript-eslint/issues/373)) ([43fa09c](https://github.com/typescript-eslint/typescript-eslint/commit/43fa09c))
- **eslint-plugin:** Add semi [extension](<[#461](https://github.com/typescript-eslint/typescript-eslint/issues/461)>) ([0962017](https://github.com/typescript-eslint/typescript-eslint/commit/0962017))
- **eslint-plugin:** no-inferrable-types: Support more primitives ([#442](https://github.com/typescript-eslint/typescript-eslint/issues/442)) ([4e193ca](https://github.com/typescript-eslint/typescript-eslint/commit/4e193ca))
- **ts-estree:** add preserveNodeMaps option ([#494](https://github.com/typescript-eslint/typescript-eslint/issues/494)) ([c3061f9](https://github.com/typescript-eslint/typescript-eslint/commit/c3061f9))
- Move shared types into their own package ([#425](https://github.com/typescript-eslint/typescript-eslint/issues/425)) ([a7a03ce](https://github.com/typescript-eslint/typescript-eslint/commit/a7a03ce))

# [1.7.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.6.0...v1.7.0) (2019-04-20)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -203,7 +203,7 @@ The `canary` (latest master) version is:

We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.

**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.5.0`.**
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.6.0`.**

This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.

Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Expand Up @@ -31,6 +31,10 @@ jobs:
yarn lint
displayName: 'Run linting'
- script: |
yarn docs:check
displayName: 'Validate documentation'
- script: |
yarn test
displayName: 'Run unit tests'
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"version": "1.7.0",
"version": "1.9.0",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -20,6 +20,7 @@
"build": "lerna run build",
"clean": "lerna clean && lerna run clean",
"cz": "git-cz",
"docs:check": "lerna run docs:check",
"generate-contributors": "yarn ts-node ./tools/generate-contributors.ts && yarn all-contributors generate",
"format": "prettier --write \"./**/*.{ts,js,json,md}\"",
"format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"",
Expand All @@ -28,7 +29,7 @@
"lint": "eslint . --ext .js,.ts",
"lint-fix": "eslint . --ext .js,.ts --fix",
"pre-commit": "yarn lint-staged",
"pre-push": "yarn lint && yarn typecheck && yarn format-check",
"pre-push": "yarn format-check",
"postinstall": "lerna bootstrap && yarn build && lerna link",
"test": "lerna run test --parallel",
"typecheck": "lerna run typecheck"
Expand Down Expand Up @@ -77,6 +78,6 @@
"ts-jest": "^24.0.0",
"ts-node": "^8.0.1",
"tslint": "^5.11.0",
"typescript": ">=3.2.1 <3.5.0"
"typescript": ">=3.2.1 <3.6.0"
}
}
11 changes: 11 additions & 0 deletions packages/eslint-plugin-tslint/CHANGELOG.md
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.9.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.8.0...v1.9.0) (2019-05-12)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint

# [1.8.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.7.0...v1.8.0) (2019-05-10)

### Bug Fixes

- upgrade lockfile versions ([#487](https://github.com/typescript-eslint/typescript-eslint/issues/487)) ([f029dba](https://github.com/typescript-eslint/typescript-eslint/commit/f029dba))
- **eslint-plugin:** Support more nodes [no-extra-parens](<[#465](https://github.com/typescript-eslint/typescript-eslint/issues/465)>) ([2d15644](https://github.com/typescript-eslint/typescript-eslint/commit/2d15644))

# [1.7.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.6.0...v1.7.0) (2019-04-20)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
Expand Down
18 changes: 12 additions & 6 deletions packages/eslint-plugin-tslint/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-tslint",
"version": "1.7.0",
"version": "1.9.0",
"main": "dist/index.js",
"typings": "src/index.ts",
"description": "TSLint wrapper plugin for ESLint",
Expand All @@ -13,28 +13,34 @@
"engines": {
"node": "^6.14.0 || ^8.10.0 || >=9.10.0"
},
"repository": "typescript-eslint/typescript-eslint",
"repository": {
"type": "git",
"url": "https://github.com/typescript-eslint/typescript-eslint.git",
"directory": "packages/eslint-plugin-tslint"
},
"bugs": {
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
},
"license": "MIT",
"scripts": {
"test": "jest --coverage",
"prebuild": "npm run clean",
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist/",
"format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore",
"prebuild": "npm run clean",
"test": "jest --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/experimental-utils": "1.9.0",
"lodash.memoize": "^4.1.2"
},
"peerDependencies": {
"eslint": "^5.0.0",
"tslint": "^5.0.0"
},
"devDependencies": {
"@types/eslint": "^4.16.3",
"@types/json-schema": "^7.0.3",
"@types/lodash.memoize": "^4.1.4",
"@typescript-eslint/parser": "1.7.0"
"@typescript-eslint/parser": "1.9.0"
}
}
159 changes: 4 additions & 155 deletions packages/eslint-plugin-tslint/src/index.ts
@@ -1,160 +1,9 @@
import { Rule } from 'eslint';
import memoize from 'lodash.memoize';
import { Configuration, RuleSeverity } from 'tslint';
import { Program } from 'typescript';
import { CustomLinter } from './custom-linter';
import { ParserServices } from '@typescript-eslint/typescript-estree';

//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------

type RawRuleConfig =
| null
| undefined
| boolean
| any[]
| {
severity?: RuleSeverity | 'warn' | 'none' | 'default';
options?: any;
};

interface RawRulesConfig {
[key: string]: RawRuleConfig;
}
import configRule from './rules/config';

/**
* Construct a configFile for TSLint
* Expose a single rule called "config", which will be accessed in the user's eslint config files
* via "tslint/config"
*/
const tslintConfig = memoize(
(
lintFile: string,
tslintRules: RawRulesConfig,
tslintRulesDirectory: string[],
) => {
if (lintFile != null) {
return Configuration.loadConfigurationFromPath(lintFile);
}
return Configuration.parseConfigFile({
rules: tslintRules || {},
rulesDirectory: tslintRulesDirectory || [],
});
},
(lintFile: string | undefined, tslintRules = {}, tslintRulesDirectory = []) =>
`${lintFile}_${Object.keys(tslintRules).join(',')}_${
tslintRulesDirectory.length
}`,
);

export const rules = {
/**
* Expose a single rule called "config", which will be accessed in the user's eslint config files
* via "tslint/config"
*/
config: {
meta: {
docs: {
description:
'Wraps a TSLint configuration and lints the whole source using TSLint',
category: 'TSLint',
},
schema: [
{
type: 'object',
properties: {
rules: {
type: 'object',
/**
* No fixed schema properties for rules, as this would be a permanently moving target
*/
additionalProperties: true,
},
rulesDirectory: {
type: 'array',
items: {
type: 'string',
},
},
lintFile: {
type: 'string',
},
},
additionalProperties: false,
},
],
},
create(context: Rule.RuleContext) {
const fileName = context.getFilename();
const sourceCode = context.getSourceCode().text;
const parserServices: ParserServices | undefined = context.parserServices;

/**
* The user needs to have configured "project" in their parserOptions
* for @typescript-eslint/parser
*/
if (!parserServices || !parserServices.program) {
throw new Error(
`You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser`,
);
}

/**
* The TSLint rules configuration passed in by the user
*/
const {
rules: tslintRules,
rulesDirectory: tslintRulesDirectory,
lintFile,
} = context.options[0];

const program: Program = parserServices.program;

/**
* Create an instance of TSLint
* Lint the source code using the configured TSLint instance, and the rules which have been
* passed via the ESLint rule options for this rule (using "tslint/config")
*/
const tslintOptions = {
formatter: 'json',
fix: false,
};
const tslint = new CustomLinter(tslintOptions, program);
const configuration = tslintConfig(
lintFile,
tslintRules,
tslintRulesDirectory,
);
tslint.lint(fileName, sourceCode, configuration);

const result = tslint.getResult();

/**
* Format the TSLint results for ESLint
*/
if (result.failures && result.failures.length) {
result.failures.forEach(failure => {
const start = failure.getStartPosition().getLineAndCharacter();
const end = failure.getEndPosition().getLineAndCharacter();
context.report({
message: `${failure.getFailure()} (tslint:${failure.getRuleName()})`,
loc: {
start: {
line: start.line + 1,
column: start.character,
},
end: {
line: end.line + 1,
column: end.character,
},
},
});
});
}

/**
* Return an empty object for the ESLint rule
*/
return {};
},
},
config: configRule,
};

0 comments on commit 9b2c4e6

Please sign in to comment.