Skip to content

Commit c427829

Browse files
authored
Merge pull request #321 from facile-it/eslint9
Migrate to eslint 9
2 parents 4099f43 + cfe657c commit c427829

23 files changed

+2011
-3229
lines changed

jest.config.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
module.exports = {
2-
preset: 'ts-jest',
32
testEnvironment: 'node',
4-
};
3+
testRegex: ['./tests/.+\\.test\\.ts$', './tests/.+\\.spec\\.ts$'],
4+
transform: {
5+
'^.+\\.(t|j)sx?$': [
6+
'@swc/jest',
7+
{
8+
jsc: {
9+
target: 'es2019',
10+
transform: {
11+
react: {
12+
runtime: 'automatic',
13+
},
14+
},
15+
},
16+
},
17+
],
18+
},
19+
};

package.json

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-fp-ts",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"description": "fp-ts ESLint rules",
55
"keywords": [
66
"eslint",
@@ -26,29 +26,28 @@
2626
"lib"
2727
],
2828
"dependencies": {
29-
"@typescript-eslint/experimental-utils": "^5.0.0",
30-
"@typescript-eslint/typescript-estree": "^5.22.0",
31-
"estraverse": "^5.2.0",
29+
"@typescript-eslint/typescript-estree": "^8.25.0",
30+
"@typescript-eslint/utils": "^8.0.0",
3231
"fp-ts": "^2.9.3",
33-
"recast": "^0.20.4"
32+
"recast": "^0.23.11"
3433
},
3534
"devDependencies": {
36-
"@types/astring": "^1.3.0",
35+
"@swc/core": "^1.11.5",
36+
"@swc/jest": "^0.2.37",
3737
"@types/common-tags": "^1.8.0",
38-
"@types/estraverse": "^5.1.0",
3938
"@types/node": "^17.0.31",
4039
"@types/requireindex": "^1.2.0",
41-
"@typescript-eslint/parser": "^5.0.0",
40+
"@typescript-eslint/parser": "^8.25.0",
41+
"@typescript-eslint/rule-tester": "^8.25.0",
4242
"common-tags": "^1.8.0",
43-
"eslint": "^8.0.0",
43+
"eslint": "^9.0.0",
4444
"eslint-plugin-fp-ts": "link:./lib",
45-
"jest": "^26.6.3",
46-
"rimraf": "^3.0.2",
47-
"ts-jest": "^26.4.4",
48-
"typescript": "^4.1.3"
45+
"jest": "^29.7.0",
46+
"rimraf": "^6.0.1",
47+
"typescript": "^5.0"
4948
},
5049
"peerDependencies": {
51-
"eslint": "^8.0.0"
50+
"eslint": "^9.0"
5251
},
5352
"engines": {
5453
"node": ">=0.10.0"

src/rules/no-discarded-pure-expression.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
ParserServices,
33
AST_NODE_TYPES,
4-
} from "@typescript-eslint/experimental-utils";
4+
} from "@typescript-eslint/utils";
55
import { array, option, readonlyArray } from "fp-ts";
66
import { constVoid, pipe } from "fp-ts/function";
77
import { Option } from "fp-ts/Option";
@@ -17,7 +17,6 @@ export default createRule({
1717
docs: {
1818
description:
1919
"Detects pure expressions that do nothing because they're in statement position",
20-
recommended: "error",
2120
},
2221
messages: {
2322
pureExpressionInStatementPosition:
@@ -142,7 +141,7 @@ export default createRule({
142141
option.Do,
143142
option.bind("parserServices", parserServices),
144143
option.bind("typeChecker", ({ parserServices }) =>
145-
option.some(parserServices.program.getTypeChecker())
144+
option.fromNullable(parserServices.program?.getTypeChecker())
146145
),
147146
option.bind(
148147
"parameterWithVoidOrUknownReturnType",
@@ -181,7 +180,7 @@ export default createRule({
181180
option.bind("argumentType", () => typeOfNode(argumentNode)),
182181
option.bind("parserServices", parserServices),
183182
option.bind("typeChecker", ({ parserServices }) =>
184-
option.some(parserServices.program.getTypeChecker())
183+
option.fromNullable(parserServices.program?.getTypeChecker())
185184
),
186185
option.bind(
187186
"parameterReturnType",

src/rules/no-lib-imports.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ASTUtils } from "@typescript-eslint/experimental-utils";
1+
import { ASTUtils } from "@typescript-eslint/utils";
22
import { createRule, inferQuote } from "../utils";
33

44
export default createRule({
@@ -8,7 +8,6 @@ export default createRule({
88
fixable: "code",
99
docs: {
1010
description: "Disallow imports from 'fp-ts/lib'",
11-
recommended: "error",
1211
},
1312
schema: [],
1413
messages: {

src/rules/no-module-imports.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
ASTUtils,
33
AST_NODE_TYPES,
4-
} from "@typescript-eslint/experimental-utils";
4+
} from "@typescript-eslint/utils";
55
import { array } from "fp-ts";
66
import { pipe } from "fp-ts/function";
77
import { contextUtils, createRule, inferQuote } from "../utils";
@@ -24,7 +24,6 @@ export default createRule<Options, MessageIds>({
2424
docs: {
2525
description:
2626
"Disallow imports from fp-ts modules, such as `fp-ts/Option`",
27-
recommended: "error",
2827
},
2928
schema: [
3029
{
@@ -103,7 +102,7 @@ export default createRule<Options, MessageIds>({
103102
const referencesFixes = importSpecifiers.flatMap(
104103
(importSpecifier) => {
105104
const variable = ASTUtils.findVariable(
106-
context.getScope(),
105+
context.sourceCode.getScope(node),
107106
importSpecifier.local.name
108107
);
109108
if (variable) {

src/rules/no-pipeable.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ASTUtils, TSESTree } from "@typescript-eslint/experimental-utils";
1+
import { ASTUtils, TSESTree } from "@typescript-eslint/utils";
22
import { createRule, inferQuote } from "../utils";
33

44
export default createRule({
@@ -9,7 +9,6 @@ export default createRule({
99
schema: [],
1010
docs: {
1111
description: "Disallow imports from the 'pipeable' module",
12-
recommended: "error",
1312
},
1413
messages: {
1514
importPipeFromFunction:
@@ -28,7 +27,7 @@ export default createRule({
2827
if (
2928
node.specifiers.find(
3029
(importClause) =>
31-
(importClause as TSESTree.ImportSpecifier).imported?.name ===
30+
((importClause as TSESTree.ImportSpecifier).imported as TSESTree.Identifier | undefined)?.name ===
3231
"pipe"
3332
)
3433
) {

src/rules/no-redundant-flow.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default createRule({
1717
schema: [],
1818
docs: {
1919
description: "Remove redundant uses of flow",
20-
recommended: "warn",
2120
},
2221
messages: {
2322
redundantFlow: "flow can be removed because it takes only one argument",

src/rules/prefer-bimap.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
AST_NODE_TYPES,
33
TSESTree,
4-
} from "@typescript-eslint/experimental-utils";
4+
} from "@typescript-eslint/utils";
55
import { boolean, option, apply } from "fp-ts";
66
import { constVoid, pipe } from "fp-ts/function";
77
import {
@@ -22,7 +22,6 @@ export default createRule({
2222
schema: [],
2323
docs: {
2424
description: "Replace map + mapLeft with bimap",
25-
recommended: "warn",
2625
},
2726
messages: {
2827
mapMapLeftIsBimap:

src/rules/prefer-chain.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AST_NODE_TYPES } from "@typescript-eslint/experimental-utils";
1+
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
22
import { boolean, option } from "fp-ts";
33
import { constVoid, pipe } from "fp-ts/function";
44
import {
@@ -17,7 +17,6 @@ export default createRule({
1717
schema: [],
1818
docs: {
1919
description: "Replace map + flatten with chain",
20-
recommended: "warn",
2120
},
2221
messages: {
2322
mapFlattenIsChain: "map followed by flatten can be replaced by chain",

src/rules/prefer-traverse.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
AST_NODE_TYPES,
33
TSESTree,
4-
} from "@typescript-eslint/experimental-utils";
4+
} from "@typescript-eslint/utils";
55
import { constVoid, pipe } from "fp-ts/function";
66
import { boolean, option } from "fp-ts";
77
import {
@@ -21,7 +21,6 @@ export default createRule({
2121
schema: [],
2222
docs: {
2323
description: "Replace map + sequence with traverse",
24-
recommended: "warn",
2524
},
2625
messages: {
2726
mapSequenceIsTraverse:

0 commit comments

Comments
 (0)