Skip to content

Commit

Permalink
Merge pull request #208 from AndreaPontrandolfo/AndreaPontrandolfo/is…
Browse files Browse the repository at this point in the history
…sue179

Added ESLint v9 support
  • Loading branch information
AndreaPontrandolfo committed Aug 15, 2024
2 parents 756ff30 + b4685c3 commit 6063a81
Show file tree
Hide file tree
Showing 19 changed files with 657 additions and 729 deletions.
12 changes: 12 additions & 0 deletions .changeset/wild-peas-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'eslint-config-sheriff': major
'create-sheriff-config': patch
'@sherifforg/constants': patch
'sheriff-webservices': patch
'@sheriff/utils': patch
'docs-website': patch
---

feat(config): added ESLint v9 support and removed ESLint version 8.57.0 pins
Fixes #179
Fixes #185
2 changes: 1 addition & 1 deletion apps/config-validation-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.2.15",
"eslint": "^8.57.0",
"eslint": "^9.9.0",
"eslint-config-sheriff": "workspace:*",
"eslint-define-config": "^2.1.0",
"tsconfig": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/docs/eslint-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sidebar_position: 7
- [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
- [eslint-plugin-tsdoc](https://www.npmjs.com/package/eslint-plugin-tsdoc)
- [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest)
- [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/tree/main)
- [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest)
- [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) with [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript)
- [eslint-plugin-lodash-f](https://github.com/AndreaPontrandolfo/eslint-plugin-lodash) (my fork of [eslint-plugin-lodash](https://github.com/wix/eslint-plugin-lodash))
- [@next/eslint-plugin-next](https://www.npmjs.com/package/@next/eslint-plugin-next)
Expand Down
4 changes: 2 additions & 2 deletions apps/docs-website/docs/requirements/hard-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ description: The bare minimum

# Hard requirements

- [Node >=16](https://nodejs.org/en/)
- [ESLint >=8.38.0](https://eslint.org/)
- [Node >=18.18](https://nodejs.org/en/)
- [ESLint >=9.0.0](https://eslint.org/)
- [Typescript >= 5.0.0](https://www.typescriptlang.org/)
2 changes: 1 addition & 1 deletion apps/docs-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.2.15",
"eslint": "^8.57.0",
"eslint": "^9.9.0",
"eslint-config-sheriff": "workspace:*",
"eslint-define-config": "^2.1.0",
"eslint-plugin-mdx": "^3.1.5",
Expand Down
8 changes: 4 additions & 4 deletions apps/sheriff-webservices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
"typescript": "^5.5.3"
},
"dependencies": {
"@eslint-react/eslint-plugin": "^1.5.12",
"@eslint/js": "^8.57.0",
"@eslint-react/eslint-plugin": "^1.10.1",
"@eslint/js": "^9.9.0",
"@hono/node-server": "^1.12.0",
"@next/eslint-plugin-next": "^13.2.3",
"@regru/eslint-plugin-prefer-early-return": "^1.0.0",
"@stylistic/eslint-plugin": "^1.5.1",
"eslint": "^8.57.0",
"@vitest/eslint-plugin": "^1.0.3",
"eslint": "^9.9.0",
"eslint-config-sheriff": "workspace:*",
"eslint-plugin-arrow-return-style": "^1.3.0",
"eslint-plugin-astro": "^1.2.3",
Expand All @@ -51,7 +52,6 @@
"eslint-plugin-storybook": "^0.6.11",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-vitest": "^0.3.26",
"hono": "^3.12.0",
"lodash": "^4.17.21",
"typescript-eslint": "^8.0.1"
Expand Down
2 changes: 1 addition & 1 deletion apps/sheriff-webservices/src/getAllRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import sonarjs from 'eslint-plugin-sonarjs';
import storybook from 'eslint-plugin-storybook';
import tsdoc from 'eslint-plugin-tsdoc';
import unicorn from 'eslint-plugin-unicorn';
import vitest from 'eslint-plugin-vitest';
import tseslint from 'typescript-eslint';
import eslintRecommended from '@eslint/js';
import rel1cxReact from '@eslint-react/eslint-plugin';
Expand All @@ -28,6 +27,7 @@ import type {
SheriffSettings,
} from '@sherifforg/types';
import stylistic from '@stylistic/eslint-plugin';
import vitest from '@vitest/eslint-plugin';
import { prependRulesWithPluginName } from './prependRulesWithPluginName.js';

interface Plugin {
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
],
"ignoreMissing": [
"vitest"
],
"allowedVersions": {
"eslint": "8.57.0 || 8.57.0-0"
}
]
}
}
}
2 changes: 1 addition & 1 deletion packages/create-sheriff-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.10",
"@types/yargs": "^17.0.32",
"eslint": "^8.57.0",
"eslint": "^9.9.0",
"eslint-config-sheriff": "workspace:*",
"eslint-define-config": "^2.1.0",
"publint": "^0.2.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { consola } from 'consola';
import { colors } from 'consola/utils';
import { isNumber } from 'lodash-es';
import { addDependency, detectPackageManager } from 'nypm';
import { CURRENT_FROZEN_ESLINT_VERSION } from '@sherifforg/constants';
import { getInstallationCommand } from './getInstallationCommand';
import { getPackageJsonContents } from './getPackageJsonContents';
import { throwError } from './throwError';
Expand All @@ -12,10 +11,6 @@ export const autoInstallPackages = async (
selectedProject: string | null,
): Promise<void> => {
const packagesLatestVersions = packages.map((packageName) => {
if (packageName === 'eslint') {
return `eslint@${CURRENT_FROZEN_ESLINT_VERSION}`;
}

const lastCharacter = packageName.charAt(packageName.length - 1);

if (isNumber(lastCharacter)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { consola } from 'consola';
import { CURRENT_FROZEN_ESLINT_VERSION } from '@sherifforg/constants';

export const getRequiredPackages = (
isEslintTsPatchRequired: boolean,
Expand All @@ -16,10 +15,7 @@ export const getRequiredPackages = (
consola.start("Installing 'eslint-config-sheriff'...");

if (isEslintTsPatchRequired) {
requiredPackages.push(
`eslint-ts-patch@${CURRENT_FROZEN_ESLINT_VERSION}`,
`eslint@npm:eslint-ts-patch@${CURRENT_FROZEN_ESLINT_VERSION}`,
);
requiredPackages.push(`eslint-ts-patch@`, `eslint@npm:eslint-ts-patch@`);
consola.start("Installing 'eslint-ts-patch'...");
requiredPackages.push('@sherifforg/types');
consola.start("Installing '@sherifforg/types'...");
Expand Down
15 changes: 8 additions & 7 deletions packages/eslint-config-sheriff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
"are-the-types-wrong": "attw --pack ."
},
"dependencies": {
"@eslint-react/eslint-plugin": "^1.5.12",
"@eslint/js": "^8.57.0",
"@eslint-react/eslint-plugin": "^1.10.1",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.9.0",
"@next/eslint-plugin-next": "^13.2.3",
"@regru/eslint-plugin-prefer-early-return": "^1.0.0",
"@stylistic/eslint-plugin": "^1.5.1",
"@vitest/eslint-plugin": "^1.0.3",
"eslint-config-flat-gitignore": "^0.1.3",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-arrow-return-style": "^1.3.0",
Expand All @@ -80,16 +82,15 @@
"eslint-plugin-storybook": "^0.6.11",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-vitest": "^0.3.26",
"globals": "^15.9.0",
"typescript-eslint": "^8.0.1"
},
"peerDependencies": {
"eslint": "8.38.0 - 8.57.0 || 8.57.0-0",
"eslint": ">=9.0.0",
"typescript": ">=5.0.0"
},
"engines": {
"node": ">=16"
"node": ">=18.18"
},
"license": "MIT",
"devDependencies": {
Expand All @@ -100,8 +101,8 @@
"@types/eslint__js": "^8.42.3",
"@types/lodash": "^4.17.6",
"@types/node": "^20.14.10",
"@typescript-eslint/utils": "^8.0.1",
"eslint": "^8.57.0",
"@typescript-eslint/utils": "^8.1.0",
"eslint": "^9.9.0",
"eslint-define-config": "^2.1.0",
"lodash": "^4.17.21",
"publint": "^0.2.8",
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config-sheriff/src/getBaseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { unicornHandPickedRules } from './handpickedRules/unicornHandPickedRules
import { getBaseEslintHandPickedRules } from './handpickedRules/getBaseEslintHandPickedRules';
import { getLanguageOptionsTypescript } from './utils/getLanguageOptionsTypescript';
import globals from 'globals';
import { fixupPluginRules } from '@eslint/compat';

export const getBaseConfig = (
userConfigChoices: SheriffSettings,
Expand Down Expand Up @@ -127,7 +128,7 @@ export const getBaseConfig = (
},
{
files: [supportedFileTypes],
plugins: { import: pluginImport },
plugins: { import: fixupPluginRules(pluginImport) },
rules: importHandPickedRules,
settings: {
'import/parsers': {
Expand All @@ -147,7 +148,7 @@ export const getBaseConfig = (
'**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)',
'**/*.story.@(ts|tsx|js|jsx|mjs|cjs)',
],
plugins: { storybook },
plugins: { storybook: fixupPluginRules(storybook) },
rules: {
...storybook.configs.recommended.overrides[0].rules,
...storybook.configs.csf.overrides[0].rules,
Expand All @@ -157,7 +158,7 @@ export const getBaseConfig = (
},
{
files: ['**/.storybook/main.@(js|cjs|mjs|ts)'],
plugins: { storybook },
plugins: { storybook: fixupPluginRules(storybook) },
rules: storybook.configs.recommended.overrides[1].rules,
},
{
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-config-sheriff/src/getJestConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import jest from 'eslint-plugin-jest';
import tseslint from 'typescript-eslint';
import { allJsExtensions } from '@sherifforg/constants';
import { jestHandPickedRules } from './handpickedRules/jestHandPickedRules';
import { type TSESLint } from '@typescript-eslint/utils';

export const getJestConfig = (pathsOverrides?: string[]) => {
export const getJestConfig = (
pathsOverrides?: string[],
): TSESLint.FlatConfig.ConfigArray => {
return tseslint.config({
files: pathsOverrides ?? [
`**/*.{test,spec}.{${allJsExtensions}}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-sheriff/src/getVitestConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import vitest from 'eslint-plugin-vitest';
import vitest from '@vitest/eslint-plugin';
import { allJsExtensions } from '@sherifforg/constants';
import { vitestHandPickedRules } from './handpickedRules/vitestHandPickedRules';

Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-config-sheriff/src/nextjsConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import nextjs from '@next/eslint-plugin-next';
import { fixupPluginRules } from '@eslint/compat';
import { supportedFileTypes } from '@sherifforg/constants';

export const nextjsConfig = {
files: [supportedFileTypes],
plugins: {
'@next/next': nextjs,
'@next/next': fixupPluginRules(nextjs),
},
rules: {
...nextjs.configs.recommended.rules,
Expand Down
2 changes: 0 additions & 2 deletions packages/sheriff-constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,3 @@ export const baseNoRestrictedSyntaxRules = [
message: 'Avoid classes. Use functions and objects instead.',
},
] as const;

export const CURRENT_FROZEN_ESLINT_VERSION = '8.57.0';
2 changes: 1 addition & 1 deletion packages/sheriff-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@sherifforg/types": "workspace:*",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.14.10",
"eslint": "^8.57.0",
"eslint": "^9.9.0",
"eslint-config-sheriff": "workspace:*",
"eslint-define-config": "^2.1.0",
"lodash-es": "^4.17.21",
Expand Down
Loading

0 comments on commit 6063a81

Please sign in to comment.