From 0b501e95a55b68e307474f115b6ee2e0adcf61e8 Mon Sep 17 00:00:00 2001 From: Marco Pasqualetti <24919330+marcalexiei@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:40:58 +0100 Subject: [PATCH] chore(apps/documentation): migrate to eslint 9 (#188) --- apps/documentation/.eslintrc | 106 ------------------ apps/documentation/package.json | 3 +- .../{postcss.config.cjs => postcss.config.js} | 2 +- .../mdx-provider/mdx-code/mdx-code.tsx | 3 +- .../mdx-provider/mdx-pre/mdx-pre.tsx | 9 +- .../components/mdx-provider/mdx-provider.tsx | 3 +- .../mdx-provider/mdx-title/mdx-title.tsx | 1 + .../table-of-content/table-of-content.tsx | 1 + apps/documentation/src/modules.d.ts | 5 +- apps/documentation/src/routes/__root.tsx | 4 +- apps/documentation/tsconfig.json | 43 ++++--- eslint.config.js | 9 ++ 12 files changed, 56 insertions(+), 133 deletions(-) delete mode 100644 apps/documentation/.eslintrc rename apps/documentation/{postcss.config.cjs => postcss.config.js} (94%) diff --git a/apps/documentation/.eslintrc b/apps/documentation/.eslintrc deleted file mode 100644 index 6cbaf5ca..00000000 --- a/apps/documentation/.eslintrc +++ /dev/null @@ -1,106 +0,0 @@ -{ - "root": true, - "reportUnusedDisableDirectives": true, - "ignorePatterns": ["**/build", "**/dist"], - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "import"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/stylistic", - "plugin:import/recommended", - "plugin:import/typescript", - "prettier", - ], - "env": { - "browser": true, - "es2020": true, - }, - "parserOptions": { - "tsconfigRootDir": ".", - "project": true, - "sourceType": "module", - "ecmaVersion": 2020, - }, - "settings": { - "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx"], - }, - "import/resolver": { - "typescript": true, - }, - "react": { - "version": "detect", - }, - }, - "rules": { - "@typescript-eslint/array-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/ban-ts-comment": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/consistent-type-imports": [ - "error", - { "prefer": "type-imports" }, - ], - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/method-signature-style": ["error", "property"], - "@typescript-eslint/naming-convention": [ - "error", - { - "selector": "typeParameter", - "format": ["PascalCase"], - "leadingUnderscore": "forbid", - "trailingUnderscore": "forbid", - "custom": { - "regex": "^(T|T[A-Z][A-Za-z]+)$", - "match": true, - }, - }, - ], - "@typescript-eslint/no-deprecated": "error", - "@typescript-eslint/no-empty-function": "error", - "@typescript-eslint/no-empty-interface": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-non-null-assertion": "error", - "@typescript-eslint/no-unnecessary-condition": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/explicit-function-return-type": "error", - "@typescript-eslint/no-inferrable-types": [ - "error", - { "ignoreParameters": true }, - ], - "import/default": "error", - "import/export": "error", - "import/namespace": "error", - "import/newline-after-import": "error", - "import/no-cycle": "error", - "import/no-duplicates": "off", - "import/no-named-as-default-member": "error", - "import/no-unused-modules": "error", - "import/order": [ - "off", - { - "groups": [ - "builtin", - "external", - "internal", - "parent", - "sibling", - "index", - "object", - "type", - ], - }, - ], - "no-case-declarations": "error", - "no-empty": "error", - "no-prototype-builtins": "error", - "no-redeclare": "error", - "no-shadow": "error", - "no-undef": "off", - "sort-imports": "off", - }, -} diff --git a/apps/documentation/package.json b/apps/documentation/package.json index 3abc22bb..c1dc6f20 100644 --- a/apps/documentation/package.json +++ b/apps/documentation/package.json @@ -3,8 +3,9 @@ "description": "The react/rust fullstack framework documentation", "version": "0.0.1", "private": true, + "type": "module", "scripts": { - "lint": "eslint --ext .ts,.tsx ./src -c .eslintrc", + "lint": "eslint .", "format": "prettier -u --write --ignore-unknown './src/**/*'", "format:check": "prettier --check --ignore-unknown './src/**/*'", "types": "tsc --noEmit" diff --git a/apps/documentation/postcss.config.cjs b/apps/documentation/postcss.config.js similarity index 94% rename from apps/documentation/postcss.config.cjs rename to apps/documentation/postcss.config.js index 6a683623..5ada75c1 100644 --- a/apps/documentation/postcss.config.cjs +++ b/apps/documentation/postcss.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { plugins: { 'postcss-preset-mantine': {}, 'postcss-simple-vars': { diff --git a/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx b/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx index 3b0af777..cf7a9525 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-code/mdx-code.tsx @@ -1,6 +1,5 @@ -import type { JSX } from 'react' +import type { JSX, HTMLAttributes } from 'react' import { Code } from '@mantine/core' -import type { HTMLAttributes } from 'react' export default function MdxCode( props: HTMLAttributes, diff --git a/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx b/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx index 6047ea35..17aeabef 100644 --- a/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx +++ b/apps/documentation/src/components/mdx-provider/mdx-pre/mdx-pre.tsx @@ -1,10 +1,17 @@ import type { JSX } from 'react' import { CodeHighlight } from '@mantine/code-highlight' + import styles from './mdx-pre.module.css' interface PreProps { - children: any + children: { + props: { + children: string + className?: string + } + } } + export default function MdxPre({ children }: PreProps): JSX.Element { return ( + export default CSSModule +} diff --git a/apps/documentation/src/routes/__root.tsx b/apps/documentation/src/routes/__root.tsx index 76eb10f2..8a7ef03d 100644 --- a/apps/documentation/src/routes/__root.tsx +++ b/apps/documentation/src/routes/__root.tsx @@ -7,13 +7,13 @@ import { } from '@mantine/core' import { useDisclosure } from '@mantine/hooks' import { Head, useRouter } from 'tuono' + import Navbar from '@/components/navbar' +import Sidebar from '@/components/sidebar' import '@mantine/core/styles.css' import '@mantine/code-highlight/styles.css' -import Sidebar from '@/components/sidebar' - interface RootRouteProps { children: ReactNode } diff --git a/apps/documentation/tsconfig.json b/apps/documentation/tsconfig.json index 0ce21289..e6db9a03 100644 --- a/apps/documentation/tsconfig.json +++ b/apps/documentation/tsconfig.json @@ -1,28 +1,37 @@ { "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2021", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ + // Typechecking "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, + + // Modules + "module": "ESNext", + "moduleResolution": "bundler", + "resolveJsonModule": true, "paths": { "@/*": ["./src/*"] - } + }, + + // Emit + "noEmit": true, + + // JavaScript Support + "allowJs": true, + + // Interop Constraints + "isolatedModules": true, + + // Language and Environment + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2021", "DOM", "DOM.Iterable"], + "jsx": "react-jsx", + + // Completeness + "skipLibCheck": true }, - "include": ["src"], + "include": ["src", "tuono.config.ts", "postcss.config.js"], "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/eslint.config.js b/eslint.config.js index d8f20c23..9f607939 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -9,6 +9,7 @@ export default tseslint.config( // #region shared '**/build', '**/dist', + '**/.tuono', '**/vite.config.ts.timestamp**', // #endregion shared @@ -128,4 +129,12 @@ export default tseslint.config( 'sort-imports': 'off', }, }, + { + files: ['apps/documentation/**'], + settings: { + 'import/resolver': { + typescript: 'apps/documentation/tsconfig.json', + }, + }, + }, )