Skip to content

Commit

Permalink
Merge branch 'main' into fix/8540
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Mar 6, 2024
2 parents 687e3e3 + 3ac824b commit c340d40
Show file tree
Hide file tree
Showing 133 changed files with 1,417 additions and 850 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Expand Up @@ -53,7 +53,6 @@ module.exports = {

// TODO(#7130): Investigate changing these in or removing these from presets
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',

//
// our plugin :D
Expand Down Expand Up @@ -91,6 +90,12 @@ module.exports = {
allowBitwiseExpressions: true,
},
],
'@typescript-eslint/prefer-string-starts-ends-with': [
'error',
{
allowSingleElementEquality: 'always',
},
],
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,16 @@
## 7.1.1 (2024-03-04)


### 🩹 Fixes

- **typescript-eslint:** apply `ignores` to all extended configs passed to `config` helper function ([#8567](https://github.com/typescript-eslint/typescript-eslint/pull/8567))

### ❤️ Thank You

- auvred @auvred

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.

## 7.1.0 (2024-02-26)


Expand Down
3 changes: 2 additions & 1 deletion eslint.config.mjs
Expand Up @@ -132,7 +132,6 @@ export default tseslint.config(
{ allowIIFEs: true },
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-constant-condition': 'off',
'@typescript-eslint/no-unnecessary-condition': [
'error',
Expand Down Expand Up @@ -297,6 +296,7 @@ export default tseslint.config(
// eslint-plugin-unicorn
//

'jsdoc/informative-docs': 'error',
'unicorn/no-typeof-undefined': 'error',
},
},
Expand Down Expand Up @@ -342,6 +342,7 @@ export default tseslint.config(
'error',
{ allow: ['arrowFunctions'] },
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -62,9 +62,9 @@
"@babel/types": "^7.23.3",
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "^8.56.0",
"@nx/eslint": "18.0.4",
"@nx/jest": "18.0.4",
"@nx/workspace": "18.0.4",
"@nx/eslint": "18.0.5",
"@nx/jest": "18.0.5",
"@nx/workspace": "18.0.5",
"@swc/core": "^1.4.0",
"@swc/jest": "^0.2.26",
"@types/babel__code-frame": "^7.0.3",
Expand All @@ -85,7 +85,7 @@
"cross-fetch": "^4.0.0",
"cspell": "^7.0.0",
"downlevel-dts": ">=0.11.0",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^5.2.1",
Expand All @@ -110,7 +110,7 @@
"markdownlint-cli": "^0.39.0",
"ncp": "^2.0.0",
"netlify": "^13.1.9",
"nx": "18.0.4",
"nx": "18.0.5",
"prettier": "3.2.5",
"pretty-format": "^29.6.2",
"raw-loader": "^4.0.2",
Expand All @@ -132,7 +132,7 @@
"@types/estree": "link:./tools/dummypkg",
"@types/node": "^20.0.0",
"@types/react": "^18.2.14",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-visitor-keys": "^3.4.1",
"jest-config": "^29",
"jest-resolve": "^29",
Expand Down
6 changes: 6 additions & 0 deletions packages/ast-spec/CHANGELOG.md
@@ -1,3 +1,9 @@
## 7.1.1 (2024-03-04)

This was a version bump only for ast-spec to align it with other projects, there were no code changes.

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.

## 7.1.0 (2024-02-26)

This was a version bump only for ast-spec to align it with other projects, there were no code changes.
Expand Down
2 changes: 1 addition & 1 deletion packages/ast-spec/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/ast-spec",
"version": "7.1.0",
"version": "7.1.1",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin-internal/CHANGELOG.md
@@ -1,3 +1,9 @@
## 7.1.1 (2024-03-04)

This was a version bump only for eslint-plugin-internal to align it with other projects, there were no code changes.

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.

## 7.1.0 (2024-02-26)

This was a version bump only for eslint-plugin-internal to align it with other projects, there were no code changes.
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin-internal/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin-internal",
"version": "7.1.0",
"version": "7.1.1",
"private": true,
"main": "dist/index.js",
"types": "index.d.ts",
Expand All @@ -15,10 +15,10 @@
},
"dependencies": {
"@prettier/sync": "^0.5.0",
"@typescript-eslint/rule-tester": "7.1.0",
"@typescript-eslint/scope-manager": "7.1.0",
"@typescript-eslint/type-utils": "7.1.0",
"@typescript-eslint/utils": "7.1.0",
"@typescript-eslint/rule-tester": "7.1.1",
"@typescript-eslint/scope-manager": "7.1.1",
"@typescript-eslint/type-utils": "7.1.1",
"@typescript-eslint/utils": "7.1.1",
"prettier": "^3.0.3"
},
"devDependencies": {
Expand Down
Expand Up @@ -55,6 +55,7 @@ function getExpectedIndentForNode(
sourceCodeLines: string[],
): number {
const lineIdx = node.loc.start.line - 1;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const indent = START_OF_LINE_WHITESPACE_MATCHER.exec(
sourceCodeLines[lineIdx],
)![1];
Expand Down Expand Up @@ -348,6 +349,7 @@ export default createRule<Options, MessageIds>({
// +2 because we expect the string contents are indented one level
const expectedIndent = parentIndent + 2;

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const firstLineIndent = START_OF_LINE_WHITESPACE_MATCHER.exec(
lines[0],
)![1];
Expand All @@ -370,6 +372,7 @@ export default createRule<Options, MessageIds>({
continue;
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const matches = START_OF_LINE_WHITESPACE_MATCHER.exec(line)!;

const indent = matches[1];
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/CHANGELOG.md
@@ -1,3 +1,9 @@
## 7.1.1 (2024-03-04)

This was a version bump only for eslint-plugin to align it with other projects, there were no code changes.

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.

## 7.1.0 (2024-02-26)


Expand Down
Expand Up @@ -52,6 +52,26 @@ foo.startsWith('bar');
foo.endsWith('bar');
```

<!--/tabs-->

## Options

### `allowSingleElementEquality`

If switched to `'always'`, the rule will allow equality checks against the first or last character in a string.
This can be preferable in projects that don't deal with special character encodings and prefer a more succinct style.

The following code is considered incorrect by default, but is allowed with `allowSingleElementEquality: 'always'`:

```ts option='{ "allowSingleElementEquality": "always" }' showPlaygroundButton
declare const text: string;

text[0] === 'a';
text[0] === text[0].toUpperCase();
text[0] === text[1];
text[text.length - 1] === 'b';
```

## When Not To Use It

If you don't mind which style of string checking is used, you can turn this rule off safely.
Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "7.1.0",
"version": "7.1.1",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
Expand Down Expand Up @@ -61,10 +61,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "7.1.0",
"@typescript-eslint/type-utils": "7.1.0",
"@typescript-eslint/utils": "7.1.0",
"@typescript-eslint/visitor-keys": "7.1.0",
"@typescript-eslint/scope-manager": "7.1.1",
"@typescript-eslint/type-utils": "7.1.1",
"@typescript-eslint/utils": "7.1.1",
"@typescript-eslint/visitor-keys": "7.1.1",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.4",
Expand All @@ -76,8 +76,8 @@
"@types/debug": "*",
"@types/marked": "*",
"@types/natural-compare": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "7.1.0",
"@typescript-eslint/rule-tester": "7.1.0",
"@typescript-eslint/rule-schema-to-typescript-types": "7.1.1",
"@typescript-eslint/rule-tester": "7.1.1",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
"cross-env": "^7.0.3",
Expand Down
6 changes: 6 additions & 0 deletions packages/eslint-plugin/src/index.ts
Expand Up @@ -6,10 +6,13 @@ import disableTypeChecked from './configs/disable-type-checked';
import eslintRecommended from './configs/eslint-recommended';
import recommended from './configs/recommended';
import recommendedTypeChecked from './configs/recommended-type-checked';
import recommendedTypeCheckedOnly from './configs/recommended-type-checked-only';
import strict from './configs/strict';
import strictTypeChecked from './configs/strict-type-checked';
import strictTypeCheckedOnly from './configs/strict-type-checked-only';
import stylistic from './configs/stylistic';
import stylisticTypeChecked from './configs/stylistic-type-checked';
import stylisticTypeCheckedOnly from './configs/stylistic-type-checked-only';
import rules from './rules';

// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
Expand All @@ -28,10 +31,13 @@ export = {
/** @deprecated - please use "recommended-type-checked" instead. */
'recommended-requiring-type-checking': recommendedTypeChecked,
'recommended-type-checked': recommendedTypeChecked,
'recommended-type-checked-only': recommendedTypeCheckedOnly,
strict,
'strict-type-checked': strictTypeChecked,
'strict-type-checked-only': strictTypeCheckedOnly,
stylistic,
'stylistic-type-checked': stylisticTypeChecked,
'stylistic-type-checked-only': stylisticTypeCheckedOnly,
},
meta: {
name,
Expand Down
Expand Up @@ -124,10 +124,6 @@ export default createRule({
}
}

/**
* Check the body for overload methods.
* @param node the body to be inspected.
*/
function checkBodyForOverloadMethods(node: RuleNode): void {
const members = getMembers(node);

Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/ban-ts-comment.ts
Expand Up @@ -131,6 +131,7 @@ export default createRule<[Options], MessageIds>({
if (!match) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { directive, description } = match.groups!;

const fullDirective = `ts-${directive}` as keyof Options;
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/block-spacing.ts
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';

Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/brace-style.ts
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { TSESTree } from '@typescript-eslint/utils';

import type {
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/comma-spacing.ts
Expand Up @@ -71,6 +71,7 @@ export default createRule<Options, MessageIds>({
for (const element of node.elements) {
let token: TSESTree.Token | null;
if (element == null) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
token = context.sourceCode.getTokenAfter(previousToken!);
if (token && isCommaToken(token)) {
ignoredTokens.add(token);
Expand Down
@@ -1,7 +1,7 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import { createRule } from '../util';
import { createRule, nullThrows, NullThrowsReasons } from '../util';

type MessageIds = 'preferConstructor' | 'preferTypeAnnotation';
type Options = ['constructor' | 'type-annotation'];
Expand Down Expand Up @@ -94,7 +94,10 @@ export default createRule<Options, MessageIds>({
}
// If the property's computed, we have to attach the
// annotation after the square bracket, not the enclosed expression
return context.sourceCode.getTokenAfter(node.key)!;
return nullThrows(
context.sourceCode.getTokenAfter(node.key),
NullThrowsReasons.MissingToken(']', 'key'),
);
}
return [
fixer.remove(typeArguments),
Expand Down
18 changes: 10 additions & 8 deletions packages/eslint-plugin/src/rules/consistent-type-assertions.ts
Expand Up @@ -9,6 +9,8 @@ import {
isClosingParenToken,
isOpeningParenToken,
isParenthesized,
nullThrows,
NullThrowsReasons,
} from '../util';
import { getWrappedCode } from '../util/getWrappedCode';

Expand Down Expand Up @@ -109,14 +111,14 @@ export default createRule<Options, MessageIds>({
let afterCount = 0;

if (isParenthesized(node, context.sourceCode)) {
const bodyOpeningParen = context.sourceCode.getTokenBefore(
node,
isOpeningParenToken,
)!;
const bodyClosingParen = context.sourceCode.getTokenAfter(
node,
isClosingParenToken,
)!;
const bodyOpeningParen = nullThrows(
context.sourceCode.getTokenBefore(node, isOpeningParenToken),
NullThrowsReasons.MissingToken('(', 'node'),
);
const bodyClosingParen = nullThrows(
context.sourceCode.getTokenAfter(node, isClosingParenToken),
NullThrowsReasons.MissingToken(')', 'node'),
);

beforeCount = node.range[0] - bodyOpeningParen.range[0];
afterCount = bodyClosingParen.range[1] - node.range[1];
Expand Down

0 comments on commit c340d40

Please sign in to comment.