Skip to content

Commit

Permalink
Migrate to ESLint v9
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Haines <[email protected]>
  • Loading branch information
haines committed Oct 14, 2024
1 parent 8531af1 commit 65c42ce
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 448 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

87 changes: 0 additions & 87 deletions .eslintrc.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@
"matchPackageNames": ["@types/node"],
"matchUpdateTypes": ["major"],
"enabled": false
},
{
"description": "eslint v9 is not widely supported by plugins yet",
"matchPackageNames": ["eslint"],
"matchUpdateTypes": ["major"],
"enabled": false
},
{
"description": "eslint-plugin-vitest only supports flat config from v0.5.0 (https://github.com/veritem/eslint-plugin-vitest/issues/414)",
"matchPackageNames": ["eslint-plugin-vitest"],
"matchUpdateTypes": ["minor"],
"enabled": false
}
],
"postUpdateOptions": ["pnpmDedupe"],
Expand Down
137 changes: 137 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import eslint from "@eslint/js";
import vitestPlugin from "@vitest/eslint-plugin";
import importPlugin from "eslint-plugin-import";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import tsdocPlugin from "eslint-plugin-tsdoc";
import typescriptPlugin from "typescript-eslint";

export default typescriptPlugin.config(
{
ignores: [
"packages/*/lib/**",
"packages/*/src/protobuf/**",
"private/*/src/protobuf/**",
],
},
eslint.configs.recommended,
...typescriptPlugin.configs.strictTypeChecked,
...typescriptPlugin.configs.stylisticTypeChecked,
importPlugin.flatConfigs.typescript,
{
plugins: {
import: importPlugin,
},
settings: {
"import/internal-regex": "^@cerbos/",
},
languageOptions: {
parserOptions: {
projectService: true,
},
},
rules: {
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/explicit-member-accessibility": "warn",
"@typescript-eslint/no-confusing-void-expression": "warn",
"@typescript-eslint/no-require-imports": [
"warn",
{ allow: ["/package\\.json$"] },
],
"@typescript-eslint/no-unnecessary-condition": [
"warn",
{ allowConstantLoopConditions: true },
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/prefer-enum-initializers": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/promise-function-async": "warn",
"@typescript-eslint/restrict-template-expressions": [
"warn",
{ allowNumber: true },
],
"@typescript-eslint/return-await": ["warn", "always"],
curly: "warn",
"func-style": ["warn", "declaration"],
"import/consistent-type-specifier-style": ["warn", "prefer-top-level"],
"import/export": "warn",
"import/newline-after-import": "warn",
"import/no-duplicates": "warn",
"import/no-extraneous-dependencies": [
"warn",
{
devDependencies: ["private/**", "eslint.config.mjs"],
optionalDependencies: false,
includeTypes: true,
},
],
"import/no-named-as-default": "warn",
"import/order": [
"warn",
{
alphabetize: {
order: "asc",
orderImportKind: "asc",
caseInsensitive: true,
},
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "always",
},
],
"no-console": "warn",
"no-constant-condition": ["warn", { checkLoops: false }],
quotes: ["warn", "double", { avoidEscape: true }],
"sort-imports": ["warn", { ignoreDeclarationSort: true }],
},
},
{
files: ["**/*.ts"],
plugins: {
tsdoc: tsdocPlugin,
},
rules: {
"tsdoc/syntax": "warn",
},
},
{
files: ["packages/react/**"],
plugins: {
"react-hooks": reactHooksPlugin,
},
rules: reactHooksPlugin.configs.recommended.rules,
},
{
files: ["private/scripts/**"],
rules: {
"no-console": "off",
},
},
{
files: ["**/*.test.ts", "private/test/src/helpers.ts"],
...vitestPlugin.configs.recommended,
settings: {
vitest: {
typecheck: true,
},
},
rules: {
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"vitest/expect-expect": ["warn", { assertFunctionNames: ["expect*"] }],
},
},
);
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "0.16.4",
"@eslint/js": "9.12.0",
"@microsoft/api-documenter": "7.25.17",
"@microsoft/api-extractor": "7.47.9",
"@tsconfig/node18": "18.2.4",
"@tsconfig/strictest": "2.0.5",
"@types/eslint__js": "8.42.3",
"@types/node": "18.19.55",
"@typescript-eslint/eslint-plugin": "8.8.1",
"@typescript-eslint/parser": "8.8.1",
"@vitest/eslint-plugin": "1.1.7",
"concurrently": "9.0.1",
"depcheck": "1.4.7",
"eslint": "8.57.1",
"eslint": "9.12.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-tsdoc": "0.3.0",
"prettier": "3.3.3",
"prettier-plugin-pkg": "0.18.1",
"ts-proto": "2.2.3",
"tsx": "4.19.1",
"typescript": "5.6.3"
"typescript": "5.6.3",
"typescript-eslint": "8.8.1"
}
}
1 change: 0 additions & 1 deletion packages/grpc/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Client } from "@cerbos/core";

import { Transport } from "./transport";

// eslint-disable-next-line @typescript-eslint/no-var-requires -- Can't import package.json because it is outside of the project's rootDir
const { version } = require("../package.json") as { version: string };

const defaultUserAgent = `cerbos-sdk-javascript-grpc/${version}`;
Expand Down
1 change: 0 additions & 1 deletion packages/http/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Client } from "@cerbos/core";

import { Transport } from "./transport";

// eslint-disable-next-line @typescript-eslint/no-var-requires -- Can't import package.json because it is outside of the project's rootDir
const { version } = require("../package.json") as { version: string };

const defaultUserAgent = `cerbos-sdk-javascript-http/${version}`;
Expand Down
1 change: 0 additions & 1 deletion packages/opentelemetry/src/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires -- Can't import package.json because it is outside of the project's rootDir
export const { name, version } = require("../package.json") as {
name: string;
version: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/react/.eslintrc.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"use-deep-compare-effect": "^1.8.1"
},
"devDependencies": {
"@types/react": "18.3.11",
"eslint-plugin-react-hooks": "4.6.2"
"@types/react": "18.3.11"
},
"publishConfig": {
"access": "public",
Expand Down
Loading

0 comments on commit 65c42ce

Please sign in to comment.