Skip to content

Commit

Permalink
Merge branch 'main' into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Apr 26, 2023
2 parents 2946d87 + 1944d42 commit 3e3b789
Show file tree
Hide file tree
Showing 40 changed files with 473 additions and 234 deletions.
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,39 @@
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},{
"type": "node",
"request": "launch",
"name": "Jest Test Current eslint-plugin-tslint Rule",
"cwd": "${workspaceFolder}/packages/eslint-plugin-tslint/",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-cache",
"--no-coverage",
"${fileBasenameNoExtension}"
],
"sourceMaps": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"${workspaceFolder}/packages/utils/src/index.ts",
"${workspaceFolder}/packages/utils/dist/index.js",
"${workspaceFolder}/packages/utils/src/ts-estree.ts",
"${workspaceFolder}/packages/utils/dist/ts-estree.js",
"${workspaceFolder}/packages/type-utils/src/index.ts",
"${workspaceFolder}/packages/type-utils/dist/index.js",
"${workspaceFolder}/packages/parser/src/index.ts",
"${workspaceFolder}/packages/parser/dist/index.js",
"${workspaceFolder}/packages/typescript-estree/src/index.ts",
"${workspaceFolder}/packages/typescript-estree/dist/index.js",
"${workspaceFolder}/packages/types/src/index.ts",
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
"type": "node",
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)


### Bug Fixes

* **eslint-plugin:** [prefer-regexp-exec] skip malformed regexes ([#6935](https://github.com/typescript-eslint/typescript-eslint/issues/6935)) ([05ed60e](https://github.com/typescript-eslint/typescript-eslint/commit/05ed60e25f1de9d1bb83d56c81a349130960bec8))
* **eslint-plugin:** [unified-signatures] no parameters function ([#6940](https://github.com/typescript-eslint/typescript-eslint/issues/6940)) ([2970861](https://github.com/typescript-eslint/typescript-eslint/commit/297086154acc568a0ae8eb41c8977b7a7ba4e0ed))





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)


Expand Down
14 changes: 8 additions & 6 deletions docs/Getting_Started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugi
Next, create a `.eslintrc.cjs` config file in the root of your project, and populate it with the following:

```js title=".eslintrc.cjs"
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -57,22 +58,23 @@ ESLint will lint all TypeScript compatible files within the current folder, and

## Details

- You can read more about configuring ESLint [in their documentation on configuration](https://eslint.org/docs/user-guide/configuring).
- You can read more about the rules provided by ESLint [in their documentation on their rules](https://eslint.org/docs/rules/).
- You can read more about the rules provided by typescript-eslint in [our rules documentation](/rules).

### Configuration Values

- `parser: '@typescript-eslint/parser'` tells ESLint to use the [`@typescript-eslint/parser`](./architecture/Parser.mdx) package you installed to parse your source files.
- This is required, or else ESLint will throw errors as it tries to parse TypeScript code as if it were regular JavaScript.
- `plugins: ['@typescript-eslint']` tells ESLint to load the [`@typescript-eslint/eslint-plugin`](./architecture/ESLint_Plugin.mdx) package as a plugin.
- This allows you to use typescript-eslint's rules within your codebase.
- `extends: [ ... ]` tells ESLint that your config extends the given configurations.
- `eslint:recommended` is ESLint's inbuilt "recommended" config - it turns on a small, sensible set of rules which lint for well-known best-practices.
- `plugin:@typescript-eslint/recommended` is our "recommended" config - it's similar to `eslint:recommended`, except it turns on TypeScript-specific rules from our plugin.
- `root: true` is a generally good ESLint practice to indicate this file is the root-level one used by the project and ESLint should not search beyond this directory for config files.

## Next Steps

We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit the next page for a setup guide](./linting/Typed_Linting.mdx 'Visit the next page for a typed rules setup guide').

If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./linting/Troubleshooting.mdx).

### Documentation Resources

- You can read more about configuring ESLint [in their documentation on configuration](https://eslint.org/docs/user-guide/configuring).
- You can read more about the rules provided by ESLint [in their documentation on their rules](https://eslint.org/docs/rules/).
- You can read more about the rules provided by typescript-eslint in [our rules documentation](/rules).
1 change: 1 addition & 0 deletions docs/linting/Typed_Linting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Some typescript-eslint rules utilize the awesome power of TypeScript's type chec
To tap into TypeScript's additional powers, there are two small changes you need to make to your config file:

```js title=".eslintrc.js"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
Expand Down
1 change: 1 addition & 0 deletions docs/linting/troubleshooting/Formatting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ You can then configure your formatter separately from ESLint.
Using this config by adding it to the end of your `extends`:

```js title=".eslintrc.js"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
Expand Down
2 changes: 2 additions & 0 deletions docs/linting/typed-linting/Monorepos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Paths may be provided as [Node globs](https://github.com/isaacs/node-glob/blob/f
For each file being linted, the first matching project path will be used as its backing TSConfig.

```js title=".eslintrc.js"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
Expand All @@ -68,6 +69,7 @@ Using wide globs `**` in your `parserOptions.project` may degrade linting perfor
Instead of globs that use `**` to recursively check all folders, prefer paths that use a single `*` at a time.

```js title=".eslintrc.js"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.59.0",
"version": "5.59.1",
"npmClient": "yarn",
"useWorkspaces": true,
"stream": true
Expand Down
8 changes: 8 additions & 0 deletions packages/ast-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)

**Note:** Version bump only for package @typescript-eslint/ast-spec





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)

**Note:** Version bump only for package @typescript-eslint/ast-spec
Expand Down
2 changes: 1 addition & 1 deletion packages/ast-spec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/ast-spec",
"version": "5.59.0",
"version": "5.59.1",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
Expand Down
8 changes: 8 additions & 0 deletions packages/eslint-plugin-internal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)

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





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-internal",
"version": "5.59.0",
"version": "5.59.1",
"private": true,
"main": "dist/index.js",
"scripts": {
Expand All @@ -14,9 +14,9 @@
},
"dependencies": {
"@types/prettier": "*",
"@typescript-eslint/scope-manager": "5.59.0",
"@typescript-eslint/type-utils": "5.59.0",
"@typescript-eslint/utils": "5.59.0",
"@typescript-eslint/scope-manager": "5.59.1",
"@typescript-eslint/type-utils": "5.59.1",
"@typescript-eslint/utils": "5.59.1",
"prettier": "*"
}
}
8 changes: 8 additions & 0 deletions packages/eslint-plugin-tslint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)

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





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-tslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-tslint",
"version": "5.59.0",
"version": "5.59.1",
"main": "dist/index.js",
"typings": "src/index.ts",
"description": "ESLint plugin that wraps a TSLint configuration and lints the whole source using TSLint",
Expand Down Expand Up @@ -46,15 +46,15 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@typescript-eslint/utils": "5.59.0"
"@typescript-eslint/utils": "5.59.1"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0",
"tslint": "^5.0.0 || ^6.0.0",
"typescript": "*"
},
"devDependencies": {
"@typescript-eslint/parser": "5.59.0"
"@typescript-eslint/parser": "5.59.1"
},
"funding": {
"type": "opencollective",
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)


### Bug Fixes

* **eslint-plugin:** [prefer-regexp-exec] skip malformed regexes ([#6935](https://github.com/typescript-eslint/typescript-eslint/issues/6935)) ([05ed60e](https://github.com/typescript-eslint/typescript-eslint/commit/05ed60e25f1de9d1bb83d56c81a349130960bec8))
* **eslint-plugin:** [unified-signatures] no parameters function ([#6940](https://github.com/typescript-eslint/typescript-eslint/issues/6940)) ([2970861](https://github.com/typescript-eslint/typescript-eslint/commit/297086154acc568a0ae8eb41c8977b7a7ba4e0ed))





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)


Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "5.59.0",
"version": "5.59.1",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
Expand Down Expand Up @@ -55,9 +55,9 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.59.0",
"@typescript-eslint/type-utils": "5.59.0",
"@typescript-eslint/utils": "5.59.0",
"@typescript-eslint/scope-manager": "5.59.1",
"@typescript-eslint/type-utils": "5.59.1",
"@typescript-eslint/utils": "5.59.1",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
Expand All @@ -71,7 +71,7 @@
"@types/marked": "*",
"@types/natural-compare": "*",
"@types/prettier": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "5.59.0",
"@typescript-eslint/rule-schema-to-typescript-types": "5.59.1",
"cross-fetch": "*",
"jest-specific-snapshot": "*",
"json-schema": "*",
Expand Down
7 changes: 6 additions & 1 deletion packages/eslint-plugin/src/rules/prefer-regexp-exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ export default createRule({
argumentNode.type === AST_NODE_TYPES.Literal &&
typeof argumentNode.value === 'string'
) {
const regExp = RegExp(argumentNode.value);
let regExp: RegExp;
try {
regExp = RegExp(argumentNode.value);
} catch {
return;
}
return context.report({
node: memberNode.property,
messageId: 'regExpExecOverStringMatch',
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/unified-signatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ export default util.createRule<Options, MessageIds>({
b.typeParameters !== undefined ? b.typeParameters.params : undefined;

if (ignoreDifferentlyNamedParameters) {
for (let i = 0; i < a.params.length; i += 1) {
const commonParamsLength = Math.min(a.params.length, b.params.length);
for (let i = 0; i < commonParamsLength; i += 1) {
if (
a.params[i].type === b.params[i].type &&
getStaticParameterName(a.params[i]) !==
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/tests/rules/prefer-regexp-exec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ const matchCount = (str: string, re: RegExp) => {
return (str.match(re) || []).length;
};
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/6928
`
function test(str: string) {
str.match('[a-z');
}
`,
],
invalid: [
{
Expand Down
22 changes: 22 additions & 0 deletions packages/eslint-plugin/tests/rules/unified-signatures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@ function f(v: number, u?: string): void {}
},
{
code: `
function f(v: boolean): number;
function f(): string;
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(v: boolean, u: boolean): number;
function f(v: boolean): string;
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(v: number, u?: string): void {}
function f(v: number): void;
function f(): string;
`,
options: [{ ignoreDifferentlyNamedParameters: true }],
},
{
code: `
function f(a: boolean, ...c: number[]): void;
function f(a: boolean, ...d: string[]): void;
function f(a: boolean, ...c: (number | string)[]): void {}
Expand Down
8 changes: 8 additions & 0 deletions packages/parser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.59.1](https://github.com/typescript-eslint/typescript-eslint/compare/v5.59.0...v5.59.1) (2023-04-24)

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





# [5.59.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.58.0...v5.59.0) (2023-04-17)

**Note:** Version bump only for package @typescript-eslint/parser
Expand Down
10 changes: 5 additions & 5 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
"version": "5.59.0",
"version": "5.59.1",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"files": [
"dist",
Expand Down Expand Up @@ -51,10 +51,10 @@
"eslint": "^7.0.0 || ^8.0.0"
},
"dependencies": {
"@typescript-eslint/scope-manager": "5.59.0",
"@typescript-eslint/types": "5.59.0",
"@typescript-eslint/typescript-estree": "5.59.0",
"@typescript-eslint/visitor-keys": "5.59.0",
"@typescript-eslint/scope-manager": "5.59.1",
"@typescript-eslint/types": "5.59.1",
"@typescript-eslint/typescript-estree": "5.59.1",
"@typescript-eslint/visitor-keys": "5.59.1",
"debug": "^4.3.4"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/repo-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/repo-tools",
"version": "5.59.0",
"version": "5.59.1",
"private": true,
"scripts": {
"build": "tsc -b tsconfig.build.json",
Expand Down

0 comments on commit 3e3b789

Please sign in to comment.