From 60b869435e1503fad384cfffc894b72fbb679883 Mon Sep 17 00:00:00 2001 From: Maciek Sitkowski Date: Sun, 26 Nov 2023 04:18:47 +0100 Subject: [PATCH] fix lint issues --- .gitignore | 2 +- apps/docs/.eslintrc.cjs | 16 ++++++++++++- apps/docs/package.json | 1 + apps/docs/stories/button.stories.tsx | 3 +-- apps/docs/tailwind.config.ts | 2 +- apps/docs/tsconfig.json | 15 +++++++++++- libs/tailwind-config/.eslintrc.js | 4 ++++ libs/tailwind-config/package.json | 1 + libs/tailwind-config/tailwind.config.ts | 3 +-- libs/ui/.eslintrc.js | 5 ++-- libs/ui/package.json | 7 +++--- libs/ui/tailwind.config.ts | 2 +- package.json | 5 ++-- pnpm-lock.yaml | 31 +++++++++++++++++++++++++ 14 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 libs/tailwind-config/.eslintrc.js diff --git a/.gitignore b/.gitignore index 9782849..b7f5e56 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,6 @@ lerna-debug.log* # Misc .cache - +tsconfig.tsbuildinfo diff --git a/apps/docs/.eslintrc.cjs b/apps/docs/.eslintrc.cjs index 61ea173..ce42dfb 100644 --- a/apps/docs/.eslintrc.cjs +++ b/apps/docs/.eslintrc.cjs @@ -1,4 +1,18 @@ /** @type {import("eslint").Linter.Config} */ module.exports = { - // extends: ["@repo/eslint-config/storybook.js"], + extends: [ + '@repo/eslint-config/base', + '@repo/eslint-config/react', + 'plugin:storybook/recommended', + ], + overrides: [ + { + files: ['*.stories.tsx'], + rules: { + // For some reason it shows errors for imports from @repo/ui, even though they are resolved correctly. + // Both develop and build work fine, so I'm disabling it for now. + 'import/no-unresolved': 'off', + }, + }, + ], } diff --git a/apps/docs/package.json b/apps/docs/package.json index 37d9d37..6f5e791 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -29,6 +29,7 @@ "@storybook/theming": "^7.5.3", "@vitejs/plugin-react": "^4.2.0", "eslint": "^8.54.0", + "eslint-plugin-storybook": "^0.6.15", "postcss": "^8.4.31", "serve": "^14.2.1", "storybook": "^7.5.3", diff --git a/apps/docs/stories/button.stories.tsx b/apps/docs/stories/button.stories.tsx index 6853c85..e710fd3 100644 --- a/apps/docs/stories/button.stories.tsx +++ b/apps/docs/stories/button.stories.tsx @@ -1,5 +1,5 @@ -import type { Meta, StoryObj } from '@storybook/react' import { Button } from '@repo/ui' +import type { Meta, StoryObj } from '@storybook/react' const meta: Meta = { component: Button, @@ -9,7 +9,6 @@ const meta: Meta = { options: ['button', 'submit', 'reset'], }, }, - } export default meta diff --git a/apps/docs/tailwind.config.ts b/apps/docs/tailwind.config.ts index 5cc0217..c622c6d 100644 --- a/apps/docs/tailwind.config.ts +++ b/apps/docs/tailwind.config.ts @@ -1,5 +1,5 @@ -import type { Config } from 'tailwindcss' import sharedConfig from '@repo/tailwind-config/tailwind.config' +import type { Config } from 'tailwindcss' const config: Pick = { presets: [sharedConfig], diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json index 1fdb38f..8aa7634 100644 --- a/apps/docs/tsconfig.json +++ b/apps/docs/tsconfig.json @@ -1,5 +1,18 @@ { - "extends": "@repo/tsconfig/react-app.json", + "extends": "../../tsconfig.json", + "compilerOptions": { + "allowJs": true, + "declaration": false, + "declarationMap": false, + "incremental": true, + "jsx": "preserve", + "lib": ["dom", "dom.iterable", "esnext"], + "module": "esnext", + "noEmit": true, + "resolveJsonModule": true, + "target": "es5", + "skipLibCheck": true + }, "include": ["."], "exclude": ["dist", "build", "node_modules"] } diff --git a/libs/tailwind-config/.eslintrc.js b/libs/tailwind-config/.eslintrc.js new file mode 100644 index 0000000..d5ff108 --- /dev/null +++ b/libs/tailwind-config/.eslintrc.js @@ -0,0 +1,4 @@ +/** @type {import('eslint').Linter.Config} */ +module.exports = { + extends: ['@repo/eslint-config/base'], +} diff --git a/libs/tailwind-config/package.json b/libs/tailwind-config/package.json index 2cce6e5..ef2dec7 100644 --- a/libs/tailwind-config/package.json +++ b/libs/tailwind-config/package.json @@ -3,6 +3,7 @@ "main": "index.ts", "types": "index.ts", "devDependencies": { + "@repo/eslint-config": "workspace:^", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "tailwindcss": "^3.3.5" diff --git a/libs/tailwind-config/tailwind.config.ts b/libs/tailwind-config/tailwind.config.ts index b7f15d3..7521613 100644 --- a/libs/tailwind-config/tailwind.config.ts +++ b/libs/tailwind-config/tailwind.config.ts @@ -1,7 +1,6 @@ -import typographyPlugin from '@tailwindcss/typography' import formsPlugin from '@tailwindcss/forms' +import typographyPlugin from '@tailwindcss/typography' import type { Config } from 'tailwindcss' - import tailwindColors from 'tailwindcss/colors' export default { diff --git a/libs/ui/.eslintrc.js b/libs/ui/.eslintrc.js index 1ea0caa..67d09da 100644 --- a/libs/ui/.eslintrc.js +++ b/libs/ui/.eslintrc.js @@ -1,3 +1,4 @@ +/** @type {import('eslint').Linter.Config} */ module.exports = { - extends: ["custom/react"], -}; + extends: ['@repo/eslint-config/base', '@repo/eslint-config/react'], +} diff --git a/libs/ui/package.json b/libs/ui/package.json index 1576be3..b3e28b7 100644 --- a/libs/ui/package.json +++ b/libs/ui/package.json @@ -23,10 +23,8 @@ "develop": "tsup --watch", "check-types": "tsc --noEmit" }, - "peerDependencies": { - "react": "^18.2.0" - }, "devDependencies": { + "@repo/eslint-config": "workspace:^", "@repo/tailwind-config": "workspace:^", "@repo/tsconfig": "workspace:^", "@types/react": "^18.2.5", @@ -36,5 +34,8 @@ "tailwindcss": "^3.3.5", "tsup": "^6.0.1", "typescript": "^5.3.2" + }, + "peerDependencies": { + "react": "^18.2.0" } } diff --git a/libs/ui/tailwind.config.ts b/libs/ui/tailwind.config.ts index 7242efe..b65b29a 100644 --- a/libs/ui/tailwind.config.ts +++ b/libs/ui/tailwind.config.ts @@ -1,5 +1,5 @@ -import type { Config } from 'tailwindcss' import sharedConfig from '@repo/tailwind-config/tailwind.config.ts' +import type { Config } from 'tailwindcss' const config: Pick = { presets: [sharedConfig], diff --git a/package.json b/package.json index 6c17205..0aa36b8 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "develop:ui": "pnpm -F ui develop", "develop": "pnpm -r develop", "format": "prettier --write .", - "lint:fix": "pnpm lint -fix", + "lint:fix": "pnpm lint --fix", "lint": "eslint --ext .ts,.tsx ./apps ./libs", "start:docs": "pnpm -F docs start", "start:nestjs": "pnpm -F nestjs start", @@ -47,5 +47,6 @@ "engines": { "node": ">=20", "pnpm": "8" - } + }, + "packageManager": "pnpm@8.10.5" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7c2ef1c..dcb558a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -117,6 +117,9 @@ importers: eslint: specifier: ^8.54.0 version: 8.54.0 + eslint-plugin-storybook: + specifier: ^0.6.15 + version: 0.6.15(eslint@8.54.0)(typescript@5.3.2) postcss: specifier: ^8.4.31 version: 8.4.31 @@ -286,6 +289,9 @@ importers: libs/tailwind-config: devDependencies: + '@repo/eslint-config': + specifier: workspace:^ + version: link:../eslint-config '@tailwindcss/forms': specifier: ^0.5.7 version: 0.5.7(tailwindcss@3.3.5) @@ -309,6 +315,9 @@ importers: libs/ui: devDependencies: + '@repo/eslint-config': + specifier: workspace:^ + version: link:../eslint-config '@repo/tailwind-config': specifier: workspace:^ version: link:../tailwind-config @@ -4530,6 +4539,12 @@ packages: - supports-color dev: true + /@storybook/csf@0.0.1: + resolution: {integrity: sha512-USTLkZze5gkel8MYCujSRBVIrUQ3YPBrLOx7GNk/0wttvVtlzWXAq9eLbQ4p/NicGxP+3T7KPEMVV//g+yubpw==} + dependencies: + lodash: 4.17.21 + dev: true + /@storybook/csf@0.1.2: resolution: {integrity: sha512-ePrvE/pS1vsKR9Xr+o+YwdqNgHUyXvg+1Xjx0h9LrVx7Zq4zNe06pd63F5EvzTbCbJsHj7GHr9tkiaqm7U8WRA==} dependencies: @@ -7873,6 +7888,22 @@ packages: string.prototype.matchall: 4.0.10 dev: true + /eslint-plugin-storybook@0.6.15(eslint@8.54.0)(typescript@5.3.2): + resolution: {integrity: sha512-lAGqVAJGob47Griu29KXYowI4G7KwMoJDOkEip8ujikuDLxU+oWJ1l0WL6F2oDO4QiyUFXvtDkEkISMOPzo+7w==} + engines: {node: 12.x || 14.x || >= 16} + peerDependencies: + eslint: '>=6' + dependencies: + '@storybook/csf': 0.0.1 + '@typescript-eslint/utils': 5.62.0(eslint@8.54.0)(typescript@5.3.2) + eslint: 8.54.0 + requireindex: 1.2.0 + ts-dedent: 2.2.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /eslint-plugin-testing-library@5.11.1(eslint@8.54.0)(typescript@5.3.2): resolution: {integrity: sha512-5eX9e1Kc2PqVRed3taaLnAAqPZGEX75C+M/rXzUAI3wIg/ZxzUm1OVAwfe/O+vE+6YXOLetSe9g5GKD2ecXipw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0, npm: '>=6'}