Skip to content

Commit a7587b2

Browse files
committed
refactor: remove unused code
1 parent 230f14b commit a7587b2

File tree

9 files changed

+58
-42
lines changed

9 files changed

+58
-42
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-mount.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export const RULE_FEATURES = [
1616

1717
export type MessageID = CamelCase<typeof RULE_NAME>;
1818

19-
function isComponentWillMount(node: TSESTree.ClassElement) {
20-
return AST.isMethodOrProperty(node)
21-
&& node.key.type === T.Identifier
22-
&& node.key.name === "componentWillMount";
23-
}
24-
2519
export default createRule<[], MessageID>({
2620
meta: {
2721
type: "problem",
@@ -51,7 +45,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
5145
for (const { node: component } of components.values()) {
5246
const { body } = component.body;
5347
for (const member of body) {
54-
if (isComponentWillMount(member)) {
48+
if (ER.isComponentWillMount(member)) {
5549
context.report({
5650
messageId: "noComponentWillMount",
5751
node: member,

packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-receive-props.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export const RULE_FEATURES = [
1616

1717
export type MessageID = CamelCase<typeof RULE_NAME>;
1818

19-
function isComponentWillUpdate(node: TSESTree.ClassElement) {
20-
return AST.isMethodOrProperty(node)
21-
&& node.key.type === T.Identifier
22-
&& node.key.name === "componentWillReceiveProps";
23-
}
24-
2519
export default createRule<[], MessageID>({
2620
meta: {
2721
type: "problem",
@@ -50,7 +44,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
5044
for (const { node: component } of components.values()) {
5145
const { body } = component.body;
5246
for (const member of body) {
53-
if (isComponentWillUpdate(member)) {
47+
if (ER.isComponentWillReceiveProps(member)) {
5448
context.report({
5549
messageId: "noComponentWillReceiveProps",
5650
node: member,

packages/plugins/eslint-plugin-react-x/src/rules/no-component-will-update.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ export const RULE_FEATURES = [
1616

1717
export type MessageID = CamelCase<typeof RULE_NAME>;
1818

19-
function isComponentWillUpdate(node: TSESTree.ClassElement) {
20-
return AST.isMethodOrProperty(node)
21-
&& node.key.type === T.Identifier
22-
&& node.key.name === "componentWillUpdate";
23-
}
24-
2519
export default createRule<[], MessageID>({
2620
meta: {
2721
type: "problem",
@@ -51,7 +45,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
5145
for (const { node: component } of components.values()) {
5246
const { body } = component.body;
5347
for (const member of body) {
54-
if (isComponentWillUpdate(member)) {
48+
if (ER.isComponentWillUpdate(member)) {
5549
context.report({
5650
messageId: "noComponentWillUpdate",
5751
node: member,

packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-mount.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export const RULE_FEATURES = [] as const satisfies RuleFeature[];
1414

1515
export type MessageID = CamelCase<typeof RULE_NAME>;
1616

17-
function isComponentDidMount(node: TSESTree.Node) {
18-
return AST.isMethodOrProperty(node)
19-
&& node.key.type === T.Identifier
20-
&& node.key.name === "componentDidMount";
21-
}
22-
2317
export default createRule<[], MessageID>({
2418
meta: {
2519
type: "problem",
@@ -46,7 +40,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4640
return;
4741
}
4842
const clazz = AST.findParentNode(node, ER.isClassComponent);
49-
const method = AST.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
43+
const method = AST.findParentNode(node, (n) => n === clazz || ER.isComponentDidMount(n));
5044
if (clazz == null || method == null || method === clazz) return;
5145
const methodScope = context.sourceCode.getScope(method);
5246
const upperScope = context.sourceCode.getScope(node).upper;

packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-did-update.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export const RULE_FEATURES = [] as const satisfies RuleFeature[];
1414

1515
export type MessageID = CamelCase<typeof RULE_NAME>;
1616

17-
function isComponentDidUpdate(node: TSESTree.Node) {
18-
return AST.isMethodOrProperty(node)
19-
&& node.key.type === T.Identifier
20-
&& node.key.name === "componentDidUpdate";
21-
}
22-
2317
export default createRule<[], MessageID>({
2418
meta: {
2519
type: "problem",
@@ -46,7 +40,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4640
return;
4741
}
4842
const clazz = AST.findParentNode(node, ER.isClassComponent);
49-
const method = AST.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
43+
const method = AST.findParentNode(node, (n) => n === clazz || ER.isComponentDidUpdate(n));
5044
if (clazz == null || method == null || method === clazz) return;
5145
const methodScope = context.sourceCode.getScope(method);
5246
const upperScope = context.sourceCode.getScope(node).upper;

packages/plugins/eslint-plugin-react-x/src/rules/no-set-state-in-component-will-update.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export const RULE_FEATURES = [] as const satisfies RuleFeature[];
1414

1515
export type MessageID = CamelCase<typeof RULE_NAME>;
1616

17-
function isComponentWillUpdate(node: TSESTree.Node) {
18-
return AST.isMethodOrProperty(node)
19-
&& node.key.type === T.Identifier
20-
&& node.key.name === "componentWillUpdate";
21-
}
22-
2317
export default createRule<[], MessageID>({
2418
meta: {
2519
type: "problem",
@@ -47,7 +41,7 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
4741
return;
4842
}
4943
const clazz = AST.findParentNode(node, ER.isClassComponent);
50-
const method = AST.findParentNode(node, (n) => n === clazz || isComponentWillUpdate(n));
44+
const method = AST.findParentNode(node, (n) => n === clazz || ER.isComponentWillUpdate(n));
5145
if (clazz == null || method == null || method === clazz) return;
5246
const methodScope = context.sourceCode.getScope(method);
5347
const upperScope = context.sourceCode.getScope(node).upper;

packages/utilities/kit/docs/@eslint-react/namespaces/LanguagePreference/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
## Variables
1010

1111
- [DEFAULT\_LANGUAGE\_PREFERENCE](variables/DEFAULT_LANGUAGE_PREFERENCE.md)
12+
13+
## Functions
14+
15+
- [make](functions/make.md)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[**@eslint-react/kit**](../../../../README.md)
2+
3+
***
4+
5+
[@eslint-react/kit](../../../../README.md) / [LanguagePreference](../README.md) / make
6+
7+
# Function: make()
8+
9+
> **make**(): `object`
10+
11+
Get a copy of the default LanguagePreference.
12+
13+
## Returns
14+
15+
`object`
16+
17+
### indentStyle
18+
19+
> **indentStyle**: `"tab"` \| `"space"`
20+
21+
### indentWidth
22+
23+
> **indentWidth**: `number`
24+
25+
### jsxQuoteStyle
26+
27+
> **jsxQuoteStyle**: `"single"` \| `"double"`
28+
29+
### quoteStyle
30+
31+
> **quoteStyle**: `"single"` \| `"double"`
32+
33+
### semicolons
34+
35+
> **semicolons**: `"always"` \| `"asNeeded"`
36+
37+
### trailingCommas
38+
39+
> **trailingCommas**: `"all"` \| `"es5"` \| `"none"`

packages/utilities/kit/src/LanguagePreference/LanguagePreference.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export const DEFAULT_LANGUAGE_PREFERENCE = {
1919
trailingCommas: "all",
2020
} as const satisfies LanguagePreference;
2121

22+
/**
23+
* Get a copy of the default LanguagePreference.
24+
*/
25+
export function make(): LanguagePreference {
26+
return {
27+
...DEFAULT_LANGUAGE_PREFERENCE,
28+
};
29+
}
30+
2231
declare module "@typescript-eslint/utils/ts-eslint" {
2332
export interface SharedConfigurationSettings {
2433
// TODO: Add the language preference to the shared configuration settings when it is ready.

0 commit comments

Comments
 (0)