diff --git a/.vscode/settings.json b/.vscode/settings.json index 995a830e67..a02f6abb07 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,8 +4,12 @@ "**/.yarn": true }, "typescript.enablePromptUseWorkspaceTsdk": true, - "editor.formatOnSave": true, - "editor.codeActionsOnSave": ["source.fixAll", "source.organizeImports", "source.sortMembers"], + "editor.formatOnSave": false, + "editor.codeActionsOnSave": [ + "source.fixAll", + "source.organizeImports", + "source.sortMembers", + ], "editor.defaultFormatter": "esbenp.prettier-vscode", "[ignore]": { "editor.defaultFormatter": "foxundermoon.shell-format" diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000..c81393f368 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,171 @@ +import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"; +import { FlatCompat } from "@eslint/eslintrc"; +import js from "@eslint/js"; +import tsParser from "@typescript-eslint/parser"; +import deprecation from "eslint-plugin-deprecation"; +import _import from "eslint-plugin-import"; +import tailwindcss from "eslint-plugin-tailwindcss"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: [ + "**/*.js", + "**/*.jsx", + "**/lib", + "**/build", + "**/dist", + "**/.yarn", + "**/.husky", + "**/generated", + "**/bundle.c?js", + "**/.pnp*", + "**/generated", + ], +}, ...fixupConfigRules(compat.extends( + "prettier", + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/strict", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:vitest/recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:tailwindcss/recommended", + "plugin:@next/next/recommended", +)), { + plugins: { + deprecation, + import: fixupPluginRules(_import), + tailwindcss: fixupPluginRules(tailwindcss), + }, + + languageOptions: { + globals: { + ...globals.browser, + }, + + parser: tsParser, + ecmaVersion: 12, + sourceType: "module", + + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + + project: ["./tsconfig.eslint.json", "./packages/**/tsconfig.json"], + allowAutomaticSingleRunInference: true, + tsconfigRootDir: "/Volumes/git/fern-platform", + }, + }, + + settings: { + react: { + version: "18.3.1", + }, + + next: { + rootDir: "packages/fern-docs/bundle/", + }, + }, + + rules: { + "@typescript-eslint/no-unused-vars": ["error", { + varsIgnorePattern: "^_", + argsIgnorePattern: "^_", + ignoreRestSiblings: true, + }], + + "@typescript-eslint/no-namespace": ["error", { + allowDeclarations: true, + }], + + "@typescript-eslint/explicit-module-boundary-types": ["off"], + "@typescript-eslint/no-floating-promises": ["error"], + + "@typescript-eslint/no-empty-function": ["error", { + allow: ["private-constructors", "protected-constructors", "decoratedFunctions"], + }], + + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-base-to-string": "error", + "@typescript-eslint/no-extraneous-class": "off", + "@typescript-eslint/no-invalid-void-type": "off", + "@typescript-eslint/prefer-optional-chain": "off", + "@typescript-eslint/strict-boolean-expressions": "off", + "linebreak-style": ["error", "unix"], + "no-console": "error", + + "no-empty": ["error", { + allowEmptyCatch: true, + }], + + "no-unused-vars": "off", + "tailwindcss/classnames-order": "off", + + quotes: ["error", "double", { + avoidEscape: true, + }], + + semi: ["error", "always"], + indent: "off", + "object-shorthand": ["error"], + "deprecation/deprecation": "warn", + + eqeqeq: ["error", "always", { + null: "never", + }], + + curly: "error", + "react/react-in-jsx-scope": "off", + "react/prop-types": "off", + "tailwindcss/no-custom-classname": "off", + "@next/next/no-html-link-for-pages": "off", + "@next/next/no-img-element": "off", + + "react-hooks/exhaustive-deps": ["warn", { + additionalHooks: "(useMemoOne|useCallbackOne)", + }], + }, +}, { + files: ["**/*.ts", "**/*.mts", "**/*.cts", "**/*.tsx"], + + rules: { + "@typescript-eslint/explicit-module-boundary-types": ["error", { + allowHigherOrderFunctions: false, + }], + }, +}, { + files: ["packages/fdr-sdk/**/*", "servers/fdr-deploy/**/*", "servers/fdr/**/*"], + + rules: { + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/no-base-to-string": "off", + }, +}, { + files: ["servers/fdr/**/*", "servers/fern-bot/**/*"], + + rules: { + eqeqeq: "off", + "no-console": "off", + }, +}, { + files: ["packages/fern-docs/**/*"], + + rules: { + "@typescript-eslint/no-explicit-any": "off", + }, +}]; \ No newline at end of file diff --git a/package.json b/package.json index ce13abe32f..eb94f0d453 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,9 @@ "@babel/preset-env": "^7.26.0", "@babel/preset-react": "^7.25.9", "@babel/preset-typescript": "^7.26.0", + "@eslint/compat": "^1.2.4", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.17.0", "@next/eslint-plugin-next": "14.2.9", "@playwright/test": "^1.47.1", "@tailwindcss/forms": "^0.5.7", @@ -90,6 +93,7 @@ "eslint-plugin-vitest": "^0.5.4", "execa": "^5.1.1", "express": "^4.20.0", + "globals": "^15.14.0", "http-proxy-middleware": "^3.0.3", "husky": "^8.0.1", "immer": "^9.0.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index beca8c6f7a..f20418e78b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,15 @@ importers: '@babel/preset-typescript': specifier: ^7.26.0 version: 7.26.0(@babel/core@7.26.0) + '@eslint/compat': + specifier: ^1.2.4 + version: 1.2.4(eslint@9.17.0(jiti@1.21.7)) + '@eslint/eslintrc': + specifier: ^3.2.0 + version: 3.2.0 + '@eslint/js': + specifier: ^9.17.0 + version: 9.17.0 '@next/eslint-plugin-next': specifier: 14.2.9 version: 14.2.9 @@ -112,7 +121,7 @@ importers: version: 3.0.0(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) eslint-plugin-import: specifier: ^2.31.0 - version: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)) + version: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-react: specifier: ^7.37.2 version: 7.37.2(eslint@9.17.0(jiti@1.21.7)) @@ -131,6 +140,9 @@ importers: express: specifier: ^4.20.0 version: 4.21.1 + globals: + specifier: ^15.14.0 + version: 15.14.0 http-proxy-middleware: specifier: ^3.0.3 version: 3.0.3 @@ -596,7 +608,7 @@ importers: version: 3.0.0(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) eslint-plugin-import: specifier: ^2.31.0 - version: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)) + version: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-react: specifier: ^7.37.2 version: 7.37.2(eslint@9.17.0(jiti@1.21.7)) @@ -4425,6 +4437,15 @@ packages: resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint/compat@1.2.4': + resolution: {integrity: sha512-S8ZdQj/N69YAtuqFt7653jwcvuUj131+6qGLUyDqfDg1OIoBQ66OCuXC473YQfO2AaxITTutiRQiDwoo7ZLYyg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: 9.17.0 + peerDependenciesMeta: + eslint: + optional: true + '@eslint/config-array@0.19.1': resolution: {integrity: sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -10504,6 +10525,10 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} + globals@15.14.0: + resolution: {integrity: sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==} + engines: {node: '>=18'} + globalthis@1.0.4: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} @@ -18106,6 +18131,10 @@ snapshots: '@eslint-community/regexpp@4.12.1': {} + '@eslint/compat@1.2.4(eslint@9.17.0(jiti@1.21.7))': + optionalDependencies: + eslint: 9.17.0(jiti@1.21.7) + '@eslint/config-array@0.19.1': dependencies: '@eslint/object-schema': 2.1.5 @@ -18795,7 +18824,7 @@ snapshots: '@kwsites/file-exists@1.1.1': dependencies: - debug: 4.3.4(supports-color@5.5.0) + debug: 4.3.7 transitivePeerDependencies: - supports-color @@ -25524,7 +25553,7 @@ snapshots: '@typescript-eslint/parser': 8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) eslint: 9.17.0(jiti@1.21.7) eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-jsx-a11y: 6.8.0(eslint@9.17.0(jiti@1.21.7)) eslint-plugin-react: 7.37.2(eslint@9.17.0(jiti@1.21.7)) @@ -25547,23 +25576,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)): - dependencies: - debug: 4.3.7 - enhanced-resolve: 5.16.1 - eslint: 9.17.0(jiti@1.21.7) - eslint-module-utils: 2.8.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)) - eslint-plugin-import: 2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.17.0(jiti@1.21.7)) - fast-glob: 3.3.2 - get-tsconfig: 4.7.5 - is-core-module: 2.13.1 - is-glob: 4.0.3 - transitivePeerDependencies: - - '@typescript-eslint/parser' - - eslint-import-resolver-node - - eslint-import-resolver-webpack - - supports-color - eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.17.0(jiti@1.21.7)): dependencies: debug: 4.3.7 @@ -25580,18 +25592,6 @@ snapshots: - eslint-import-resolver-node - eslint-import-resolver-webpack - supports-color - optional: true - - eslint-module-utils@2.12.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)): - dependencies: - debug: 3.2.7 - optionalDependencies: - '@typescript-eslint/parser': 8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) - eslint: 9.17.0(jiti@1.21.7) - eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)) - transitivePeerDependencies: - - supports-color eslint-module-utils@2.12.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)): dependencies: @@ -25604,17 +25604,6 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)): - dependencies: - debug: 3.2.7 - optionalDependencies: - '@typescript-eslint/parser': 8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) - eslint: 9.17.0(jiti@1.21.7) - eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)) - transitivePeerDependencies: - - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)): dependencies: debug: 3.2.7 @@ -25625,7 +25614,6 @@ snapshots: eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0)(eslint@9.17.0(jiti@1.21.7)) transitivePeerDependencies: - supports-color - optional: true eslint-plugin-deprecation@3.0.0(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2): dependencies: @@ -25638,35 +25626,6 @@ snapshots: - supports-color eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-typescript@3.6.1)(eslint@9.17.0(jiti@1.21.7)): - dependencies: - '@rtsao/scc': 1.1.0 - array-includes: 3.1.8 - array.prototype.findlastindex: 1.2.5 - array.prototype.flat: 1.3.2 - array.prototype.flatmap: 1.3.2 - debug: 3.2.7 - doctrine: 2.1.0 - eslint: 9.17.0(jiti@1.21.7) - eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)))(eslint@9.17.0(jiti@1.21.7)) - hasown: 2.0.2 - is-core-module: 2.16.0 - is-glob: 4.0.3 - minimatch: 3.1.2 - object.fromentries: 2.0.8 - object.groupby: 1.0.3 - object.values: 1.2.0 - semver: 6.3.1 - string.prototype.trimend: 1.0.8 - tsconfig-paths: 3.15.0 - optionalDependencies: - '@typescript-eslint/parser': 8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2) - transitivePeerDependencies: - - eslint-import-resolver-typescript - - eslint-import-resolver-webpack - - supports-color - - eslint-plugin-import@2.31.0(@typescript-eslint/parser@8.18.1(eslint@9.17.0(jiti@1.21.7))(typescript@5.7.2))(eslint@9.17.0(jiti@1.21.7)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.8 @@ -26551,6 +26510,8 @@ snapshots: globals@14.0.0: {} + globals@15.14.0: {} + globalthis@1.0.4: dependencies: define-properties: 1.2.1 diff --git a/turbo.json b/turbo.json index 7a47bf21dc..eb6a37ada0 100644 --- a/turbo.json +++ b/turbo.json @@ -43,5 +43,5 @@ "dependsOn": ["^build", "^compile"] } }, - "globalDependencies": [".eslintrc.js", ".prettierrc.json"] + "globalDependencies": ["eslint.config.mjs", ".prettierrc.json"] }