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

chore(eslint): upgrade eslint to v9 #2716

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
35fbdc1
chore(eslint): upgrade docs/preview to eslint@9
liady Jan 20, 2025
f677160
chore(eslint): upgrade examples/express to eslint@9
liady Jan 20, 2025
e501805
chore(eslint): upgrade templates/skeleton to eslint@9
liady Jan 20, 2025
d88c0c3
chore(eslint): upgrade root package.json to eslint@9
liady Jan 20, 2025
3f0f04d
chore(eslint): upgrade hyrogen-react to eslint@9
liady Jan 20, 2025
8f3f5ad
minor
liady Jan 20, 2025
5176700
minor fixes
liady Jan 20, 2025
c5fc0ef
remove unused flag
liady Jan 20, 2025
80e3856
change lint script
liady Jan 21, 2025
086ab9c
packages
liady Jan 21, 2025
4a2a258
chore(eslint): better v9 conversion - hydrogen-react
liady Jan 21, 2025
4d9a31d
chore(eslint): upgrade eslint in templates/skeleton
liady Jan 21, 2025
030f262
root config
liady Jan 26, 2025
1a447e4
fix config
liady Jan 27, 2025
fdc556e
remove eslint from packages
liady Jan 27, 2025
4842137
imports reorder and object shorthand
liady Jan 27, 2025
300f7d6
lint config
liady Jan 27, 2025
66ee24b
fix lint
liady Jan 27, 2025
416d944
lint fixes
liady Jan 27, 2025
702d51f
eslint config
liady Jan 27, 2025
6176c67
lint config
liady Jan 27, 2025
4c0945c
eslint config
liady Jan 27, 2025
ba4a509
Merge branch 'main' into chore/eslint-upgrade
liady Jan 27, 2025
efa5cf3
remove remix eslint config from expected test
liady Jan 27, 2025
3ab5340
no need for -ext in selint v9
liady Jan 27, 2025
cd96615
fix test
liady Jan 27, 2025
a54d1a0
pr fixes
liady Jan 28, 2025
d7ebd48
upgrade isbot
liady Jan 28, 2025
0b9c3bd
ignore generated file
liady Jan 28, 2025
e5e5007
Merge branch 'main' into chore/eslint-upgrade
liady Jan 28, 2025
16ca847
remove the package-lock in the assets/vite folder
wizardlyhel Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

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

This file was deleted.

2 changes: 0 additions & 2 deletions docs/preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
},
"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",
"typescript": "^5.2.2",
"vite": "^5.1.8",
"vite-tsconfig-paths": "^4.3.1"
Expand Down
316 changes: 316 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat');
const js = require('@eslint/js');
const {FlatCompat} = require('@eslint/eslintrc');
const eslintComments = require('eslint-plugin-eslint-comments');
const react = require('eslint-plugin-react');
const reactHooks = require('eslint-plugin-react-hooks');
const jsxA11Y = require('eslint-plugin-jsx-a11y');
const tsdoc = require('eslint-plugin-tsdoc');
const jest = require('eslint-plugin-jest');
const simpleImportSort = require('eslint-plugin-simple-import-sort');
const tsParser = require('@typescript-eslint/parser');
const globals = require('globals');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

const lintedTSPackages = [
'packages/hydrogen-react',
'examples/express',
'templates/skeleton',
'docs/previews',
];

module.exports = [
// Global ignores
{
ignores: [
'**/node_modules/',
'**/build/',
'**/*.graphql.d.ts',
'**/*.graphql.ts',
'**/storefront-api-types.d.ts',
'**/customer-account-api-types.d.ts',
'**/codegen.ts',
'**/dist/**/*',
'**/coverage/**/*',
'**/docs/**/*',
'**/.eslintrc.cjs',
'**/src/**/*.example.tsx',
'**/src/**/*.example.ts',
'**/src/**/*.example.jsx',
'**/src/**/*.example.js',
'**/eslint.config.cjs',
'**/scripts/**/*',
'bin/',
'*.d.ts',
'**/codegen.ts',
'**/vite.config.ts',
'**/vitest.setup.ts',
'**/vitest.config.ts',
'**/tsup.config.ts',
],
},

// Base configurations
...fixupConfigRules(
compat.extends(
'plugin:node/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'eslint:recommended',
'plugin:eslint-comments/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
),
),

// Core configuration with plugins and general rules
{
plugins: {
'eslint-comments': fixupPluginRules(eslintComments),
react: fixupPluginRules(react),
'react-hooks': fixupPluginRules(reactHooks),
'jsx-a11y': fixupPluginRules(jsxA11Y),
},
settings: {
'import/resolvers': {
typescript: {
project: [
'packages/*/tsconfig.json',
'templates/*/tsconfig.json',
'examples/*/tsconfig.json',
'docs/*/tsconfig.json',
],
},
},
react: {version: 'detect'},
jest: {version: 28},
},
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: {jsx: true},
},
globals: {
...globals.browser,
...globals.node,
},
ecmaVersion: 2020,
sourceType: 'module',
},
linterOptions: {
reportUnusedDisableDirectives: false,
},
rules: {
// React rules
'react/display-name': 'off',
'react/no-array-index-key': 'warn',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'react/no-children-prop': 'off',
'react/no-unescaped-entities': 'off',
'react/jsx-no-target-blank': 'off',
'react-hooks/exhaustive-deps': 'error',

// Node rules
'node/shebang': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-missing-import': 'off',
'node/no-extraneous-import': 'off',
'node/no-unpublished-import': 'off',
'node/no-unsupported-features/es-builtins': [
'error',
{version: '>=14.0.0', ignores: []},
],
'node/no-unsupported-features/node-builtins': [
'error',
{version: '>=14.0.0', ignores: []},
],

// TypeScript rules
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',

// General rules
'object-shorthand': ['error', 'always', {avoidQuotes: true}],
'prefer-const': ['warn', {destructuring: 'all'}],
'no-prototype-builtins': 'off',
'no-use-before-define': 'off',
'no-warning-comments': 'off',
'no-empty': 'off',
'no-control-regex': 'off',
'no-async-promise-executor': 'off',
'eslint-comments/no-unused-disable': 'off',
'jest/no-disabled-tests': 'off',
'jest/no-export': 'off',
'no-console': 'off',
'no-ex-assign': 'off',
'no-constant-condition': 'off',
'no-useless-escape': 'off',
'no-case-declarations': 'off',
'no-process-exit': 'off',

// Import rules
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
},

// Test files configuration
...compat.extends('plugin:jest/recommended').map((config) => ({
...config,
files: ['**/*.test.*'],
})),
{
files: ['**/*.test.*'],
plugins: {jest},
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
},
},

// TypeScript files configuration
{
files: ['**/*.ts', '**/*.tsx'],
settings: {
'import/resolvers': {
typescript: {
project: [
'packages/*/tsconfig.json',
'templates/*/tsconfig.json',
'examples/*/tsconfig.json',
'docs/*/tsconfig.json',
],
},
},
},
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
ecmaFeatures: {jsx: true},
},
},
rules: {
'no-unused-vars': 'off',
'no-undef': 'off',
'prefer-const': 'off',
},
},

// Server files configuration
{
files: ['**/*.server.*'],
rules: {
'react-hooks/rules-of-hooks': 'off',
},
},

// Linted TypeScript packages configuration
{
files: [
...lintedTSPackages.flatMap((pkg) => [
`${pkg}/**/*.ts`,
`${pkg}/**/*.tsx`,
]),
],
rules: {
'no-undef': 'off',
'no-unused-vars': 'off',
'tsdoc/syntax': 'error',
'react/jsx-no-target-blank': 'error',
'node/no-extraneous-import': [
'error',
{
allowModules: [
'@shopify/hydrogen',
'@shopify/react-testing',
'@remix-run/web-fetch',
'@total-typescript/ts-reset',
],
},
],
'node/no-extraneous-require': [
'error',
{
allowModules: ['@shopify/hydrogen'],
},
],
},
plugins: {tsdoc},
},

// TypeScript strict configuration for linted packages
...fixupConfigRules(
compat.extends(
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jsx-a11y/recommended',
),
).map((config) => ({
...config,
files: [
...lintedTSPackages.flatMap((pkg) => [
`${pkg}/**/*.ts`,
`${pkg}/**/*.tsx`,
]),
],
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
ecmaFeatures: {jsx: true},
},
},
rules: {
'jsx-a11y/control-has-associated-label': 'off',
'jsx-a11y/label-has-for': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
},
})),

// Example files configuration
{
files: [
'**/*.example.ts',
'**/*.example.js',
'**/*.example.tsx',
'**/*.example.jsx',
],
rules: {
'node/no-extraneous-import': 'off',
'node/no-extraneous-require': 'off',
'no-unused-vars': 'off',
'no-undef': 'off',
'import/no-duplicates': 'off',
'react-hooks/exhaustive-deps': 'off',
'prefer-const': 'off',
'import/no-named-as-default': 'off',
'node/no-missing-require': 'off',
},
},

// Index files configuration
{
files: ['**/src/index.ts'],
plugins: {'simple-import-sort': simpleImportSort},
rules: {'simple-import-sort/exports': 'error'},
},

// Hydrogen package configuration
{
files: ['packages/hydrogen/**/*.tsx', 'packages/hydrogen/**/*.ts'],
rules: {'react-hooks/exhaustive-deps': '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
3 changes: 1 addition & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
"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",
"dotenv": "^16.0.3",
"eslint": "^8.38.0",
"nodemon": "^2.0.22",
"npm-run-all": "^4.1.5",
"typescript": "^5.2.2",
Expand Down
Loading
Loading