Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Nov 14, 2023
2 parents 55e7807 + 7e353cb commit 9abb55c
Show file tree
Hide file tree
Showing 190 changed files with 1,999 additions and 1,597 deletions.
12 changes: 0 additions & 12 deletions .yarn/patches/react-split-pane-npm-0.1.92-93dbf51dff.patch

This file was deleted.

25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.10.0...v6.11.0) (2023-11-13)


### Bug Fixes

* **eslint-plugin:** [explicit-function-return-type] support JSX attributes in `allowTypedFunctionExpressions` ([#7553](https://github.com/typescript-eslint/typescript-eslint/issues/7553)) ([be2777c](https://github.com/typescript-eslint/typescript-eslint/commit/be2777c5338669836d786f9a7806f499fd566dcd))
* **eslint-plugin:** [no-unnecessary-qualifier] handle nested namespace id ([#7883](https://github.com/typescript-eslint/typescript-eslint/issues/7883)) ([a668f5b](https://github.com/typescript-eslint/typescript-eslint/commit/a668f5b10e7b1570c732312ad9ccab3431459c1b))


### Features

* add `no-unsafe-unary-minus` rule ([#7390](https://github.com/typescript-eslint/typescript-eslint/issues/7390)) ([c4709c2](https://github.com/typescript-eslint/typescript-eslint/commit/c4709c2861f8ea4e18c289218a75224d6bb76193))
* add types for flat config files ([#7273](https://github.com/typescript-eslint/typescript-eslint/issues/7273)) ([66cd0c0](https://github.com/typescript-eslint/typescript-eslint/commit/66cd0c0535e5de1b46ba337919a9a92748d2b0a6))
* allow typescript@5.3.0-RC as devDependency ([#7821](https://github.com/typescript-eslint/typescript-eslint/issues/7821)) ([b6c40b4](https://github.com/typescript-eslint/typescript-eslint/commit/b6c40b42b68d5567c7468030ee45b9b84bec4c4d))
* **eslint-plugin:** no-unsafe-enum-comparison handles switch cases ([#7898](https://github.com/typescript-eslint/typescript-eslint/issues/7898)) ([72cb9e4](https://github.com/typescript-eslint/typescript-eslint/commit/72cb9e4ed397d35a8d8838d27dedbace6122179c))
* **typescript-estree:** skip `isTTY` version check if user passes `loggerFn` on unsupported TypeScript version warning ([#7739](https://github.com/typescript-eslint/typescript-eslint/issues/7739)) ([9656e13](https://github.com/typescript-eslint/typescript-eslint/commit/9656e135e78d9346d326d0c78ba772a5596c1812))
* **utils:** add ESLint `CodePath` selector types ([#7551](https://github.com/typescript-eslint/typescript-eslint/issues/7551)) ([99a026f](https://github.com/typescript-eslint/typescript-eslint/commit/99a026fe41b4b169914352fe66e7d5d687b300bf))
* **utils:** update types to reflect `RuleContext` and `SourceCode` changes and deprecations ([#7812](https://github.com/typescript-eslint/typescript-eslint/issues/7812)) ([b73d8b2](https://github.com/typescript-eslint/typescript-eslint/commit/b73d8b21dea9c6697a68039ffba848d21b04402c))

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.





# [6.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.9.1...v6.10.0) (2023-11-06)


Expand Down
2 changes: 1 addition & 1 deletion docs/maintenance/Dependency_Version_Upgrades.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: Dependency Version Upgrades
Our published packages only depend on `@babel/*` packages as devDependencies.
You can generally upgrade those dependencies with:

1. `yarn add -DW @babel/code-frame @babel/core @babel/eslint-parser @babel/parser @babel/types`
1. `yarn add -D @babel/code-frame @babel/core @babel/eslint-parser @babel/parser @babel/types`
2. `npx nx run ast-spec:test -u`

The fixtures under `packages/ast-spec/` describe how the files are parsed under both Babel and our (TSESTree) parser.
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "6.10.0",
"version": "6.11.0",
"npmClient": "yarn",
"stream": true,
"command": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@types/babel__core": "^7.20.1",
"@types/debug": "^4.1.8",
"@types/is-glob": "^4.0.2",
"@types/jest": "29.5.6",
"@types/jest": "29.5.8",
"@types/jest-specific-snapshot": "^0.5.6",
"@types/marked": "^5.0.0",
"@types/natural-compare": "^1.4.1",
Expand Down Expand Up @@ -99,7 +99,7 @@
"jest-diff": "^29.6.2",
"jest-snapshot": "^29.6.2",
"jest-specific-snapshot": "^8.0.0",
"lerna": "7.4.1",
"lerna": "7.4.2",
"lint-staged": "^15.0.0",
"make-dir": "^4.0.0",
"markdownlint-cli": "^0.37.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/ast-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.10.0...v6.11.0) (2023-11-13)


### Features

* allow typescript@5.3.0-RC as devDependency ([#7821](https://github.com/typescript-eslint/typescript-eslint/issues/7821)) ([b6c40b4](https://github.com/typescript-eslint/typescript-eslint/commit/b6c40b42b68d5567c7468030ee45b9b84bec4c4d))

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.





# [6.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.9.1...v6.10.0) (2023-11-06)

**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": "6.10.0",
"version": "6.11.0",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
Expand Down
10 changes: 10 additions & 0 deletions packages/eslint-plugin-internal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.10.0...v6.11.0) (2023-11-13)

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

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.





# [6.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.9.1...v6.10.0) (2023-11-06)

**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal
Expand Down
10 changes: 5 additions & 5 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": "6.10.0",
"version": "6.11.0",
"private": true,
"main": "dist/index.js",
"scripts": {
Expand All @@ -14,10 +14,10 @@
},
"dependencies": {
"@prettier/sync": "*",
"@typescript-eslint/rule-tester": "6.10.0",
"@typescript-eslint/scope-manager": "6.10.0",
"@typescript-eslint/type-utils": "6.10.0",
"@typescript-eslint/utils": "6.10.0",
"@typescript-eslint/rule-tester": "6.11.0",
"@typescript-eslint/scope-manager": "6.11.0",
"@typescript-eslint/type-utils": "6.11.0",
"@typescript-eslint/utils": "6.11.0",
"prettier": "^3.0.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ This rule simply warns against using them, as using them will likely introduce t
*/

const BANNED_PROPERTIES = [
// {
// type: 'Node',
// property: 'parent',
// fixWith: null,
// },
{
type: 'Symbol',
property: 'declarations',
Expand Down Expand Up @@ -87,10 +82,6 @@ export default createRule({
messageId: 'suggestedFix',
data: banned,
fix(fixer): TSESLint.RuleFix | null {
if (banned.fixWith == null) {
return null;
}

return fixer.replaceText(node.property, banned.fixWith);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import prettier from '@prettier/sync';
import { getContextualType } from '@typescript-eslint/type-utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
import { getSourceCode } from '@typescript-eslint/utils/eslint-utils';

import { createRule } from '../util';

Expand Down Expand Up @@ -147,7 +148,7 @@ export default createRule<Options, MessageIds>({
},
],
create(context, [{ formatWithPrettier }]) {
const sourceCode = context.getSourceCode();
const sourceCode = getSourceCode(context);
const services = ESLintUtils.getParserServices(context);
const checker = services.program.getTypeChecker();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default createRule({
return {
Literal(node: TSESTree.Literal): void {
if (
node.parent?.type === AST_NODE_TYPES.TSEnumMember &&
node.parent.parent?.type === AST_NODE_TYPES.TSEnumDeclaration &&
node.parent.type === AST_NODE_TYPES.TSEnumMember &&
node.parent.parent.type === AST_NODE_TYPES.TSEnumDeclaration &&
['AST_NODE_TYPES', 'AST_TOKEN_TYPES', 'DefinitionType'].includes(
node.parent.parent.id.name,
)
Expand Down
13 changes: 13 additions & 0 deletions packages/eslint-plugin-tslint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.10.0...v6.11.0) (2023-11-13)


### Features

* add types for flat config files ([#7273](https://github.com/typescript-eslint/typescript-eslint/issues/7273)) ([66cd0c0](https://github.com/typescript-eslint/typescript-eslint/commit/66cd0c0535e5de1b46ba337919a9a92748d2b0a6))

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.





# [6.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.9.1...v6.10.0) (2023-11-06)

**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": "6.10.0",
"version": "6.11.0",
"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,7 +46,7 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@typescript-eslint/utils": "6.10.0"
"@typescript-eslint/utils": "6.11.0"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0",
Expand All @@ -55,7 +55,7 @@
},
"devDependencies": {
"@types/lodash": "*",
"@typescript-eslint/parser": "6.10.0",
"@typescript-eslint/parser": "6.11.0",
"jest": "29.7.0",
"prettier": "^3.0.3",
"rimraf": "*"
Expand Down
11 changes: 8 additions & 3 deletions packages/eslint-plugin-tslint/src/rules/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ESLintUtils } from '@typescript-eslint/utils';
import {
getCwd,
getFilename,
getSourceCode,
} from '@typescript-eslint/utils/eslint-utils';
import path from 'path';
import type { RuleSeverity } from 'tslint';
import { Configuration } from 'tslint';
Expand Down Expand Up @@ -119,8 +124,8 @@ export default createRule<Options, MessageIds>({
context,
[{ rules: tslintRules, rulesDirectory: tslintRulesDirectory, lintFile }],
) {
const fileName = path.resolve(context.getCwd(), context.getFilename());
const sourceCode = context.getSourceCode().text;
const fileName = path.resolve(getCwd(context), getFilename(context));
const sourceCode = getSourceCode(context).text;
const services = ESLintUtils.getParserServices(context);
const program = services.program;

Expand All @@ -146,7 +151,7 @@ export default createRule<Options, MessageIds>({
/**
* Format the TSLint results for ESLint
*/
if (result.failures?.length) {
if (result.failures.length) {
result.failures.forEach(failure => {
const start = failure.getStartPosition().getLineAndCharacter();
const end = failure.getEndPosition().getLineAndCharacter();
Expand Down
23 changes: 23 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [6.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.10.0...v6.11.0) (2023-11-13)


### Bug Fixes

* **eslint-plugin:** [explicit-function-return-type] support JSX attributes in `allowTypedFunctionExpressions` ([#7553](https://github.com/typescript-eslint/typescript-eslint/issues/7553)) ([be2777c](https://github.com/typescript-eslint/typescript-eslint/commit/be2777c5338669836d786f9a7806f499fd566dcd))
* **eslint-plugin:** [no-unnecessary-qualifier] handle nested namespace id ([#7883](https://github.com/typescript-eslint/typescript-eslint/issues/7883)) ([a668f5b](https://github.com/typescript-eslint/typescript-eslint/commit/a668f5b10e7b1570c732312ad9ccab3431459c1b))


### Features

* add `no-unsafe-unary-minus` rule ([#7390](https://github.com/typescript-eslint/typescript-eslint/issues/7390)) ([c4709c2](https://github.com/typescript-eslint/typescript-eslint/commit/c4709c2861f8ea4e18c289218a75224d6bb76193))
* add types for flat config files ([#7273](https://github.com/typescript-eslint/typescript-eslint/issues/7273)) ([66cd0c0](https://github.com/typescript-eslint/typescript-eslint/commit/66cd0c0535e5de1b46ba337919a9a92748d2b0a6))
* allow typescript@5.3.0-RC as devDependency ([#7821](https://github.com/typescript-eslint/typescript-eslint/issues/7821)) ([b6c40b4](https://github.com/typescript-eslint/typescript-eslint/commit/b6c40b42b68d5567c7468030ee45b9b84bec4c4d))
* **eslint-plugin:** no-unsafe-enum-comparison handles switch cases ([#7898](https://github.com/typescript-eslint/typescript-eslint/issues/7898)) ([72cb9e4](https://github.com/typescript-eslint/typescript-eslint/commit/72cb9e4ed397d35a8d8838d27dedbace6122179c))
* **utils:** add ESLint `CodePath` selector types ([#7551](https://github.com/typescript-eslint/typescript-eslint/issues/7551)) ([99a026f](https://github.com/typescript-eslint/typescript-eslint/commit/99a026fe41b4b169914352fe66e7d5d687b300bf))

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.





# [6.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v6.9.1...v6.10.0) (2023-11-06)


Expand Down
22 changes: 12 additions & 10 deletions packages/eslint-plugin/docs/rules/no-unsafe-enum-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ description: 'Disallow comparing an enum value with a non-enum value.'
>
> See **https://typescript-eslint.io/rules/no-unsafe-enum-comparison** for documentation.
The TypeScript compiler can be surprisingly lenient when working with enums.
For example, it will allow you to compare enum values against numbers even though they might not have any type overlap:
The TypeScript compiler can be surprisingly lenient when working with enums. String enums are widely considered to be safer than number enums, but even string enums have some pitfalls. For example, it is allowed to compare enum values against literals:

```ts
enum Fruit {
Apple,
Banana,
enum Vegetable {
Asparagus = 'asparagus',
}

declare let fruit: Fruit;
declare const vegetable: Vegetable;

fruit === 999; // No error
vegetable === 'asparagus'; // No error
```

This rule flags when an enum typed value is compared to a non-enum `number`.
The above code snippet should instead be written as `vegetable === Vegetable.Asparagus`. Allowing literals in comparisons subverts the point of using enums in the first place. By enforcing comparisons with properly typed enums:

- It makes a codebase more resilient to enum members changing values.
- It allows for code IDEs to use the "Rename Symbol" feature to quickly rename an enum.
- It aligns code to the proper enum semantics of referring to them by name and treating their values as implementation details.

## Examples

Expand All @@ -35,7 +37,7 @@ enum Fruit {

declare let fruit: Fruit;

fruit === 999;
fruit === 0;
```

```ts
Expand All @@ -57,7 +59,7 @@ enum Fruit {

declare let fruit: Fruit;

fruit === Fruit.Banana;
fruit === Fruit.Apple;
```

```ts
Expand Down
14 changes: 7 additions & 7 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": "6.10.0",
"version": "6.11.0",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
Expand Down Expand Up @@ -57,10 +57,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.10.0",
"@typescript-eslint/type-utils": "6.10.0",
"@typescript-eslint/utils": "6.10.0",
"@typescript-eslint/visitor-keys": "6.10.0",
"@typescript-eslint/scope-manager": "6.11.0",
"@typescript-eslint/type-utils": "6.11.0",
"@typescript-eslint/utils": "6.11.0",
"@typescript-eslint/visitor-keys": "6.11.0",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.4",
Expand All @@ -73,8 +73,8 @@
"@types/debug": "*",
"@types/marked": "*",
"@types/natural-compare": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "6.10.0",
"@typescript-eslint/rule-tester": "6.10.0",
"@typescript-eslint/rule-schema-to-typescript-types": "6.11.0",
"@typescript-eslint/rule-tester": "6.11.0",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
"cross-fetch": "*",
Expand Down

0 comments on commit 9abb55c

Please sign in to comment.