Skip to content

Commit 57e8e96

Browse files
style: apply new linting styles
1 parent 23b7797 commit 57e8e96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+126
-150
lines changed

GETTING_STARTED.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export default [
4545
...functional.configs.externalVanillaRecommended,
4646
...functional.configs.recommended,
4747
...functional.configs.stylistic,
48-
...functional.configs.disableTypeChecked
48+
...functional.configs.disableTypeChecked,
4949
// your other plugin configs here
5050
{
51-
rules: {
52-
// any rule configs here
51+
rules: {
52+
// any rule configs here
53+
},
5354
},
54-
}
5555
];
5656
```
5757

@@ -61,8 +61,8 @@ In your `eslint.config.js` file, import `typescript-eslint` and `eslint-plugin-f
6161

6262
```js
6363
// eslint.config.js
64-
import tseslint from 'typescript-eslint';
6564
import functional from "eslint-plugin-functional";
65+
import tseslint from "typescript-eslint";
6666

6767
export default tseslint.config({
6868
files: ["**/*.ts"],

cz-adapter/engine.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ type CZ = any;
2121
/**
2222
* The engine.
2323
*/
24-
export default (
25-
options: Options,
26-
): { prompter: (cz: CZ, commit: (msg: string) => unknown) => void } => {
27-
return {
24+
export default {
25+
create: (
26+
options: Options,
27+
): { prompter: (cz: CZ, commit: (msg: string) => unknown) => void } => ({
2828
prompter: (cz, commit) =>
2929
promptUser(cz, options).then(doCommit(commit, options)),
30-
};
30+
}),
3131
};
3232

3333
/**
@@ -86,9 +86,7 @@ function promptUser(cz: CZ, options: Options) {
8686
name: "scope",
8787
message: "What is the scope of this change: (press enter to skip)",
8888
default: defaultScope,
89-
when: (answers: Answers) => {
90-
return !scopeRulesType.has(answers.type);
91-
},
89+
when: (answers: Answers) => !scopeRulesType.has(answers.type),
9290
filter: filterScope(options),
9391
},
9492
{
@@ -97,19 +95,15 @@ function promptUser(cz: CZ, options: Options) {
9795
message: "Which rule does this change apply to:",
9896
choices: getRulesChoices(),
9997
default: defaultScope,
100-
when: (answers: Answers) => {
101-
return scopeRulesType.has(answers.type);
102-
},
98+
when: (answers: Answers) => scopeRulesType.has(answers.type),
10399
filter: filterScope(options),
104100
},
105101
{
106102
type: "confirm",
107103
name: "isBreaking",
108104
message: "Are there any breaking changes?",
109105
default: false,
110-
when: (answers: Answers) => {
111-
return possibleBreakingRulesType.has(answers.type);
112-
},
106+
when: (answers: Answers) => possibleBreakingRulesType.has(answers.type),
113107
},
114108
{
115109
type: "input",
@@ -161,9 +155,7 @@ function promptUser(cz: CZ, options: Options) {
161155
type: "input",
162156
name: "issues",
163157
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
164-
when: (answers: Answers) => {
165-
return answers.isIssueAffected;
166-
},
158+
when: (answers: Answers) => answers.isIssueAffected,
167159
default: defaultIssues,
168160
},
169161
]);
@@ -266,11 +258,8 @@ function maxSummaryLength(options: Options, answers: Answers) {
266258
* Get a function to auto-process the scope.
267259
*/
268260
function filterScope(options: Options) {
269-
return (value: string) => {
270-
return options.disableScopeLowerCase
271-
? value.trim()
272-
: value.trim().toLowerCase();
273-
};
261+
return (value: string) =>
262+
options.disableScopeLowerCase ? value.trim() : value.trim().toLowerCase();
274263
}
275264

276265
/**

docs/rules/functional-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Any function that takes multiple parameter can be rewritten as a higher-order fu
137137

138138
Example:
139139

140-
<!-- eslint-disable @typescript-eslint/no-redeclare -->
140+
<!-- eslint-disable ts/no-redeclare -->
141141

142142
```js
143143
// This function

docs/rules/no-classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const Message = ({ message }) => <div>{message}</div>;
6969
What about lifecycle methods like `shouldComponentUpdate`? We can use the [recompose](https://github.com/acdlite/recompose) library to apply these optimizations to your Stateless Functional Components. The [recompose](https://github.com/acdlite/recompose) library relies on the fact that your Redux state is immutable to efficiently implement `shouldComponentUpdate` for you.
7070

7171
```js
72-
import { pure, onlyUpdateForKeys } from "recompose";
72+
import { onlyUpdateForKeys, pure } from "recompose";
7373

7474
const Message = ({ message }) => <div>{message}</div>;
7575

docs/rules/no-let.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ If set, `let`s inside of for a loop initializer are allowed. This does not inclu
8686

8787
#### ✅ Correct
8888

89-
<!-- eslint-disable @typescript-eslint/prefer-for-of -->
89+
<!-- eslint-disable ts/prefer-for-of -->
9090

9191
```js
9292
/* eslint functional/no-let: ["error", { "allowInForLoopInit": true } ] */

docs/rules/prefer-property-signatures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Foo = {
2929

3030
### ✅ Correct
3131

32-
<!-- eslint-disable @typescript-eslint/no-redeclare -->
32+
<!-- eslint-disable ts/no-redeclare -->
3333

3434
```ts
3535
/* eslint functional/prefer-property-signatures: "error" */

docs/rules/prefer-readonly-type.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This is just as effective as using `Object.freeze()` to prevent mutations. Howev
6767

6868
The `readonly` modifier also works on indexers:
6969

70-
<!-- eslint-disable @typescript-eslint/consistent-indexed-object-style -->
70+
<!-- eslint-disable ts/consistent-indexed-object-style -->
7171

7272
```ts
7373
const foo: { readonly [key: string]: number } = { a: 1, b: 2 };

docs/rules/settings/immutability.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ readonly, then no override will be applied.
3232
"name": "ReadonlyArray",
3333
},
3434
"to": "Immutable",
35-
"from": "ReadonlyDeep"
36-
}
37-
]
38-
}
35+
"from": "ReadonlyDeep",
36+
},
37+
],
38+
},
3939
},
4040
"rules": {
4141
// ...
42-
}
42+
},
4343
}
4444
```

docs/user-guide/migrating-from-tslint.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ In order for the parser to have access to type information, it needs access to y
2222
"parserOptions": {
2323
"ecmaVersion": 10,
2424
"project": "./tsconfig.json",
25-
"sourceType": "module"
25+
"sourceType": "module",
2626
},
27-
"plugins": [
28-
"functional"
29-
],
27+
"plugins": ["functional"],
3028
"env": {
31-
"es6": true
29+
"es6": true,
3230
},
33-
"extends": [
34-
"plugin:functional/recommended"
35-
],
31+
"extends": ["plugin:functional/recommended"],
3632
"rules": {
3733
// These rules will be applied to all linted file.
3834
},
@@ -41,9 +37,9 @@ In order for the parser to have access to type information, it needs access to y
4137
"files": ["*.ts", "*.tsx"],
4238
"rules": {
4339
// These rules will only be applied to ts file.
44-
}
45-
}
46-
]
40+
},
41+
},
42+
],
4743
}
4844
```
4945

eslint.config.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export default rsEslint(
2525

2626
// Some types say they have nonnullable properties, but they don't always.
2727
"ts/no-unnecessary-condition": "off",
28-
28+
},
29+
},
30+
{
31+
files: ["src/**/*"],
32+
rules: {
2933
"eslint/fixer-return": "error",
3034
"eslint/meta-property-ordering": "error",
3135
"eslint/no-deprecated-context-methods": "error",
@@ -56,7 +60,7 @@ export default rsEslint(
5660
},
5761
},
5862
{
59-
files: ["src/configs/", "src/index.ts"],
63+
files: ["src/configs/**/*", "src/index.ts"],
6064
rules: {
6165
"ts/naming-convention": "off",
6266
},
@@ -68,7 +72,7 @@ export default rsEslint(
6872
},
6973
},
7074
{
71-
files: ["src/utils/conditional-imports/"],
75+
files: ["src/utils/conditional-imports/**/*"],
7276
rules: {
7377
"@typescript-eslint/no-var-requires": "off",
7478
"functional/functional-parameters": "off",
@@ -83,14 +87,14 @@ export default rsEslint(
8387
},
8488
},
8589
{
86-
files: ["tests/"],
90+
files: ["tests/**/*"],
8791
rules: {
8892
"functional/no-return-void": "off",
8993
"jsdoc/require-jsdoc": "off",
9094
},
9195
},
9296
{
93-
files: ["cz-adapter/"],
97+
files: ["cz-adapter/**/*"],
9498
rules: {
9599
"no-console": "off",
96100

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const configs = {
5656
stylistic: { plugins: { functional }, rules: stylistic },
5757
} satisfies Record<string, FlatConfig.Config>;
5858

59-
// eslint-disable-next-line functional/immutable-data, functional/no-expression-statements
6059
functional.configs = configs;
6160

6261
export default functional as FlatConfig.Plugin & {

src/rules/functional-parameters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
77
import { deepmerge } from "deepmerge-ts";
88

99
import {
10+
type IgnoreIdentifierPatternOption,
11+
type IgnorePrefixSelectorOption,
1012
ignoreIdentifierPatternOptionSchema,
1113
ignorePrefixSelectorOptionSchema,
1214
shouldIgnorePattern,
13-
type IgnoreIdentifierPatternOption,
14-
type IgnorePrefixSelectorOption,
1515
} from "#eslint-plugin-functional/options";
1616
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";
1717
import { type ESFunction } from "#eslint-plugin-functional/utils/node-types";
1818
import {
19-
createRuleUsingFunction,
2019
type NamedCreateRuleCustomMeta,
2120
type RuleResult,
21+
createRuleUsingFunction,
2222
} from "#eslint-plugin-functional/utils/rule";
2323
import {
2424
isArgument,

src/rules/immutable-data.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
77
import { deepmerge } from "deepmerge-ts";
88

99
import {
10+
type IgnoreAccessorPatternOption,
11+
type IgnoreClassesOption,
12+
type IgnoreIdentifierPatternOption,
1013
ignoreAccessorPatternOptionSchema,
1114
ignoreClassesOptionSchema,
1215
ignoreIdentifierPatternOptionSchema,
1316
shouldIgnoreClasses,
1417
shouldIgnorePattern,
15-
type IgnoreAccessorPatternOption,
16-
type IgnoreClassesOption,
17-
type IgnoreIdentifierPatternOption,
1818
} from "#eslint-plugin-functional/options";
1919
import {
2020
isExpected,
2121
ruleNameScope,
2222
} from "#eslint-plugin-functional/utils/misc";
2323
import {
24-
createRule,
25-
getTypeOfNode,
2624
type NamedCreateRuleCustomMeta,
2725
type RuleResult,
26+
createRule,
27+
getTypeOfNode,
2828
} from "#eslint-plugin-functional/utils/rule";
2929
import {
3030
findRootIdentifier,

src/rules/no-classes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
44
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";
55
import { type ESClass } from "#eslint-plugin-functional/utils/node-types";
66
import {
7-
createRule,
87
type NamedCreateRuleCustomMeta,
98
type RuleResult,
9+
createRule,
1010
} from "#eslint-plugin-functional/utils/rule";
1111

1212
/**

src/rules/no-conditional-statements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { type Type } from "typescript";
66
import tsApiUtils from "#eslint-plugin-functional/conditional-imports/ts-api-utils";
77
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";
88
import {
9-
createRule,
10-
getTypeOfNode,
119
type NamedCreateRuleCustomMeta,
1210
type RuleResult,
11+
createRule,
12+
getTypeOfNode,
1313
} from "#eslint-plugin-functional/utils/rule";
1414
import {
1515
isBlockStatement,

src/rules/no-expression-statements.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import { deepmerge } from "deepmerge-ts";
99
import tsApiUtils from "#eslint-plugin-functional/conditional-imports/ts-api-utils";
1010
import typescript from "#eslint-plugin-functional/conditional-imports/typescript";
1111
import {
12+
type IgnoreCodePatternOption,
1213
ignoreCodePatternOptionSchema,
1314
shouldIgnorePattern,
14-
type IgnoreCodePatternOption,
1515
} from "#eslint-plugin-functional/options";
1616
import {
1717
isDirectivePrologue,
1818
ruleNameScope,
1919
} from "#eslint-plugin-functional/utils/misc";
2020
import {
21-
createRule,
22-
getTypeOfNode,
2321
type NamedCreateRuleCustomMeta,
2422
type RuleResult,
23+
createRule,
24+
getTypeOfNode,
2525
} from "#eslint-plugin-functional/utils/rule";
2626
import {
2727
isCallExpression,

src/rules/no-let.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
77
import { deepmerge } from "deepmerge-ts";
88

99
import {
10+
type IgnoreIdentifierPatternOption,
1011
ignoreIdentifierPatternOptionSchema,
1112
shouldIgnoreInFunction,
1213
shouldIgnorePattern,
13-
type IgnoreIdentifierPatternOption,
1414
} from "#eslint-plugin-functional/options";
1515
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";
1616
import {
17-
createRule,
1817
type NamedCreateRuleCustomMeta,
1918
type RuleResult,
19+
createRule,
2020
} from "#eslint-plugin-functional/utils/rule";
2121
import { isInForLoopInitializer } from "#eslint-plugin-functional/utils/tree";
2222

src/rules/no-loop-statements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { type RuleContext } from "@typescript-eslint/utils/ts-eslint";
44
import { ruleNameScope } from "#eslint-plugin-functional/utils/misc";
55
import { type ESLoop } from "#eslint-plugin-functional/utils/node-types";
66
import {
7-
createRule,
87
type NamedCreateRuleCustomMeta,
98
type RuleResult,
9+
createRule,
1010
} from "#eslint-plugin-functional/utils/rule";
1111

1212
/**

0 commit comments

Comments
 (0)