diff --git a/eslint.config.js b/eslint.config.js index 12277c129..d9985c40d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,49 +1,332 @@ -const typescriptParser = require('@typescript-eslint/parser'); -const typescriptPlugin = require('@typescript-eslint/eslint-plugin'); +const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat'); +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 globals = require('globals'); +const tsParser = require('@typescript-eslint/parser'); +const jest = require('eslint-plugin-jest'); +const simpleImportSort = require('eslint-plugin-simple-import-sort'); +const js = require('@eslint/js'); +const {FlatCompat} = require('@eslint/eslintrc'); + +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); -/** @type {import('eslint').Flat.Config[]} */ module.exports = [ { ignores: [ - 'build/', - 'node_modules/', + '**/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', - 'dist/', - 'coverage/', 'packages/hydrogen-react/codegen.ts', 'packages/hydrogen-react/vite.config.ts', 'packages/hydrogen-react/vitest.setup.ts', ], }, + ...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', + 'plugin:jsx-a11y/recommended', + ), + ), { - files: ['**/*.{js,jsx,ts,tsx}'], + plugins: { + 'eslint-comments': fixupPluginRules(eslintComments), + react: fixupPluginRules(react), + 'react-hooks': fixupPluginRules(reactHooks), + 'jsx-a11y': fixupPluginRules(jsxA11Y), + tsdoc, + }, settings: { 'import/resolvers': { typescript: { - project: ['packages/*/tsconfig.json', 'templates/*/tsconfig.json'], + project: [ + 'packages/*/tsconfig.json', + 'templates/*/tsconfig.json', + 'examples/*/tsconfig.json', + 'docs/*/tsconfig.json', + ], }, }, }, languageOptions: { - parser: typescriptParser, + parser: tsParser, parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', + projectService: { + allowDefaultProject: ['vite.config.ts', 'vitest.setup.ts'], + }, + tsconfigRootDir: __dirname, + ecmaFeatures: { + jsx: true, + }, + }, + globals: { + ...globals.browser, + ...globals.node, }, + ecmaVersion: 2020, + sourceType: 'module', }, linterOptions: { reportUnusedDisableDirectives: false, }, - plugins: { - '@typescript-eslint': typescriptPlugin, + settings: { + react: { + version: 'detect', + }, + jest: { + version: 28, + }, }, rules: { + '@shopify/jsx-no-complex-expressions': 'off', + '@shopify/jsx-no-hardcoded-content': 'off', + 'jsx-a11y/control-has-associated-label': 'off', + 'jsx-a11y/label-has-for': 'off', + 'no-use-before-define': 'off', + 'no-warning-comments': 'off', + 'react/no-children-prop': 'off', + 'object-shorthand': [ + 'error', + 'always', + { + avoidQuotes: true, + }, + ], + 'react/display-name': 'off', + 'react/no-array-index-key': 'warn', + 'react/prop-types': 'off', + 'react/react-in-jsx-scope': 'off', + 'eslint-comments/no-unused-disable': 'off', + 'jest/no-disabled-tests': 'off', + 'jest/no-export': 'off', + 'no-console': 'off', + 'no-constant-condition': 'off', + 'tsdoc/syntax': 'error', + 'node/no-extraneous-import': [ + 'error', + { + allowModules: ['@shopify/hydrogen', '@shopify/react-testing'], + }, + ], + 'node/no-extraneous-require': [ + 'error', + { + allowModules: ['@shopify/hydrogen'], + }, + ], + 'node/no-unsupported-features/es-syntax': '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: [], + }, + ], + 'prefer-const': [ + 'warn', + { + destructuring: 'all', + }, + ], '@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', + 'import/extensions': 'off', + 'import/no-unresolved': 'off', + 'node/no-missing-import': 'off', + 'react-hooks/exhaustive-deps': 'error', + }, + }, + ...compat.extends('plugin:jest/recommended').map((config) => ({ + ...config, + files: ['**/*.test.*'], + })), + { + files: ['**/*.test.*'], + plugins: { + jest, + }, + languageOptions: { + globals: { + ...globals.node, + ...globals.jest, + }, + }, + }, + { + files: ['**/*.server.*'], + rules: { + 'react-hooks/rules-of-hooks': 'off', + }, + }, + ...fixupConfigRules( + compat.extends( + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + ), + ).map((config) => ({ + ...config, + files: [ + 'packages/hydrogen-react/**/*.ts', + 'packages/hydrogen-react/**/*.tsx', + 'examples/express/**/*.ts', + 'examples/express/**/*.tsx', + 'templates/skeleton/**/*.ts', + 'templates/skeleton/**/*.tsx', + 'docs/previews/**/*.ts', + 'docs/previews/**/*.tsx', + ], + languageOptions: { + parser: tsParser, + parserOptions: { + tsconfigRootDir: __dirname, + ecmaFeatures: { + jsx: true, + }, + }, + }, + rules: { + '@typescript-eslint/explicit-function-return-type': 'error', + // handled by @typescript-eslint + 'no-unused-vars': 'off', + 'no-undef': 'off', + }, + })), + // { + // files: ['**/*.ts', '**/*.tsx'], + // languageOptions: { + // parser: tsParser, + // parserOptions: { + // tsconfigRootDir: __dirname, + // ecmaFeatures: { + // jsx: true, + // }, + // }, + // }, + // rules: { + // '@typescript-eslint/explicit-module-boundary-types': 'off', + // '@typescript-eslint/prefer-promise-reject-errors': 'off', + // '@typescript-eslint/naming-convention': [ + // 'error', + // { + // selector: 'default', + // format: ['camelCase', 'PascalCase', 'UPPER_CASE'], + // leadingUnderscore: 'allowSingleOrDouble', + // trailingUnderscore: 'allowSingleOrDouble', + // }, + // { + // selector: 'typeLike', + // format: ['PascalCase'], + // }, + // { + // selector: 'typeParameter', + // format: ['PascalCase'], + // leadingUnderscore: 'allow', + // }, + // { + // selector: 'interface', + // format: ['PascalCase'], + // }, + // { + // selector: 'property', + // format: null, + // }, + // ], + // '@typescript-eslint/no-empty-function': 'off', + // '@typescript-eslint/no-empty-interface': 'off', + // '@typescript-eslint/no-explicit-any': 'off', + // '@typescript-eslint/no-non-null-assertion': 'off', + // '@typescript-eslint/no-unused-vars': 'off', + // 'react/prop-types': 'off', + // 'react/no-children-prop': 'off', + // '@typescript-eslint/no-redundant-type-constituents': 'off', + // '@typescript-eslint/no-unsafe-assignment': 'off', + // '@typescript-eslint/no-unsafe-return': 'off', + // '@typescript-eslint/no-unsafe-argument': 'off', + // '@typescript-eslint/no-unsafe-member-access': 'off', + // '@typescript-eslint/require-await': 'off', + // '@typescript-eslint/only-throw-error': 'off', + // '@typescript-eslint/await-thenable': 'off', + // '@typescript-eslint/no-unsafe-call': 'off', + // }, + // }, + // { + // files: [ + // 'packages/hydrogen-react/**/*.(ts|tsx)', + // 'examples/express/**/*.(ts|tsx)', + // 'templates/skeleton/**/*.(ts|tsx)', + // 'docs/previews/**/*.(ts|tsx)', + // ], + // rules: { + // '@typescript-eslint/no-redundant-type-constituents': 'error', + // '@typescript-eslint/no-unsafe-assignment': 'error', + // '@typescript-eslint/no-unsafe-return': 'error', + // '@typescript-eslint/no-unsafe-argument': 'error', + // '@typescript-eslint/no-unsafe-member-access': 'error', + // '@typescript-eslint/require-await': 'error', + // '@typescript-eslint/only-throw-error': 'error', + // '@typescript-eslint/await-thenable': 'error', + // '@typescript-eslint/no-unsafe-call': 'error', + // }, + // }, + { + 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', + }, + }, + { + files: ['**/src/index.ts'], + plugins: { + 'simple-import-sort': simpleImportSort, + }, + rules: { + 'simple-import-sort/exports': 'error', }, }, ]; diff --git a/package-lock.json b/package-lock.json index 978bb2db5..09b85f010 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,9 @@ "devDependencies": { "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.0", + "@eslint/compat": "^1.2.5", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.18.0", "@playwright/test": "^1.40.1", "@shopify/cli": "~3.73.0", "@types/eslint": "^9.6.1", @@ -44,7 +47,15 @@ "cross-env": "^7.0.3", "eslint": "^9.18.0", "eslint-import-resolver-typescript": "^3.7.0", + "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-import": "^2.31.0", + "eslint-plugin-jest": "^28.11.0", + "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-react": "^7.37.4", + "eslint-plugin-react-hooks": "^5.1.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-tsdoc": "^0.4.0", "globals": "^15.14.0", "lint-staged": "^10.5.4", "prettier": "^2.8.4", @@ -3637,25 +3648,6 @@ "node": ">=12" } }, - "node_modules/@eslint-community/eslint-plugin-eslint-comments": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-4.4.1.tgz", - "integrity": "sha512-lb/Z/MzbTf7CaVYM9WCFNQZ4L1yi3ev2fsFPF99h31ljhSEyUoyEsKsNWiU+qD1glbYTDJdqgyaLKtyTkkqtuQ==", - "dev": true, - "dependencies": { - "escape-string-regexp": "^4.0.0", - "ignore": "^5.2.4" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "dev": true, @@ -6973,18 +6965,6 @@ "node": ">=14" } }, - "node_modules/@pkgr/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", - "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/@playwright/test": { "version": "1.40.1", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", @@ -15235,12 +15215,6 @@ "version": "3.1.3", "license": "MIT" }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", - "dev": true - }, "node_modules/fast-glob": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", @@ -24691,18 +24665,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/pretty-format": { "version": "27.5.1", "dev": true, @@ -28787,22 +28749,6 @@ "tslib": "^2.0.3" } }, - "node_modules/synckit": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", - "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", - "dev": true, - "dependencies": { - "@pkgr/core": "^0.1.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/tapable": { "version": "2.2.1", "dev": true, @@ -32409,10 +32355,6 @@ "worktop": "^0.7.3" }, "devDependencies": { - "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", - "@eslint/compat": "^1.2.5", - "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "^9.18.0", "@faker-js/faker": "^7.6.0", "@graphql-codegen/add": "^5.0.1", "@graphql-codegen/cli": "^5.0.1", @@ -32429,18 +32371,6 @@ "@vitejs/plugin-react": "^4.2.1", "@vitest/coverage-v8": "^1.0.4", "cpy-cli": "^4.2.0", - "eslint": "^9.18.0", - "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jest": "^28.11.0", - "eslint-plugin-jsx-a11y": "^6.10.2", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^5.2.3", - "eslint-plugin-react": "^7.37.4", - "eslint-plugin-react-hooks": "^5.1.0", - "eslint-plugin-simple-import-sort": "^12.1.1", - "eslint-plugin-tsdoc": "^0.4.0", - "globals": "^15.14.0", "happy-dom": "8.7.2", "npm-run-all": "^4.1.5", "prettier": "^3.4.2", @@ -32794,36 +32724,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/hydrogen-react/node_modules/eslint-plugin-prettier": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.3.tgz", - "integrity": "sha512-qJ+y0FfCp/mQYQ/vWQ3s7eUlFEL4PyKfAJxsnYTJ4YT73nsJBWqmEpFryxV9OeUiqmsTsYJ5Y+KDNaeP31wrRw==", - "dev": true, - "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.9.1" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint-plugin-prettier" - }, - "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "eslint-config-prettier": "*", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } - } - }, "packages/hydrogen-react/node_modules/estree-util-is-identifier-name": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/estree-util-is-identifier-name/-/estree-util-is-identifier-name-3.0.0.tgz", diff --git a/package.json b/package.json index 8ab8cd9cc..ca2326419 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "dev:app": "cd templates/skeleton && npm run dev --", "docs:build": "turbo run build-docs", "docs:preview": "turbo run preview-docs", - "lint": "eslint --flag unstable_config_lookup_from_file --no-error-on-unmatched-pattern ./packages", - "lint-staged": "eslint --flag unstable_config_lookup_from_file --no-error-on-unmatched-pattern", + "lint": "eslint --no-error-on-unmatched-pattern ./packages", + "lint-staged": "eslint --no-error-on-unmatched-pattern", "format": "prettier --write --ignore-unknown ./packages", "format:check": "prettier --check --ignore-unknown ./packages", "typecheck": "turbo typecheck --parallel", @@ -62,6 +62,9 @@ "devDependencies": { "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.0", + "@eslint/compat": "^1.2.5", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.18.0", "@playwright/test": "^1.40.1", "@shopify/cli": "~3.73.0", "@types/eslint": "^9.6.1", @@ -71,7 +74,15 @@ "cross-env": "^7.0.3", "eslint": "^9.18.0", "eslint-import-resolver-typescript": "^3.7.0", + "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-import": "^2.31.0", + "eslint-plugin-jest": "^28.11.0", + "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-react": "^7.37.4", + "eslint-plugin-react-hooks": "^5.1.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "eslint-plugin-tsdoc": "^0.4.0", "globals": "^15.14.0", "lint-staged": "^10.5.4", "prettier": "^2.8.4", @@ -92,10 +103,8 @@ "*.{js,jsx}": [ "prettier --write" ], - "packages/**/*.{ts,tsx}": [ - "npm run lint-staged --" - ], "*.{ts,tsx}": [ + "npm run lint-staged --", "prettier --parser=typescript --write" ], "*.html": [ diff --git a/packages/hydrogen-react/eslint.config.cjs b/packages/hydrogen-react/eslint.config.cjs deleted file mode 100644 index 1ed713d8b..000000000 --- a/packages/hydrogen-react/eslint.config.cjs +++ /dev/null @@ -1,272 +0,0 @@ -const {fixupConfigRules, fixupPluginRules} = require('@eslint/compat'); -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 globals = require('globals'); -const tsParser = require('@typescript-eslint/parser'); -const jest = require('eslint-plugin-jest'); -const simpleImportSort = require('eslint-plugin-simple-import-sort'); -const js = require('@eslint/js'); -const {FlatCompat} = require('@eslint/eslintrc'); - -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all, -}); - -module.exports = [ - { - 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/**/*', - ], - }, - ...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', - 'plugin:jsx-a11y/recommended', - ), - ), - { - plugins: { - 'eslint-comments': fixupPluginRules(eslintComments), - react: fixupPluginRules(react), - 'react-hooks': fixupPluginRules(reactHooks), - 'jsx-a11y': fixupPluginRules(jsxA11Y), - tsdoc, - }, - languageOptions: { - parser: tsParser, - parserOptions: { - projectService: { - allowDefaultProject: ['vite.config.ts', 'vitest.setup.ts'], - }, - tsconfigRootDir: __dirname, - ecmaFeatures: { - jsx: true, - }, - }, - globals: { - ...globals.browser, - ...globals.node, - }, - ecmaVersion: 2020, - sourceType: 'module', - }, - linterOptions: { - reportUnusedDisableDirectives: false, - }, - settings: { - react: { - version: 'detect', - }, - jest: { - version: 28, - }, - }, - rules: { - '@shopify/jsx-no-complex-expressions': 'off', - '@shopify/jsx-no-hardcoded-content': 'off', - 'jsx-a11y/control-has-associated-label': 'off', - 'jsx-a11y/label-has-for': 'off', - 'no-use-before-define': 'off', - 'no-warning-comments': 'off', - 'object-shorthand': [ - 'error', - 'always', - { - avoidQuotes: true, - }, - ], - 'react/display-name': 'off', - 'react/no-array-index-key': 'warn', - 'react/prop-types': 'off', - 'react/react-in-jsx-scope': 'off', - 'eslint-comments/no-unused-disable': 'off', - 'jest/no-disabled-tests': 'off', - 'jest/no-export': 'off', - 'no-console': 'off', - 'no-constant-condition': 'off', - 'tsdoc/syntax': 'error', - 'node/no-extraneous-import': [ - 'error', - { - allowModules: ['@shopify/hydrogen', '@shopify/react-testing'], - }, - ], - 'node/no-extraneous-require': [ - 'error', - { - allowModules: ['@shopify/hydrogen'], - }, - ], - 'node/no-unsupported-features/es-syntax': '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: [], - }, - ], - 'prefer-const': [ - 'warn', - { - destructuring: 'all', - }, - ], - '@typescript-eslint/naming-convention': 'off', - 'import/extensions': ['error', 'ignorePackages'], - 'import/no-unresolved': 'off', - 'node/no-missing-import': 'off', - 'react-hooks/exhaustive-deps': 'error', - }, - }, - ...compat.extends('plugin:jest/recommended').map((config) => ({ - ...config, - files: ['**/*.test.*'], - })), - { - files: ['**/*.test.*'], - plugins: { - jest, - }, - languageOptions: { - globals: { - ...globals.node, - ...globals.jest, - }, - }, - }, - { - files: ['**/*.server.*'], - rules: { - 'react-hooks/rules-of-hooks': 'off', - }, - }, - ...fixupConfigRules( - compat.extends( - 'plugin:@typescript-eslint/eslint-recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/recommended-requiring-type-checking', - ), - ).map((config) => ({ - ...config, - files: ['**/*.ts', '**/*.tsx'], - languageOptions: { - parser: tsParser, - parserOptions: { - projectService: { - allowDefaultProject: ['vite.config.ts', 'vitest.setup.ts'], - }, - tsconfigRootDir: __dirname, - ecmaFeatures: { - jsx: true, - }, - }, - }, - })), - { - files: ['**/*.ts', '**/*.tsx'], - languageOptions: { - parser: tsParser, - parserOptions: { - projectService: { - allowDefaultProject: ['vite.config.ts', 'vitest.setup.ts'], - }, - tsconfigRootDir: __dirname, - ecmaFeatures: { - jsx: true, - }, - }, - }, - rules: { - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/prefer-promise-reject-errors': 'off', - '@typescript-eslint/naming-convention': [ - 'error', - { - selector: 'default', - format: ['camelCase', 'PascalCase', 'UPPER_CASE'], - leadingUnderscore: 'allowSingleOrDouble', - trailingUnderscore: 'allowSingleOrDouble', - }, - { - selector: 'typeLike', - format: ['PascalCase'], - }, - { - selector: 'typeParameter', - format: ['PascalCase'], - leadingUnderscore: 'allow', - }, - { - selector: 'interface', - format: ['PascalCase'], - }, - { - selector: 'property', - format: null, - }, - ], - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-empty-interface': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/no-unused-vars': 'off', - 'react/prop-types': 'off', - }, - }, - { - files: ['src/*.example.?(ts|js|tsx|jsx)'], - rules: { - 'node/no-extraneous-import': 'off', - 'node/no-extraneous-require': 'off', - }, - }, - { - files: ['src/index.ts'], - plugins: { - 'simple-import-sort': simpleImportSort, - }, - rules: { - 'simple-import-sort/exports': 'error', - }, - }, - { - files: ['src/**/!(*.test|*.example|*.doc|*.stories).?(ts|js|tsx|jsx)'], - rules: { - '@typescript-eslint/explicit-function-return-type': 'error', - }, - }, -]; diff --git a/packages/hydrogen-react/package.json b/packages/hydrogen-react/package.json index 987a417c8..87adb5a09 100644 --- a/packages/hydrogen-react/package.json +++ b/packages/hydrogen-react/package.json @@ -122,7 +122,6 @@ "copy-storefront-types": "cpy ./src/storefront-api-types.d.ts ./dist/types/ --flat", "format": "prettier --write \"{src,docs}/**/*\" --ignore-unknown", "graphql-types": "graphql-codegen --config codegen.ts && npm run format", - "lint": "eslint --no-error-on-unmatched-pattern src", "test": "vitest run --coverage", "test:watch": "vitest", "typecheck": "run-p typecheck:*", @@ -131,10 +130,6 @@ "preview-docs": "npm run dev --prefix ../../docs/preview" }, "devDependencies": { - "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", - "@eslint/compat": "^1.2.5", - "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "^9.18.0", "@faker-js/faker": "^7.6.0", "@graphql-codegen/add": "^5.0.1", "@graphql-codegen/cli": "^5.0.1", @@ -151,18 +146,6 @@ "@vitejs/plugin-react": "^4.2.1", "@vitest/coverage-v8": "^1.0.4", "cpy-cli": "^4.2.0", - "eslint": "^9.18.0", - "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jest": "^28.11.0", - "eslint-plugin-jsx-a11y": "^6.10.2", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^5.2.3", - "eslint-plugin-react": "^7.37.4", - "eslint-plugin-react-hooks": "^5.1.0", - "eslint-plugin-simple-import-sort": "^12.1.1", - "eslint-plugin-tsdoc": "^0.4.0", - "globals": "^15.14.0", "happy-dom": "8.7.2", "npm-run-all": "^4.1.5", "prettier": "^3.4.2",