Skip to content

Commit

Permalink
fix(eslint-plugin): migrate to typescript-eslint (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Apr 11, 2024
1 parent 9f51524 commit 576f29a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-chairs-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/eslint-plugin": patch
---

Migrate to `typescript-eslint`
6 changes: 2 additions & 4 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const compat = new FlatCompat({

module.exports = [
...rnx.configs.strict,
...compat.extends(
"plugin:@microsoft/sdl/required",
"plugin:@typescript-eslint/stylistic"
),
...rnx.configs.stylistic,
...compat.extends("plugin:@microsoft/sdl/required"),
{
rules: {
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "^8.56.0",
"@react-native/eslint-plugin": "^0.74.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"enhanced-resolve": "^5.8.3",
"eslint-plugin-react": "^7.33.0",
"eslint-plugin-react-hooks": "^4.6.0"
"eslint-plugin-react-hooks": "^4.6.0",
"typescript-eslint": "^7.5.0"
},
"peerDependencies": {
"eslint": ">=8.56.0"
Expand All @@ -67,6 +66,7 @@
"@types/estree": "*",
"@types/jest": "^29.2.1",
"@types/node": "^20.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@typescript-eslint/types": "^7.0.0",
"eslint": "^8.56.0",
"eslint-plugin-node": "11.1.0",
Expand Down
15 changes: 6 additions & 9 deletions packages/eslint-plugin/src/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");
const tseslint = require("typescript-eslint");

const compat = new FlatCompat({
baseDirectory: __dirname,
Expand All @@ -22,18 +23,14 @@ function isInstalled(spec) {
}

const usesReact = isInstalled("react");
const configs = ["plugin:@typescript-eslint/recommended"];
if (usesReact) {
configs.push("plugin:react-hooks/recommended", "plugin:react/recommended");
}
const reactConfigs = usesReact
? compat.extends("plugin:react-hooks/recommended", "plugin:react/recommended")
: [];

module.exports = [
...compat.extends(...configs),
...tseslint.configs.recommended,
...reactConfigs,
{
languageOptions: {
// @ts-expect-error No declaration file for module
parser: require("@typescript-eslint/parser"),
},
plugins: {
// @ts-expect-error No declaration file for module
"@react-native": require("@react-native/eslint-plugin"),
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
configs: {
recommended: require("./configs/recommended"),
strict: require("./configs/strict"),
stylistic: require("typescript-eslint").configs.stylistic,
},
rules: require("./rules").rules,
};
22 changes: 19 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3859,7 +3859,6 @@ __metadata:
"@types/estree": "npm:*"
"@types/jest": "npm:^29.2.1"
"@types/node": "npm:^20.0.0"
"@typescript-eslint/eslint-plugin": "npm:^7.0.0"
"@typescript-eslint/parser": "npm:^7.0.0"
"@typescript-eslint/types": "npm:^7.0.0"
enhanced-resolve: "npm:^5.8.3"
Expand All @@ -3870,6 +3869,7 @@ __metadata:
jest: "npm:^29.2.1"
prettier: "npm:^3.0.0"
typescript: "npm:^5.0.0"
typescript-eslint: "npm:^7.5.0"
peerDependencies:
eslint: ">=8.56.0"
languageName: unknown
Expand Down Expand Up @@ -4921,7 +4921,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^7.0.0":
"@typescript-eslint/eslint-plugin@npm:7.5.0":
version: 7.5.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.5.0"
dependencies:
Expand All @@ -4946,7 +4946,7 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/parser@npm:^7.0.0":
"@typescript-eslint/parser@npm:7.5.0, @typescript-eslint/parser@npm:^7.0.0":
version: 7.5.0
resolution: "@typescript-eslint/parser@npm:7.5.0"
dependencies:
Expand Down Expand Up @@ -13843,6 +13843,22 @@ __metadata:
languageName: node
linkType: hard

"typescript-eslint@npm:^7.5.0":
version: 7.5.0
resolution: "typescript-eslint@npm:7.5.0"
dependencies:
"@typescript-eslint/eslint-plugin": "npm:7.5.0"
"@typescript-eslint/parser": "npm:7.5.0"
"@typescript-eslint/utils": "npm:7.5.0"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/5b40508de65bf8398e006dd7e0cd83962720ffad6b4854a7fa5e5be00d67fd4a0e2fc37592c54e29847d8b4d38cf9aecb8a25dc8b7f3203eca232fe5dfe962df
languageName: node
linkType: hard

"typescript@npm:>=4.7.0, typescript@npm:^5.0.0":
version: 5.4.3
resolution: "typescript@npm:5.4.3"
Expand Down

0 comments on commit 576f29a

Please sign in to comment.