Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(eslint-plugin): [no-floating-promises] disable checkThenables by default for v8 #9509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions 31 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
## 7.16.0 (2024-07-08)


### 🚀 Features

- **ast-spec:** add parent property to AccessorProperty node types ([#9487](https://github.com/typescript-eslint/typescript-eslint/pull/9487))
- **eslint-plugin:** [no-unnecessary-parameter-property-assignment] add new rule ([#8903](https://github.com/typescript-eslint/typescript-eslint/pull/8903))
- **eslint-plugin:** add support for nested namespaces to unsafe-member-access ([#9478](https://github.com/typescript-eslint/typescript-eslint/pull/9478))
- **eslint-plugin:** [no-floating-promises] add checkThenables option ([#9263](https://github.com/typescript-eslint/typescript-eslint/pull/9263))
- **rule-tester:** stricter rule test validations ([#9086](https://github.com/typescript-eslint/typescript-eslint/pull/9086))

### 🩹 Fixes

- **deps:** update dependency @eslint-community/regexpp to v4.11.0 ([#9497](https://github.com/typescript-eslint/typescript-eslint/pull/9497))
- **eslint-plugin:** [no-floating-promises] add `suggestions` to tests from #9263 `checkThenables` ([#9515](https://github.com/typescript-eslint/typescript-eslint/pull/9515), [#9263](https://github.com/typescript-eslint/typescript-eslint/issues/9263))
- **eslint-plugin:** [restrict-template-expressions] don't report tuples if `allowArray` option is enabled ([#9492](https://github.com/typescript-eslint/typescript-eslint/pull/9492))
- **utils:** context.parserPath may be undefined ([#9486](https://github.com/typescript-eslint/typescript-eslint/pull/9486))
- **website:** react key error on internal pages of website ([#9506](https://github.com/typescript-eslint/typescript-eslint/pull/9506))

### ❤️ Thank You

- Abraham Guo
- auvred @auvred
- Josh Goldberg ✨
- Juan Sanchez @JSanchezIO
- Vinccool96
- YeonJuan @yeonjuan
- Yukihiro Hasegawa @y-hsgw

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.15.0 (2024-07-01)


Expand Down
1 change: 1 addition & 0 deletions 1 eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default tseslint.config(
{ commentPattern: '.*intentional fallthrough.*' },
],
'one-var': ['error', 'never'],
'prefer-arrow-callback': 'error',
'prefer-object-has-own': 'error',

//
Expand Down
22 changes: 22 additions & 0 deletions 22 packages/ast-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 7.16.0 (2024-07-08)


### 🩹 Fixes

- **deps:** update dependency @eslint-community/regexpp to v4.11.0

- **website:** react key error on internal pages of website


### ❤️ Thank You

- Abraham Guo
- auvred
- Josh Goldberg ✨
- Juan Sanchez
- Vinccool96
- YeonJuan
- Yukihiro Hasegawa

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.15.0 (2024-07-01)

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 2 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": "7.15.0",
"version": "7.16.0",
"description": "Complete specification for the TypeScript-ESTree AST",
"private": true,
"keywords": [
Expand Down
22 changes: 22 additions & 0 deletions 22 packages/eslint-plugin-internal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 7.16.0 (2024-07-08)


### 🩹 Fixes

- **deps:** update dependency @eslint-community/regexpp to v4.11.0

- **website:** react key error on internal pages of website


### ❤️ Thank You

- Abraham Guo
- auvred
- Josh Goldberg ✨
- Juan Sanchez
- Vinccool96
- YeonJuan
- Yukihiro Hasegawa

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.15.0 (2024-07-01)

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 10 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": "7.15.0",
"version": "7.16.0",
"private": true,
"main": "dist/index.js",
"types": "index.d.ts",
Expand All @@ -15,10 +15,10 @@
},
"dependencies": {
"@prettier/sync": "^0.5.1",
"@typescript-eslint/rule-tester": "7.15.0",
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/utils": "7.15.0",
"@typescript-eslint/rule-tester": "7.16.0",
"@typescript-eslint/scope-manager": "7.16.0",
"@typescript-eslint/type-utils": "7.16.0",
"@typescript-eslint/utils": "7.16.0",
"prettier": "^3.2.5"
},
"devDependencies": {
Expand Down
37 changes: 37 additions & 0 deletions 37 packages/eslint-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## 7.16.0 (2024-07-08)


### 🚀 Features

- **rule-tester:** stricter rule test validations

- **eslint-plugin:** [no-unnecessary-parameter-property-assignment] add new rule

- **eslint-plugin:** add support for nested namespaces to unsafe-member-access

- **eslint-plugin:** [no-floating-promises] add checkThenables option


### 🩹 Fixes

- **deps:** update dependency @eslint-community/regexpp to v4.11.0

- **eslint-plugin:** [no-floating-promises] add `suggestions` to tests from #9263 `checkThenables`

- **website:** react key error on internal pages of website

- **eslint-plugin:** [restrict-template-expressions] don't report tuples if `allowArray` option is enabled


### ❤️ Thank You

- Abraham Guo
- auvred
- Josh Goldberg ✨
- Juan Sanchez
- Vinccool96
- YeonJuan
- Yukihiro Hasegawa

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.15.0 (2024-07-01)


Expand Down
4 changes: 0 additions & 4 deletions 4 packages/eslint-plugin/docs/rules/no-floating-promises.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ await createMyThenable();
</TabItem>
</Tabs>

:::info
This option is enabled by default in v7 but will be turned off by default in v8.
:::

### `ignoreVoid`

This option, which is `true` by default, allows you to stop the rule reporting promises consumed with void operator.
Expand Down
14 changes: 7 additions & 7 deletions 14 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": "7.15.0",
"version": "7.16.0",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
Expand Down Expand Up @@ -60,10 +60,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "7.15.0",
"@typescript-eslint/type-utils": "7.15.0",
"@typescript-eslint/utils": "7.15.0",
"@typescript-eslint/visitor-keys": "7.15.0",
"@typescript-eslint/scope-manager": "7.16.0",
"@typescript-eslint/type-utils": "7.16.0",
"@typescript-eslint/utils": "7.16.0",
"@typescript-eslint/visitor-keys": "7.16.0",
"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
Expand All @@ -74,8 +74,8 @@
"@types/marked": "^5.0.2",
"@types/mdast": "^4.0.3",
"@types/natural-compare": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "7.15.0",
"@typescript-eslint/rule-tester": "7.15.0",
"@typescript-eslint/rule-schema-to-typescript-types": "7.16.0",
"@typescript-eslint/rule-tester": "7.16.0",
"ajv": "^6.12.6",
"cross-env": "^7.0.3",
"cross-fetch": "*",
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/eslint-plugin/src/rules/no-floating-promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default createRule<Options, MessageId>({
{
allowForKnownSafeCalls: readonlynessOptionsDefaults.allow,
allowForKnownSafePromises: readonlynessOptionsDefaults.allow,
checkThenables: true,
checkThenables: false,
ignoreIIFE: false,
ignoreVoid: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default createRule({
description:
'Disallow unnecessary assignment of constructor property parameter',
},
fixable: 'code',
messages: {
unnecessaryAssign:
'This assignment is unnecessary since it is already assigned by a parameter property.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const optionTesters = (
[
'Array',
(type, checker, recursivelyCheckType): boolean =>
checker.isArrayType(type) &&
(checker.isArrayType(type) || checker.isTupleType(type)) &&
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
recursivelyCheckType(type.getNumberIndexType()!),
],
Expand Down
24 changes: 9 additions & 15 deletions 24 packages/eslint-plugin/tests/rules/no-floating-promises.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,25 +770,19 @@ createSafePromise();
},
],
},
{
code: `
declare const createPromise: () => PromiseLike<number>;
createPromise();
`,
options: [{ checkThenables: false }],
},
{
code: `
`
declare const createPromiseLike: () => PromiseLike<number>;
createPromiseLike();
`,
`
interface MyThenable {
then(onFulfilled: () => void, onRejected: () => void): MyThenable;
}

declare function createMyThenable(): MyThenable;

createMyThenable();
`,
options: [{ checkThenables: false }],
},
`,
],

invalid: [
Expand Down Expand Up @@ -2104,6 +2098,7 @@ async function test() {
],
},
],
options: [{ checkThenables: true }],
},
{
code: `
Expand Down Expand Up @@ -3586,6 +3581,7 @@ promise;
options: [
{
allowForKnownSafePromises: [{ from: 'file', name: 'SafeThenable' }],
checkThenables: true,
},
],
errors: [
Expand Down Expand Up @@ -3962,7 +3958,6 @@ void createPromise();
],
},
],
options: [{ checkThenables: false }],
},
{
code: `
Expand All @@ -3986,7 +3981,6 @@ void createMyPromise();
],
},
],
options: [{ checkThenables: false }],
},
{
code: `
Expand Down Expand Up @@ -4014,7 +4008,7 @@ void createMyPromise();
],
},
],
options: [{ checkThenables: false }],
options: [{ checkThenables: true }],
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,40 @@ ruleTester.run('restrict-template-expressions', rule, {
{
options: [{ allowArray: true }],
code: `
const arg = [];
function test<T extends string[]>(arg: T) {
return \`arg = \${arg}\`;
}
`,
},
{
options: [{ allowArray: true }],
code: `
declare const arg: [number, string];
const msg = \`arg = \${arg}\`;
`,
},
{
options: [{ allowArray: true }],
code: `
const arg = [1, 'a'] as const;
const msg = \`arg = \${arg || 'default'}\`;
`,
},
{
options: [{ allowArray: true }],
code: `
function test<T extends [string, string]>(arg: T) {
return \`arg = \${arg}\`;
}
`,
},
{
code: `
declare const arg: [number | undefined, string];
const msg = \`arg = \${arg}\`;
`,
options: [{ allowNullish: true, allowArray: true }],
},
// allowAny
{
options: [{ allowAny: true }],
Expand Down Expand Up @@ -365,6 +393,20 @@ ruleTester.run('restrict-template-expressions', rule, {
],
options: [{ allowNullish: false }],
},
{
code: `
declare const arg: number[];
const msg = \`arg = \${arg}\`;
`,
errors: [
{
messageId: 'invalidType',
data: { type: 'number[]' },
line: 3,
column: 30,
},
],
},
{
code: `
const msg = \`arg = \${[, 2]}\`;
Expand All @@ -379,6 +421,21 @@ ruleTester.run('restrict-template-expressions', rule, {
],
options: [{ allowNullish: false, allowArray: true }],
},
{
code: `
declare const arg: [number | undefined, string];
const msg = \`arg = \${arg}\`;
`,
errors: [
{
messageId: 'invalidType',
data: { type: '[number | undefined, string]' },
line: 3,
column: 30,
},
],
options: [{ allowNullish: false, allowArray: true }],
},
{
code: `
declare const arg: number;
Expand Down
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.