From 65514cdd3905aa831df559d9ba9e4dddad361d2f Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:13:58 +0530 Subject: [PATCH] chore: update config, format and cleanup (#46) Co-authored-by: Anna --- .eslintignore | 15 ++ .eslintrc.cjs | 46 ++++++ .eslintrc.json | 21 --- .prettierignore | 1 - .prettierrc | 22 +-- astro.config.mjs | 19 +-- package.json | 20 ++- pnpm-lock.yaml | 147 +++++++++++++++++- src/components/FCCThemeProvider.astro | 6 +- src/components/FCCThemeSelect.astro | 4 - src/content/config.ts | 2 +- src/content/docs/codebase-best-practices.md | 2 +- src/content/docs/curriculum-help.md | 2 +- .../docs/how-to-add-playwright-tests.md | 6 +- .../docs/how-to-enable-new-languages.md | 18 +-- .../docs/how-to-work-on-coding-challenges.md | 4 +- src/content/docs/index.mdx | 8 +- src/sidebar.ts | 98 ++++++------ 18 files changed, 305 insertions(+), 136 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.cjs delete mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..6d3c040b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,15 @@ +# Deep Directories +**/node_modules + +# Generated Directories +**/dist +**/.astro +**/__coverage__ + +# Directories +.changeset + +# Files +pnpm-lock.yaml +pre-commit +.prettierignore diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..9ac6630d --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,46 @@ +module.exports = { + env: { + browser: true, + es2022: true, + node: true + }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:astro/recommended', + 'prettier' + ], + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module' + }, + rules: {}, + plugins: ['@typescript-eslint'], + overrides: [ + { + env: { + node: true + }, + files: ['.eslintrc.{js,cjs}'], + parserOptions: { + sourceType: 'script' + } + }, + { + files: ['*.astro'], + parser: 'astro-eslint-parser', + processor: 'astro/client-side-ts', + parserOptions: { + parser: '@typescript-eslint/parser', + extraFileExtensions: ['.astro'] + }, + rules: {} + }, + { + files: ['*.d.ts'], + rules: { + '@typescript-eslint/triple-slash-reference': 'off' + } + } + ] +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index e51ac217..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "root": true, - "extends": ["plugin:astro/recommended"], - "overrides": [ - { - // Define the configuration for `.astro` file. - "files": ["*.astro"], - // Allows Astro components to be parsed. - "processor": "astro/client-side-ts", - "parserOptions": { - "parser": "@typescript-eslint/parser", - "extraFileExtensions": [".astro"] - }, - "rules": { - // override/add rules settings here, such as: - // "astro/no-set-html-directive": "error" - } - } - // ... - ] -} diff --git a/.prettierignore b/.prettierignore index c45c8c29..6d3c040b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,4 +13,3 @@ pnpm-lock.yaml pre-commit .prettierignore - diff --git a/.prettierrc b/.prettierrc index c50b2929..2c652fea 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,23 +1,9 @@ { - "printWidth": 100, + "endOfLine": "lf", "semi": true, "singleQuote": true, + "jsxSingleQuote": true, "tabWidth": 2, - "trailingComma": "es5", - "useTabs": false, - "plugins": ["prettier-plugin-astro"], - "overrides": [ - { - "files": [".*", "*.json", "*.md"], - "options": { - "useTabs": false - } - }, - { - "files": ["*.md", "*.mdx"], - "options": { - "printWidth": 80 - } - } - ] + "trailingComma": "none", + "arrowParens": "avoid" } diff --git a/astro.config.mjs b/astro.config.mjs index 2e91d7a9..34f59ac7 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -12,32 +12,33 @@ export default defineConfig({ description: 'Contribute to freeCodeCamp.org', logo: { src: './public/icons/icon-96x96.png', - replacesTitle: true, + replacesTitle: true }, tableOfContents: true, defaultLocale: 'en', editLink: { - baseUrl: 'https://github.com/freeCodeCamp/contribute/edit/main/', + baseUrl: 'https://github.com/freeCodeCamp/contribute/edit/main/' }, social: { github: 'https://github.com/freeCodeCamp', twitter: 'https://twitter.com/freeCodeCamp', - discord: 'https://discord.com/invite/freecodecamp-org-official-fi-fo-692816967895220344', + discord: + 'https://discord.com/invite/freecodecamp-org-official-fi-fo-692816967895220344' }, sidebar: sidebar, components: { // Override the default `SocialIcons` component. Header: './src/components/FCCHeader.astro', - ThemeProvider: './src/components/FCCThemeProvider.astro', + ThemeProvider: './src/components/FCCThemeProvider.astro' }, customCss: [ // Relative path to your custom CSS file - './src/styles/theme.css', - ], - }), + './src/styles/theme.css' + ] + }) ], output: 'hybrid', adapter: cloudflare({ - imageService: 'passthrough', - }), + imageService: 'passthrough' + }) }); diff --git a/package.json b/package.json index faf80ae7..22edad6a 100644 --- a/package.json +++ b/package.json @@ -3,17 +3,21 @@ "type": "module", "version": "1.0.0", "scripts": { - "dev": "astro dev", + "preinstall": "npx only-allow pnpm", + "prepare": "is-ci || husky", + "dev": "pnpm run develop", + "develop": "astro dev", "start": "astro dev", "build": "astro check && astro build", "preview": "wrangler pages dev ./dist", "astro": "astro", - "format": "prettier -w --cache --plugin prettier-plugin-astro .", - "prepare": "husky", - "lint": "eslint --cache --max-warnings 0 ." + "format": "prettier . --write --cache && eslint . --cache --fix", + "lint": "prettier . --check --cache && eslint . --cache" }, "lint-staged": { - "*": "prettier -w --cache --plugin prettier-plugin-astro ." + "**/*.{astro, mjs,cjs,js,jsx,ts,tsx,yaml,yml}": [ + "pnpm format" + ] }, "dependencies": { "@astrojs/check": "^0.5.10", @@ -23,10 +27,14 @@ "typescript": "^5.4.3" }, "devDependencies": { - "@typescript-eslint/parser": "^7.4.0", + "@typescript-eslint/eslint-plugin": "^7.5.0", + "@typescript-eslint/parser": "^7.5.0", "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", "eslint-plugin-astro": "^0.33.1", + "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.11", + "is-ci": "^3.0.1", "lint-staged": "^15.2.2", "prettier": "^3.2.5", "prettier-plugin-astro": "^0.13.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8beeb2e2..96d50bad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,18 +22,30 @@ dependencies: version: 5.4.3 devDependencies: + '@typescript-eslint/eslint-plugin': + specifier: ^7.5.0 + version: 7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.3) '@typescript-eslint/parser': - specifier: ^7.4.0 + specifier: ^7.5.0 version: 7.5.0(eslint@8.57.0)(typescript@5.4.3) eslint: specifier: ^8.57.0 version: 8.57.0 + eslint-config-prettier: + specifier: ^9.1.0 + version: 9.1.0(eslint@8.57.0) eslint-plugin-astro: specifier: ^0.33.1 version: 0.33.1(eslint@8.57.0) + eslint-plugin-prettier: + specifier: ^5.1.3 + version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) husky: specifier: ^9.0.11 version: 9.0.11 + is-ci: + specifier: ^3.0.1 + version: 3.0.1 lint-staged: specifier: ^15.2.2 version: 15.2.2 @@ -1684,6 +1696,10 @@ packages: '@types/unist': 3.0.2 dev: false + /@types/json-schema@7.0.15: + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + dev: true + /@types/mdast@4.0.3: resolution: {integrity: sha512-LsjtqsyF+d2/yFOYaN22dHZI1Cpwkrj+g06G8+qtUKlhovPW89YhqSnfKtMbkgmEtYpH2gydRNULd6y8mciAFg==} dependencies: @@ -1730,6 +1746,10 @@ packages: '@types/node': 17.0.45 dev: false + /@types/semver@7.5.8: + resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + dev: true + /@types/unist@2.0.10: resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} dev: false @@ -1738,6 +1758,35 @@ packages: resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} dev: false + /@typescript-eslint/eslint-plugin@7.5.0(@typescript-eslint/parser@7.5.0)(eslint@8.57.0)(typescript@5.4.3): + resolution: {integrity: sha512-HpqNTH8Du34nLxbKgVMGljZMG0rJd2O9ecvr2QLYp+7512ty1j42KnsFwspPXg1Vh8an9YImf6CokUBltisZFQ==} + engines: {node: ^18.18.0 || >=20.0.0} + peerDependencies: + '@typescript-eslint/parser': ^7.0.0 + eslint: ^8.56.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@eslint-community/regexpp': 4.10.0 + '@typescript-eslint/parser': 7.5.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/scope-manager': 7.5.0 + '@typescript-eslint/type-utils': 7.5.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.3) + '@typescript-eslint/visitor-keys': 7.5.0 + debug: 4.3.4 + eslint: 8.57.0 + graphemer: 1.4.0 + ignore: 5.3.1 + natural-compare: 1.4.0 + semver: 7.6.0 + ts-api-utils: 1.3.0(typescript@5.4.3) + typescript: 5.4.3 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/parser@7.5.0(eslint@8.57.0)(typescript@5.4.3): resolution: {integrity: sha512-cj+XGhNujfD2/wzR1tabNsidnYRaFfEkcULdcIyVBYcXjBvBKOes+mpMBP7hMpOyk+gBcfXsrg4NBGAStQyxjQ==} engines: {node: ^18.18.0 || >=20.0.0} @@ -1775,6 +1824,26 @@ packages: '@typescript-eslint/visitor-keys': 7.5.0 dev: true + /@typescript-eslint/type-utils@7.5.0(eslint@8.57.0)(typescript@5.4.3): + resolution: {integrity: sha512-A021Rj33+G8mx2Dqh0nMO9GyjjIBK3MqgVgZ2qlKf6CJy51wY/lkkFqq3TqqnH34XyAHUkq27IjlUkWlQRpLHw==} + engines: {node: ^18.18.0 || >=20.0.0} + peerDependencies: + eslint: ^8.56.0 + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.3) + '@typescript-eslint/utils': 7.5.0(eslint@8.57.0)(typescript@5.4.3) + debug: 4.3.4 + eslint: 8.57.0 + ts-api-utils: 1.3.0(typescript@5.4.3) + typescript: 5.4.3 + transitivePeerDependencies: + - supports-color + dev: true + /@typescript-eslint/types@5.62.0: resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1807,6 +1876,25 @@ packages: - supports-color dev: true + /@typescript-eslint/utils@7.5.0(eslint@8.57.0)(typescript@5.4.3): + resolution: {integrity: sha512-3vZl9u0R+/FLQcpy2EHyRGNqAS/ofJ3Ji8aebilfJe+fobK8+LbIFmrHciLVDxjDoONmufDcnVSF38KwMEOjzw==} + engines: {node: ^18.18.0 || >=20.0.0} + peerDependencies: + eslint: ^8.56.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) + '@types/json-schema': 7.0.15 + '@types/semver': 7.5.8 + '@typescript-eslint/scope-manager': 7.5.0 + '@typescript-eslint/types': 7.5.0 + '@typescript-eslint/typescript-estree': 7.5.0(typescript@5.4.3) + eslint: 8.57.0 + semver: 7.6.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /@typescript-eslint/visitor-keys@5.62.0: resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2383,7 +2471,6 @@ packages: /ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} - dev: false /ci-info@4.0.0: resolution: {integrity: sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==} @@ -2792,6 +2879,15 @@ packages: semver: 7.6.0 dev: true + /eslint-config-prettier@9.1.0(eslint@8.57.0): + resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==} + hasBin: true + peerDependencies: + eslint: '>=7.0.0' + dependencies: + eslint: 8.57.0 + dev: true + /eslint-plugin-astro@0.33.1(eslint@8.57.0): resolution: {integrity: sha512-wVyxAf8Ulmljv5qJQLgspWe17LR4hLXcksIENtUlEC3W7rleBVEKXS+hIqzBfCbpkBLZpl1tsYes1AGpYHd13w==} engines: {node: ^14.18.0 || >=16.0.0} @@ -2811,6 +2907,27 @@ packages: - supports-color dev: true + /eslint-plugin-prettier@5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5): + resolution: {integrity: sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + '@types/eslint': '>=8.0.0' + eslint: '>=8.0.0' + eslint-config-prettier: '*' + prettier: '>=3.0.0' + peerDependenciesMeta: + '@types/eslint': + optional: true + eslint-config-prettier: + optional: true + dependencies: + eslint: 8.57.0 + eslint-config-prettier: 9.1.0(eslint@8.57.0) + prettier: 3.2.5 + prettier-linter-helpers: 1.0.0 + synckit: 0.8.8 + dev: true + /eslint-scope@7.2.2: resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -3006,6 +3123,10 @@ packages: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true + /fast-diff@1.3.0: + resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} + dev: true + /fast-fifo@1.3.2: resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==} requiresBuild: true @@ -3608,6 +3729,13 @@ packages: engines: {node: '>=4'} dev: false + /is-ci@3.0.1: + resolution: {integrity: sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==} + hasBin: true + dependencies: + ci-info: 3.9.0 + dev: true + /is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: @@ -4958,6 +5086,13 @@ packages: engines: {node: '>= 0.8.0'} dev: true + /prettier-linter-helpers@1.0.0: + resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} + engines: {node: '>=6.0.0'} + dependencies: + fast-diff: 1.3.0 + dev: true + /prettier-plugin-astro@0.13.0: resolution: {integrity: sha512-5HrJNnPmZqTUNoA97zn4gNQv9BgVhv+et03314WpQ9H9N8m2L9OSV798olwmG2YLXPl1iSstlJCR1zB3x5xG4g==} engines: {node: ^14.15.0 || >=16.0.0} @@ -5634,6 +5769,14 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} + /synckit@0.8.8: + resolution: {integrity: sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==} + engines: {node: ^14.18.0 || >=16.0.0} + dependencies: + '@pkgr/core': 0.1.1 + tslib: 2.6.2 + dev: true + /synckit@0.9.0: resolution: {integrity: sha512-7RnqIMq572L8PeEzKeBINYEJDDxpcH8JEgLwUqBd3TkofhFRbkq4QLR0u+36avGAhCRbk2nnmjcW9SE531hPDg==} engines: {node: ^14.18.0 || >=16.0.0} diff --git a/src/components/FCCThemeProvider.astro b/src/components/FCCThemeProvider.astro index 460654a4..afcf1635 100644 --- a/src/components/FCCThemeProvider.astro +++ b/src/components/FCCThemeProvider.astro @@ -1,7 +1,3 @@ ---- -import type { Props } from '@astrojs/starlight/props'; ---- - {/* This is intentionally inlined to avoid FOUC. */}