Skip to content

Commit 48dc9e6

Browse files
Merge pull request #972 from eslint-functional/update
2 parents de2085d + 24f8ee0 commit 48dc9e6

File tree

8 files changed

+408
-264
lines changed

8 files changed

+408
-264
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ The [below section](#rules) gives details on which rules are enabled by each rul
117117

118118
### No Exceptions
119119

120-
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
121-
| :------------------------------------------------------- | :----------------------------------------------------- | :------------------------------- | :-- | :---- | :-- | :-- | :-- | :-- |
122-
| [no-promise-reject](docs/rules/no-promise-reject.md) | Disallow rejecting promises. | | | | | | | |
123-
| [no-throw-statements](docs/rules/no-throw-statements.md) | Disallow throwing exceptions. | ☑️ ✅ 🔒 ![badge-noExceptions][] | | | | | | |
124-
| [no-try-statements](docs/rules/no-try-statements.md) | Disallow try-catch[-finally] and try-finally patterns. | 🔒 ![badge-noExceptions][] | | ☑️ ✅ | | | | |
120+
| Name | Description | 💼 | ⚠️ | 🚫 | 🔧 | 💡 | 💭 ||
121+
| :------------------------------------------------------- | :----------------------------------------------------- | :------------------------------- | :-- | :---------------------------- | :-- | :-- | :-- | :-- |
122+
| [no-promise-reject](docs/rules/no-promise-reject.md) | Disallow rejecting promises. | | | | | | | |
123+
| [no-throw-statements](docs/rules/no-throw-statements.md) | Disallow throwing exceptions. | ☑️ ✅ 🔒 ![badge-noExceptions][] | | ![badge-disableTypeChecked][] | | | 💭 | |
124+
| [no-try-statements](docs/rules/no-try-statements.md) | Disallow try-catch[-finally] and try-finally patterns. | 🔒 ![badge-noExceptions][] | | ☑️ ✅ | | | | |
125125

126126
### No Mutations
127127

docs/rules/no-throw-statements.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
# Disallow throwing exceptions (`functional/no-throw-statements`)
55

6-
💼 This rule is enabled in the following configs: ☑️ `lite`, `noExceptions`, ✅ `recommended`, 🔒 `strict`.
6+
💼🚫 This rule is enabled in the following configs: ☑️ `lite`, `noExceptions`, ✅ `recommended`, 🔒 `strict`. This rule is _disabled_ in the `disableTypeChecked` config.
7+
8+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
79

810
<!-- end auto-generated rule header -->
911
<!-- markdownlint-restore -->

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@
100100
"@semantic-release/github": "11.0.3",
101101
"@semantic-release/npm": "12.0.1",
102102
"@semantic-release/release-notes-generator": "14.0.3",
103-
"@stylistic/eslint-plugin": "4.2.0",
103+
"@stylistic/eslint-plugin": "4.4.0",
104104
"@types/node": "18.19.100",
105105
"@typescript-eslint/eslint-plugin": "8.31.1",
106106
"@typescript-eslint/parser": "8.31.1",
107107
"@vitest/coverage-v8": "3.1.2",
108108
"@vitest/eslint-plugin": "1.1.44",
109-
"cspell": "8.19.4",
109+
"cspell": "9.0.2",
110110
"dedent": "1.6.0",
111111
"eslint": "9.25.1",
112112
"eslint-config-prettier": "10.1.5",
@@ -136,7 +136,7 @@
136136
"husky": "9.1.7",
137137
"jsonc-eslint-parser": "2.4.0",
138138
"knip": "5.55.1",
139-
"lint-staged": "15.5.2",
139+
"lint-staged": "16.1.0",
140140
"markdownlint-cli2": "0.18.0",
141141
"prettier": "3.5.3",
142142
"rimraf": "6.0.1",

pnpm-lock.yaml

Lines changed: 359 additions & 253 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rules/no-throw-statements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const meta: NamedCreateRuleCustomMeta<keyof typeof errorMessages, RawOptions> =
6666
description: "Disallow throwing exceptions.",
6767
recommended: "recommended",
6868
recommendedSeverity: "error",
69-
requiresTypeChecking: false,
69+
requiresTypeChecking: true,
7070
},
7171
messages: errorMessages,
7272
schema,

src/rules/prefer-tacit.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ function isCallerViolation(
118118
.some((signature) => signature.parameters.length === caller.arguments.length);
119119
}
120120

121+
/**
122+
* Is the given node a direct child of a getter.
123+
*/
124+
function isDirectChildOfGetter(node: TSESTree.Node): boolean {
125+
const { parent } = node;
126+
if (parent?.type !== TSESTree.AST_NODE_TYPES.Property) {
127+
return false;
128+
}
129+
130+
return parent.kind === "get";
131+
}
132+
121133
/**
122134
* Get the fixes for a call to a reference violation.
123135
*/
@@ -260,6 +272,13 @@ function checkFunction(
260272
context: Readonly<RuleContext<keyof typeof errorMessages, RawOptions>>,
261273
options: RawOptions,
262274
): RuleResult<keyof typeof errorMessages, RawOptions> {
275+
if (isDirectChildOfGetter(node)) {
276+
return {
277+
context,
278+
descriptors: [],
279+
};
280+
}
281+
263282
return {
264283
context,
265284
descriptors: [

src/settings/immutability.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare module "@typescript-eslint/utils" {
1313
from?: Immutability | keyof typeof Immutability;
1414
};
1515

16-
// eslint-disable-next-line ts/consistent-type-definitions, ts/no-shadow
16+
// eslint-disable-next-line ts/consistent-type-definitions
1717
interface SharedConfigurationSettings {
1818
immutability?: {
1919
overrides?:

tests/rules/prefer-tacit.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@ describe(name, () => {
9797
`);
9898
});
9999

100+
it("doesn't report getters", async () => {
101+
await valid(dedent`
102+
const foo = () => {
103+
const getBar = () => 1;
104+
const setBar = (value: number) => {};
105+
return {
106+
get baz() {
107+
return getBar();
108+
},
109+
set baz(value) {
110+
setBar(value);
111+
},
112+
};
113+
};
114+
`);
115+
});
116+
100117
describe("options", () => {
101118
describe("checkMemberExpressions", () => {
102119
it("doesn't report member expressions when disabled", async () => {

0 commit comments

Comments
 (0)