1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-21 17:36:52 +01:00

migrate to flat ESLint config file format

This commit is contained in:
Matthias Kretschmann 2024-06-22 14:15:13 +01:00
parent 8d623d02c6
commit 44aba333fa
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 219 additions and 79 deletions

View File

@ -1,54 +0,0 @@
{
"root": true,
"env": {
"es6": true,
"browser": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": { "jsx": true },
"project": "./tsconfig.json",
"tsconfigRootDir": "./"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:astro/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off"
},
"settings": { "react": { "version": "detect" } },
"overrides": [
{
// Define the configuration for `.astro` file.
"files": ["*.astro"],
// Allows Astro components to be parsed.
"parser": "astro-eslint-parser",
// Parse the script in `.astro` as TypeScript by adding the following configuration.
// It's the setting you need when using TypeScript.
"parserOptions": {
"parser": "@typescript-eslint/parser",
"extraFileExtensions": [".astro"]
},
"rules": {
// override/add rules settings here, such as:
// "astro/no-set-html-directive": "error"
}
},
{
"files": ["**/?(*.)+(spec|test).[jt]sx"],
"extends": ["plugin:testing-library/react"],
"rules": {
"testing-library/no-node-access": "off",
"testing-library/no-container": "off"
}
}
]
}

39
eslint.config.mjs Normal file
View File

@ -0,0 +1,39 @@
import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import prettierRecommended from 'eslint-plugin-prettier/recommended'
import eslintPluginAstro from 'eslint-plugin-astro'
import globals from 'globals'
import gitignore from 'eslint-config-flat-gitignore'
import testingLibrary from 'eslint-plugin-testing-library'
import { fixupPluginRules } from '@eslint/compat'
export default tseslint.config(
{
languageOptions: {
globals: { ...globals.browser }
}
},
gitignore(),
eslint.configs.recommended,
...tseslint.configs.recommended,
prettierRecommended,
...eslintPluginAstro.configs.recommended,
...eslintPluginAstro.configs['jsx-a11y-recommended'],
{
rules: {
'@typescript-eslint/no-explicit-any': 'warn'
// "astro/no-set-html-directive": "error"
}
},
// See https://github.com/testing-library/eslint-plugin-testing-library/issues/853
// current solution from https://github.com/testing-library/eslint-plugin-testing-library/issues/899#issuecomment-2121272355
{
files: ['**/?(*.)+(spec|test).[jt]sx'],
plugins: {
'testing-library': fixupPluginRules({
rules: testingLibrary.rules
})
},
rules: testingLibrary.configs.react.rules
}
)

193
package-lock.json generated
View File

@ -41,22 +41,24 @@
"wagmi": "^2.5.7"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/js": "^9.5.0",
"@playwright/test": "^1.44.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@types/node": "^20.14.8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitest/coverage-v8": "^1.6.0",
"eslint": "^8.57.0",
"eslint-config-flat-gitignore": "^0.1.5",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^1.2.2",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-testing-library": "^6.2.2",
"globals": "^15.6.0",
"hast-util-to-html": "^9.0.1",
"husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0",
@ -78,6 +80,7 @@
"svgo": "^3.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.2",
"typescript-eslint": "^7.13.1",
"unist-util-visit": "^5.0.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
@ -1413,6 +1416,15 @@
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/plugin-transform-classes/node_modules/globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
"peer": true,
"engines": {
"node": ">=4"
}
},
"node_modules/@babel/plugin-transform-computed-properties": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.23.3.tgz",
@ -2427,6 +2439,14 @@
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse/node_modules/globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
"engines": {
"node": ">=4"
}
},
"node_modules/@babel/types": {
"version": "7.24.6",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.6.tgz",
@ -3182,6 +3202,15 @@
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
}
},
"node_modules/@eslint/compat": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.1.0.tgz",
"integrity": "sha512-s9Wi/p25+KbzxKlDm3VshQdImhWk+cbdblhwGNnyCU5lpSwtWa4v7VQCxSki0FAUrGA3s8nCWgYzAH41mwQVKQ==",
"dev": true,
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@eslint/eslintrc": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz",
@ -3233,12 +3262,12 @@
}
},
"node_modules/@eslint/js": {
"version": "8.57.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz",
"integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==",
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.5.0.tgz",
"integrity": "sha512-A7+AOT2ICkodvtsWnxZP4Xxk3NbZ3VMHd8oihydLRGrJgqqdEz1qSeEgXYyT/Cu8h1TWWsQRejIx48mtjZ5y1w==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
},
"node_modules/@ethereumjs/common": {
@ -13738,6 +13767,90 @@
"eslint": ">=6.0.0"
}
},
"node_modules/eslint-config-flat-gitignore": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/eslint-config-flat-gitignore/-/eslint-config-flat-gitignore-0.1.5.tgz",
"integrity": "sha512-hEZLwuZjDBGDERA49c2q7vxc8sCGv8EdBp6PQYzGOMcHIgrfG9YOM6s/4jx24zhD+wnK9AI8mgN5RxSss5nClQ==",
"dev": true,
"dependencies": {
"find-up": "^7.0.0",
"parse-gitignore": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/antfu"
}
},
"node_modules/eslint-config-flat-gitignore/node_modules/find-up": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-7.0.0.tgz",
"integrity": "sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==",
"dev": true,
"dependencies": {
"locate-path": "^7.2.0",
"path-exists": "^5.0.0",
"unicorn-magic": "^0.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-config-flat-gitignore/node_modules/locate-path": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz",
"integrity": "sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==",
"dev": true,
"dependencies": {
"p-locate": "^6.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-config-flat-gitignore/node_modules/p-limit": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz",
"integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==",
"dev": true,
"dependencies": {
"yocto-queue": "^1.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-config-flat-gitignore/node_modules/p-locate": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz",
"integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==",
"dev": true,
"dependencies": {
"p-limit": "^4.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-config-flat-gitignore/node_modules/path-exists": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz",
"integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==",
"dev": true,
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/eslint-config-prettier": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz",
@ -13775,18 +13888,6 @@
"eslint": ">=8.57.0"
}
},
"node_modules/eslint-plugin-astro/node_modules/globals": {
"version": "15.6.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-15.6.0.tgz",
"integrity": "sha512-UzcJi88Hw//CurUIRa9Jxb0vgOCcuD/MNjwmXp633cyaRKkCWACkoqHCtfZv43b1kqXGg/fpOa8bwgacCeXsVg==",
"dev": true,
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eslint-plugin-jsx-a11y": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.9.0.tgz",
@ -14108,6 +14209,15 @@
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint/node_modules/@eslint/js": {
"version": "8.57.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz",
"integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/eslint/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -15222,11 +15332,15 @@
}
},
"node_modules/globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
"version": "15.6.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-15.6.0.tgz",
"integrity": "sha512-UzcJi88Hw//CurUIRa9Jxb0vgOCcuD/MNjwmXp633cyaRKkCWACkoqHCtfZv43b1kqXGg/fpOa8bwgacCeXsVg==",
"dev": true,
"engines": {
"node": ">=4"
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/globalthis": {
@ -20598,6 +20712,15 @@
"node": ">=6"
}
},
"node_modules/parse-gitignore": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/parse-gitignore/-/parse-gitignore-2.0.0.tgz",
"integrity": "sha512-RmVuCHWsfu0QPNW+mraxh/xjQVw/lhUCUru8Zni3Ctq3AoMhpDTq0OVdKS6iesd6Kqb7viCV3isAL43dciOSog==",
"dev": true,
"engines": {
"node": ">=14"
}
},
"node_modules/parse-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
@ -25227,6 +25350,32 @@
"semver": "^7.3.8"
}
},
"node_modules/typescript-eslint": {
"version": "7.13.1",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.13.1.tgz",
"integrity": "sha512-pvLEuRs8iS9s3Cnp/Wt//hpK8nKc8hVa3cLljHqzaJJQYP8oys8GUyIFqtlev+2lT/fqMPcyQko+HJ6iYK3nFA==",
"dev": true,
"dependencies": {
"@typescript-eslint/eslint-plugin": "7.13.1",
"@typescript-eslint/parser": "7.13.1",
"@typescript-eslint/utils": "7.13.1"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.56.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/ua-parser-js": {
"version": "1.0.37",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz",

View File

@ -18,7 +18,7 @@
"test:unit:watch": "vitest watch --config './test/vitest.config.ts' --coverage",
"test:e2e": "playwright test --config './test/playwright.config.ts'",
"lint": "run-p --silent lint:js lint:css lint:md",
"lint:js": "eslint --ignore-path .gitignore './{src,test,scripts}/**/*.{ts,tsx,astro,mjs,js,cjs}'",
"lint:js": "eslint './{src,test,scripts}/**/*.{ts,tsx,astro,mjs,js,cjs}'",
"lint:css": "stylelint --config '.config/.stylelintrc.json' 'src/**/*.css'",
"lint:md": "markdownlint --config '.config/.markdownlint.json' --ignore-path .gitignore --dot './**/*.{md,markdown}'",
"format": "prettier --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx,md,json,css,astro,yml}'",
@ -81,22 +81,24 @@
"wagmi": "^2.5.7"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/js": "^9.5.0",
"@playwright/test": "^1.44.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@types/node": "^20.14.8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitest/coverage-v8": "^1.6.0",
"eslint": "^8.57.0",
"eslint-config-flat-gitignore": "^0.1.5",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^1.2.2",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-testing-library": "^6.2.2",
"globals": "^15.6.0",
"hast-util-to-html": "^9.0.1",
"husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0",
@ -118,6 +120,7 @@
"svgo": "^3.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.2",
"typescript-eslint": "^7.13.1",
"unist-util-visit": "^5.0.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"

View File

@ -73,6 +73,7 @@ const srcSetStrings = formats.reduce((acc: Record<string, string>, format) => {
aria-hidden="true"
src={`data:image/svg+xml;charset=utf-8,%3Csvg%20height="${height}"%20width="${width}"%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E`}
style="max-width:100%;display:block;position:static"
alt="placeholder"
/>
</div>
) : null

View File

@ -125,6 +125,7 @@ import CodeCopy from '@components/CopyCode.astro'
<a href="https://github.com/sponsors/kremalicious/">
<img
src="https://img.shields.io/static/v1?label=Sponsor%20On%20GitHub&labelColor=%2343a699&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86&style=for-the-badge"
alt="GitHub Sponsors Badge"
/>
</a>
</section>

1
test/src/env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="astro/client" />