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 12 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;
25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"author": "Mike Bifulco <[email protected]>",
"license": "MIT",
"packageManager": "[email protected]",
"engines": {
"node": ">=20.10.0",
"pnpm": ">=9.6.0"
},
"scripts": {
"analyze": "ANALYZE=true next build",
"build": "next build && next-sitemap",
Expand All @@ -14,8 +18,8 @@
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "next start",
"test": "pnpm exec playwright test",
"lint": "next lint",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check"
"lint": "eslint ./src ",
"lint-fix": "eslint ./src --fix"
},
"dependencies": {
"@cloudinary/url-gen": "^1.21.0",
Expand All @@ -33,10 +37,10 @@
"@t3-oss/env-nextjs": "^0.11.1",
"@tailwindcss/typography": "^0.5.15",
"@tanstack/react-query": "^5.59.20",
"@trpc/client": "11.0.0-rc.477",
"@trpc/next": "11.0.0-rc.477",
"@trpc/react-query": "11.0.0-rc.477",
"@trpc/server": "11.0.0-rc.477",
"@trpc/client": "11.0.0-rc.621",
"@trpc/next": "11.0.0-rc.621",
"@trpc/react-query": "11.0.0-rc.621",
"@trpc/server": "11.0.0-rc.621",
"@types/mdx": "^2.0.13",
"@types/semver": "^7.5.8",
"airtable": "^0.12.2",
Expand Down Expand Up @@ -77,9 +81,12 @@
"svix": "^1.39.0",
"swr": "^2.2.5",
"tailwind-merge": "^2.5.4",
"typescript-eslint": "^8.13.0",
"zod": "^3.23.8"
},
"devDependencies": {
"@eslint/compat": "^1.2.2",
"@eslint/js": "^9.14.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@next/eslint-plugin-next": "^14.2.15",
"@playwright/test": "^1.48.2",
Expand All @@ -89,14 +96,14 @@
"@types/react": "^18.3.12",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"eslint": "8.57.0",
"eslint": "9.14.0",
"eslint-config-next": "^14.2.15",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.2.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-hooks": "5.0.0",
"github-slugger": "^2.0.0",
"jiti": "^2.4.0",
"next-sitemap": "^4.2.3",
Expand All @@ -116,7 +123,7 @@
"eslintConfig": {
"root": true,
"extends": [
"./eslint.config.js"
"./eslint.config.mjs"
]
}
}
Loading
Loading