Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] chore(eslint): upgrade eslint to v9 #2716

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.js

This file was deleted.

3 changes: 1 addition & 2 deletions docs/preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
},
"devDependencies": {
"@remix-run/dev": "^2.15.2",
"@remix-run/eslint-config": "^2.15.2",
"@tailwindcss/vite": "4.0.0-beta.8",
"@types/he": "^1.2.1",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/react-syntax-highlighter": "^15.5.7",
"eslint": "^8.38.0",
"eslint": "^9.18.0",
"typescript": "^5.2.2",
"vite": "^5.1.8",
"vite-tsconfig-paths": "^4.3.1"
Expand Down
49 changes: 49 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const typescriptParser = require('@typescript-eslint/parser');
const typescriptPlugin = require('@typescript-eslint/eslint-plugin');

/** @type {import('eslint').Flat.Config[]} */
module.exports = [
{
ignores: [
'build/',
'node_modules/',
'bin/',
'*.d.ts',
'dist/',
'coverage/',
'packages/hydrogen-react/codegen.ts',
'packages/hydrogen-react/vite.config.ts',
'packages/hydrogen-react/vitest.setup.ts',
],
},
{
files: ['**/*.{js,jsx,ts,tsx}'],
settings: {
'import/resolvers': {
typescript: {
project: ['packages/*/tsconfig.json', 'templates/*/tsconfig.json'],
},
},
},
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
linterOptions: {
reportUnusedDisableDirectives: false,
},
plugins: {
'@typescript-eslint': typescriptPlugin,
},
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'no-useless-escape': 'off',
'no-case-declarations': 'off',
},
},
];
4 changes: 0 additions & 4 deletions examples/express/.eslintrc.cjs

This file was deleted.

4 changes: 2 additions & 2 deletions examples/express/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {PassThrough} from 'node:stream';
import type {AppLoadContext, EntryContext} from '@remix-run/node';
import {Response} from '@remix-run/web-fetch';
import {RemixServer} from '@remix-run/react';
import isbot from 'isbot';
import isbotua from 'isbot';
import {renderToPipeableStream} from 'react-dom/server';
import {createContentSecurityPolicy} from '@shopify/hydrogen';

Expand All @@ -22,7 +22,7 @@ export default function handleRequest(
remixContext: EntryContext,
loadContext: AppLoadContext,
) {
return isbot(request.headers.get('user-agent'))
return isbotua(request.headers.get('user-agent'))
? handleBotRequest(
request,
responseStatusCode,
Expand Down
111 changes: 111 additions & 0 deletions examples/express/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import js from '@eslint/js';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';

export default [
// Base configuration for all files
{
ignores: ['!**/.server/**', '!**/.client/**'],
},
js.configs.recommended,

// JavaScript/JSX files configuration
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.browser,
...globals.commonjs,
},
},
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'jsx-a11y': jsxA11yPlugin,
},
settings: {
react: {
version: 'detect',
},
formComponents: ['Form'],
linkComponents: [
{name: 'Link', linkAttribute: 'to'},
{name: 'NavLink', linkAttribute: 'to'},
],
'import/resolver': {
typescript: {},
},
},
rules: {
...reactPlugin.configs.recommended.rules,
...reactPlugin.configs['jsx-runtime'].rules,
...reactHooksPlugin.configs.recommended.rules,
...jsxA11yPlugin.configs.recommended.rules,
},
},

// TypeScript files configuration
{
files: ['**/*.{ts,tsx}'],
plugins: {
'@typescript-eslint': tsPlugin,
import: importPlugin,
},
languageOptions: {
parser: tsParser,
globals: {
React: 'readonly',
},
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
},
},
settings: {
'import/internal-regex': '^~/',
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
node: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
},
},
rules: {
...tsPlugin.configs.recommended.rules,
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
'@typescript-eslint/no-empty-object-type': 'off',
},
},

// Node environment configuration
{
files: ['eslint.config.js'],
languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
globals: {
node: true,
},
},
},

{
files: ['**/*.mjs'], // For Node.js ESM files
languageOptions: {
globals: {
...globals.node,
},
},
},
];
12 changes: 10 additions & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@remix-run/dev": "^2.15.2",
"@remix-run/eslint-config": "^2.15.2",
"@shopify/cli": "~3.73.0",
"@types/compression": "^1.7.2",
"@types/express": "^4.17.17",
"@types/morgan": "^1.9.4",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^8.21.0",
"@typescript-eslint/parser": "^8.21.0",
"dotenv": "^16.0.3",
"eslint": "^8.38.0",
"eslint": "^9.18.0",
"eslint-import-resolver-typescript": "^3.7.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0",
"globals": "^15.14.0",
"nodemon": "^2.0.22",
"npm-run-all": "^4.1.5",
"typescript": "^5.2.2",
Expand Down
Loading
Loading