Skip to content

Commit

Permalink
feature: Update to ESLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
Karibash committed Nov 25, 2024
1 parent d6a5ea8 commit 1bb9116
Show file tree
Hide file tree
Showing 26 changed files with 667 additions and 1,245 deletions.
13 changes: 13 additions & 0 deletions .changeset/neat-icons-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@praha/eslint-config-javascript": major
"@praha/eslint-config-jest-react": major
"@praha/eslint-config-typescript": major
"@praha/eslint-config-definer": major
"@praha/eslint-config-common": major
"@praha/eslint-config-react": major
"@praha/eslint-config-style": major
"@praha/eslint-config-jest": major
"@praha/eslint-config-next": major
---

Update to ESLint v9
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.9",
"turbo": "2.2.3"
"@changesets/cli": "2.27.10",
"turbo": "2.3.1"
},
"packageManager": "pnpm@9.12.2"
"packageManager": "pnpm@9.14.2"
}
9 changes: 4 additions & 5 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
},
"dependencies": {
"@praha/eslint-config-definer": "workspace:*",
"eslint-plugin-jsonc": "^2.16.0"
"eslint-plugin-jsonc": "^2.18.2"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"eslint": "^8.0.0"
"eslint": "^9.0.0"
}
}
1 change: 1 addition & 0 deletions packages/common/src/configurators/ignore-configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Configurator } from '@praha/eslint-config-definer';
export const ignoreConfigurator: Configurator = () => {
return [
{
name: 'praha/common/ignore',
ignores: [
// Node modules
'**/node_modules',
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/configurators/json-configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const jsonConfigurator: Configurator = () => {
return [
{
name: 'jsonc/recommended-with-json',
...Object.assign({}, ...eslintPluginJsonc.configs['flat/recommended-with-json']) as Linter.FlatConfig,
...Object.assign({}, ...eslintPluginJsonc.configs['flat/recommended-with-json']) as Linter.Config,
},
{
// This rule refers to the sort-package-json.
Expand Down
7 changes: 3 additions & 4 deletions packages/definer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"eslint": "^8.0.0"
"eslint": "^9.0.0"
}
}
10 changes: 6 additions & 4 deletions packages/definer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Linter } from 'eslint';

type ExtractOptionType<T> = T extends Configurator<infer U> ? U : never;

type UnionToIntersection<U> =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type MergeOptionTypes<T extends any[]> = UnionToIntersection<ExtractOptionType<T[number]>>;

export type Configurator<T = void> =
T extends void
? (() => Linter.FlatConfig[])
: ((options: T) => Linter.FlatConfig[]);
? (() => Linter.Config[])
: ((options: T) => Linter.Config[]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const define = <T extends Configurator<any>[]>(
configurators: T,
): (options: MergeOptionTypes<T>) => Linter.FlatConfig[] => {
): (options: MergeOptionTypes<T>) => Linter.Config[] => {
return (options) => configurators.flatMap((configurator) => {
if (typeof configurator === 'object') return configurator;
return configurator(options);
Expand Down
20 changes: 9 additions & 11 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,21 @@
"lint:type": "tsc --noEmit"
},
"dependencies": {
"@eslint/js": "^8.57.0",
"@eslint/js": "^9.15.0",
"@praha/eslint-config-definer": "workspace:*",
"eslint-plugin-import-x": "^3.1.0",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-unused-imports": "^3.2.0",
"globals": "^15.8.0"
"eslint-plugin-import-x": "^4.4.3",
"eslint-plugin-unicorn": "^56.0.1",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.12.0"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"@types/eslint__js": "8.42.3",
"@typescript-eslint/eslint-plugin": "7.18.0",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"@typescript-eslint/eslint-plugin": "8.15.0",
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"@praha/eslint-config-common": "workspace:*",
"eslint": "^8.0.0"
"eslint": "^9.0.0"
}
}
17 changes: 3 additions & 14 deletions packages/javascript/src/configurators/import-configurator.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import eslintPluginImportX from 'eslint-plugin-import-x';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import eslintPluginUnusedImports from 'eslint-plugin-unused-imports';

import type { Configurator } from '@praha/eslint-config-definer';
import type { ESLint } from 'eslint';
import type { Linter } from 'eslint';

export const importConfigurator: Configurator = () => {
return [
{
name: 'import-x/recommended',
plugins: {
'import-x': eslintPluginImportX as unknown as ESLint.Plugin,
},
rules: eslintPluginImportX.configs.recommended.rules,
languageOptions: {
parserOptions: eslintPluginImportX.configs.recommended.parserOptions,
},
},
eslintPluginImportX.flatConfigs.recommended as Linter.Config,
{
name: 'unused-imports/setup',
plugins: {
'unused-imports': eslintPluginUnusedImports as unknown as ESLint.Plugin,
'unused-imports': eslintPluginUnusedImports,
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export const javascriptConfigurator: Configurator = () => {
name: 'eslint/recommended',
...eslint.configs.recommended,
},
{
name: 'unicorn/recommended',
...eslintPluginUnicorn.configs['flat/recommended'],
},
eslintPluginUnicorn.configs['flat/recommended'],
{
name: 'praha/javascript/rules',
rules: {
Expand Down
11 changes: 5 additions & 6 deletions packages/jest-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@
},
"dependencies": {
"@praha/eslint-config-definer": "workspace:*",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-testing-library": "^6.2.2"
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-testing-library": "^7.0.0"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"@praha/eslint-config-common": "workspace:*",
Expand All @@ -62,7 +61,7 @@
"@praha/eslint-config-next": "workspace:*",
"@praha/eslint-config-react": "workspace:*",
"@praha/eslint-config-typescript": "workspace:*",
"eslint": "^8.0.0"
"eslint": "^9.0.0"
},
"peerDependenciesMeta": {
"@praha/eslint-config-next": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import eslintPluginJestDom from 'eslint-plugin-jest-dom';

import { files } from '../files';

import type { Configurator } from '@praha/eslint-config-definer';
import type { Linter } from 'eslint';

export const jestDomConfigurator: Configurator = () => {
return [
{
name: 'jest-dom/recommended',
files,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...eslintPluginJestDom.configs['flat/recommended'] as Linter.FlatConfig,
...eslintPluginJestDom.configs['flat/recommended'],
},
];
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import eslintPluginTestingLibrary from 'eslint-plugin-testing-library';

import { files } from '../files';

import type { Configurator } from '@praha/eslint-config-definer';
import type { ESLint, Linter } from 'eslint';

export const testingLibraryConfigurator: Configurator = () => {
return [
{
name: 'testing-library/recommended',
files,
plugins: {
'testing-library': eslintPluginTestingLibrary as ESLint.Plugin,
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
rules: eslintPluginTestingLibrary.configs.recommended.rules as Linter.RulesRecord,
...eslintPluginTestingLibrary.configs['flat/react'],
},
];
};
13 changes: 6 additions & 7 deletions packages/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,20 @@
},
"dependencies": {
"@praha/eslint-config-definer": "workspace:*",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"eslint-plugin-jest": "^28.6.0",
"globals": "^15.8.0"
"@typescript-eslint/eslint-plugin": "^8.15.0",
"eslint-plugin-jest": "^28.9.0",
"globals": "^15.12.0"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"@praha/eslint-config-common": "workspace:*",
"@praha/eslint-config-javascript": "workspace:*",
"@praha/eslint-config-typescript": "workspace:*",
"eslint": "^8.0.0"
"eslint": "^9.0.0"
},
"peerDependenciesMeta": {
"@praha/eslint-config-typescript": {
Expand Down
9 changes: 2 additions & 7 deletions packages/jest/src/configurators/jest-configurator.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import eslintPluginJest from 'eslint-plugin-jest';

import { files } from '../files';

import type { Configurator } from '@praha/eslint-config-definer';
import type { Linter } from 'eslint';

export const jestConfigurator: Configurator = () => {
return [
{
name: 'jest/recommended',
files,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...eslintPluginJest.configs['flat/recommended'] as Linter.FlatConfig,
...eslintPluginJest.configs['flat/recommended'],
},
{
name: 'jest/style',
files,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
...eslintPluginJest.configs['flat/style'] as Linter.FlatConfig,
...eslintPluginJest.configs['flat/style'],
},
{
name: 'praha/jest/rules',
Expand Down
10 changes: 5 additions & 5 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@
"lint:type": "tsc --noEmit"
},
"dependencies": {
"@next/eslint-plugin-next": "^14.2.5",
"@eslint/compat": "1.2.3",
"@next/eslint-plugin-next": "^15.0.3",
"@praha/eslint-config-definer": "workspace:*"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"@praha/eslint-config-common": "workspace:*",
"@praha/eslint-config-javascript": "workspace:*",
"@praha/eslint-config-react": "workspace:*",
"@praha/eslint-config-typescript": "workspace:*",
"eslint": "^8.0.0"
"eslint": "^9.0.0"
},
"peerDependenciesMeta": {
"@praha/eslint-config-typescript": {
Expand Down
3 changes: 2 additions & 1 deletion packages/next/src/configurators/next-configurator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fixupPluginRules } from '@eslint/compat';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import eslintPluginNext from '@next/eslint-plugin-next';
Expand All @@ -10,7 +11,7 @@ export const nextConfigurator: Configurator = () => {
{
name: '@next/next/core-web-vitals',
plugins: {
'@next/next': eslintPluginNext as ESLint.Plugin,
'@next/next': fixupPluginRules(eslintPluginNext as ESLint.Plugin),
},
rules: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
Expand Down
14 changes: 6 additions & 8 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,21 @@
"lint:type": "tsc --noEmit"
},
"dependencies": {
"@eslint/compat": "1.1.1",
"@praha/eslint-config-definer": "workspace:*",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2"
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0"
},
"devDependencies": {
"@tsconfig/strictest": "2.0.5",
"@types/eslint": "8.56.12",
"eslint": "8.57.1",
"pkgroll": "2.5.0"
"eslint": "9.15.0",
"pkgroll": "2.5.1"
},
"peerDependencies": {
"@praha/eslint-config-common": "workspace:*",
"@praha/eslint-config-javascript": "workspace:*",
"@praha/eslint-config-typescript": "workspace:*",
"eslint": "^8.0.0"
"eslint": "^9.0.0"
},
"peerDependenciesMeta": {
"@praha/eslint-config-typescript": {
Expand Down
Loading

0 comments on commit 1bb9116

Please sign in to comment.