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

eslint 9 migration? #835

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
51 changes: 0 additions & 51 deletions eslint.config.js

This file was deleted.

104 changes: 104 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/// <reference types="./types.d.ts" />

import * as path from 'node:path';
import { fixupPluginRules, includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import nextPlugin from '@next/eslint-plugin-next';
import prettier from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import turboPlugin from 'eslint-plugin-turbo';
import tseslint from 'typescript-eslint';

export const restrictEnvAccess = tseslint.config(
{ ignores: ['**/env.ts'] },
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
rules: {
'no-restricted-properties': [
'error',
{
object: 'process',
property: 'env',
message:
"Use `import { env } from '~/env'` instead to ensure validated types.",
},
],
'no-restricted-imports': [
'error',
{
name: 'process',
importNames: ['env'],
message:
"Use `import { env } from '~/env'` instead to ensure validated types.",
},
],
},
}
);

/** @type {import("eslint").Linter.Config[]} */
const config = tseslint.config(
includeIgnoreFile(path.join(import.meta.dirname, './.gitignore')),
{ ignores: ['**/*.config.*'] },
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
plugins: {
import: importPlugin,
turbo: turboPlugin,
react: reactPlugin,
'react-hooks': fixupPluginRules(reactHooksPlugin),
'@next/next': nextPlugin,
'jsx-a11y': jsxA11yPlugin,
},
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
rules: {
...prettier.rules,
...reactPlugin.configs['jsx-runtime'].rules,
...reactHooksPlugin.configs.recommended.rules,
// ...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
'@typescript-eslint/no-unnecessary-condition': [
'error',
{
allowConstantLoopConditions: true,
},
],
'@typescript-eslint/no-non-null-assertion': 'error',
// TypeError: context.getAncestors is not a function
'@next/next/no-duplicate-head': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/consistent-type-imports': [
'warn',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
],
'@typescript-eslint/no-misused-promises': [
2,
{ checksVoidReturn: { attributes: false } },
],
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
},
},
{
linterOptions: { reportUnusedDisableDirectives: true },
languageOptions: {
parserOptions: { projectService: true },
globals: {
React: 'writable',
},
},
}
);

export default config;
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "next start",
"test": "pnpm exec playwright test",
"lint": "next lint",
"lint": "eslint ./src ",
"lint-fix": "eslint ./src --fix",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check"
},
"dependencies": {
"@cloudinary/url-gen": "^1.20.0",
"@emotion/react": "^11.13.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.9.0",
"@headlessui/react": "^2.1.2",
"@heroicons/react": "^2.1.5",
"@mdx-js/loader": "^3.0.1",
Expand All @@ -32,7 +35,7 @@
"@t3-oss/env-core": "^0.11.0",
"@t3-oss/env-nextjs": "^0.11.0",
"@tailwindcss/typography": "^0.5.14",
"@tanstack/react-query": "^5.51.23",
"@tanstack/react-query": "^5.52.0",
"@trpc/client": "11.0.0-rc.477",
"@trpc/next": "11.0.0-rc.477",
"@trpc/react-query": "11.0.0-rc.477",
Expand All @@ -45,24 +48,24 @@
"date-fns": "^3.6.0",
"fathom-client": "^3.7.2",
"feed": "^4.2.2",
"framer-motion": "^11.3.28",
"framer-motion": "^11.3.29",
"gray-matter": "^4.0.3",
"micro": "^10.0.1",
"next": "^14.2.5",
"next-cloudinary": "^6.10.0",
"next-mdx-remote": "5.0.0",
"pluralize": "^8.0.0",
"postcss": "^8.4.41",
"posthog-js": "^1.155.4",
"posthog-node": "^4.1.0",
"posthog-js": "^1.157.2",
"posthog-node": "^4.1.1",
"prism-react-renderer": "^2.3.1",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-aria": "^3.34.1",
"react-aria": "^3.34.3",
"react-dom": "^18.3.1",
"react-email": "2.1.6",
"react-icons": "^5.3.0",
"react-stately": "^3.32.1",
"react-stately": "^3.32.2",
"rehype-autolink-headings": "^7.1.0",
"rehype-img-size": "^1.0.1",
"rehype-slug": "^6.0.0",
Expand All @@ -75,26 +78,27 @@
"svix": "^1.30.0",
"swr": "^2.2.5",
"tailwind-merge": "^2.5.2",
"typescript-eslint": "^8.2.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@next/eslint-plugin-next": "^14.2.5",
"@playwright/test": "^1.46.1",
"@types/eslint": "^9.6.0",
"@types/node": "^22.4.0",
"@types/node": "^22.4.2",
"@types/pluralize": "^0.0.33",
"@types/react": "^18.3.3",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"eslint": "8.57.0",
"@types/react": "^18.3.4",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"eslint": "9.9.0",
"eslint-config-next": "^14.2.5",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.14",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-hooks": "rc",
"github-slugger": "^2.0.0",
"jiti": "^1.21.6",
"next-sitemap": "^4.2.3",
Expand All @@ -114,7 +118,7 @@
"eslintConfig": {
"root": true,
"extends": [
"./eslint.config.js"
"./eslint.config.mjs"
]
}
}
Loading