Skip to content

Commit be33bec

Browse files
authored
Migrate ESLint to @hasparus/eslint-config (flat config, ESLint 10) (#115)
* Migrate ESLint to @hasparus/eslint-config (flat config, ESLint 10) - replace inlined @edgeandnode .eslintrc.cjs with flat eslint.config.js - extend @hasparus/eslint-config/the-guild; disable perfectionist/sort-* and unicorn/prefer-global-this - astro block lints frontmatter (projectService off; astro parser can't drive type-aware linting) - solid + check-file + better-tailwindcss blocks - pnpm override pins @typescript-eslint/* to 8.62.1: @theguild/eslint-config drags in utils@8.26 which crashes on ESLint 10 * Use @hasparus/eslint-config astro + solid presets Thin consumer config: [...astro, ...solid] + per-repo tailwind entrypoint and check-file. Drops direct astro-parser/solid/better-tailwindcss/compat deps (now transitive via presets). Aligns @typescript-eslint override to 8.61.1 to match the shared config. * Green up lint: rename .ts→.tsx, fix errors, pin 2.3.0 - rename 18 src .ts → .tsx (check-file .tsx-only convention) - fix genuine errors: no-empty-function (noop), innerText→textContent, no-array-reduce→loop, no-await-expression-member, prefer-top-level-await, no-explicit-any→MarkdownInstance, prefer-add-event-listener (+ latent removeEventListener bug), a11y backdrop-dismiss (intent-disabled) - add DOM.Iterable to tsconfig lib (NodeList spread/.at were untyped) - disable low-value unicorn/consistent-function-scoping; suppress astro no-undef + solid react/display-name false positives - pin @hasparus/eslint-config to exact 2.3.0 Remaining: 7 solid/reactivity + 1 no-console warnings (non-blocking). * Patch prettier-plugin-astro to not crash on unformattable <style> - pnpm patch: embedStyle falls back to raw <style> when the CSS parser throws, instead of aborting the whole file (upstream withastro/ prettier-plugin-astro#459) - fix malformed empty-selector rule in PostLayout <style> * Bump @hasparus/eslint-config to 2.3.1; drop consumer suppressions no-undef(astro) + react/display-name(solid) now live in the presets. * Bump @hasparus/eslint-config to 3.0.0; drop @typescript-eslint override 3.0.0 dropped @TheGuild, so the @typescript-eslint/utils@8.26 dedup override is no longer needed. Uses /astro + /solid (unaffected by the /the-guild removal). * Address review nits: execFileSync, leaner error log, MDXInstance type - derivedTitleAndDatePlugin: execSync shell string -> execFileSync arg array - Image.astro: log available image keys, not the whole glob map - [...path].astro: MDXInstance (not MarkdownInstance) for the .mdx glob
1 parent c2ddfbf commit be33bec

41 files changed

Lines changed: 2589 additions & 1451 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 27 deletions
This file was deleted.

eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import astro from "@hasparus/eslint-config/astro";
2+
import solid from "@hasparus/eslint-config/solid";
3+
import checkFile from "eslint-plugin-check-file";
4+
5+
export default [
6+
{ ignores: ["**/*.mdx", "**/*.md", "**/*.gitignored.*"] },
7+
8+
...astro,
9+
...solid,
10+
11+
{
12+
settings: {
13+
"better-tailwindcss": { entryPoint: "src/global-styles/base.css" },
14+
},
15+
},
16+
17+
{
18+
rules: { "unicorn/consistent-function-scoping": "off" },
19+
},
20+
21+
{
22+
files: ["src/**/*.ts"],
23+
ignores: ["**/*.d.ts", "**/*.xml.ts", "**/*.txt.ts", "**/*.md.ts"],
24+
plugins: { "check-file": checkFile },
25+
rules: {
26+
"check-file/filename-blocklist": ["error", { "**/*.ts": "*.tsx" }],
27+
},
28+
},
29+
];

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
"@types/unist": "^3.0.3",
3636
"@vercel/og": "^0.6.2",
3737
"astro": "^6.4.6",
38-
"astro-eslint-parser": "^1.4.0",
39-
"eslint-plugin-markdown": "^5.0.0",
4038
"estree-util-value-to-estree": "^3.5.0",
4139
"gray-matter": "4.0.3",
4240
"plaiceholder": "^3.0.0",
@@ -55,12 +53,13 @@
5553
},
5654
"devDependencies": {
5755
"@astrojs/rss": "^4.0.18",
58-
"@edgeandnode/eslint-config": "^2.0.3",
56+
"@hasparus/eslint-config": "3.0.0",
5957
"@playwright/test": "1.60.0",
6058
"@types/hast": "3.0.4",
6159
"@types/node": "^22.0.0",
6260
"cssnano": "^7.1.5",
63-
"eslint": "^8.57.0",
61+
"eslint": "^10.6.0",
62+
"eslint-plugin-check-file": "3.3.1",
6463
"prettier": "^3.8.3",
6564
"prettier-plugin-astro": "^0.14.0",
6665
"prettier-plugin-tailwindcss": "^0.8.0",
@@ -83,6 +82,9 @@
8382
"core-js-pure",
8483
"puppeteer",
8584
"sharp"
86-
]
85+
],
86+
"patchedDependencies": {
87+
"prettier-plugin-astro@0.14.0": "patches/prettier-plugin-astro@0.14.0.patch"
88+
}
8789
}
8890
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/dist/index.js b/dist/index.js
2+
index 6b9f37eac7baa92be5d3a7d6e6054886f99dcac4..817f3c7381c67dfe07f5de53228c161c6e12e963 100644
3+
--- a/dist/index.js
4+
+++ b/dist/index.js
5+
@@ -747,10 +747,21 @@ async function embedStyle(lang, content, path, print, textToDoc, options) {
6+
case 'less':
7+
case 'css':
8+
case 'scss': {
9+
- let formattedStyles = await wrapParserTryCatch(textToDoc, content, {
10+
- ...options,
11+
- parser: lang,
12+
- });
13+
+ let formattedStyles;
14+
+ try {
15+
+ formattedStyles = await textToDoc(content, {
16+
+ ...options,
17+
+ parser: lang,
18+
+ });
19+
+ }
20+
+ catch {
21+
+ const node = path.getNode();
22+
+ return node
23+
+ ? Buffer.from(options.originalText)
24+
+ .subarray(options.locStart(node), options.locEnd(node))
25+
+ .toString()
26+
+ : undefined;
27+
+ }
28+
formattedStyles = stripTrailingHardline(formattedStyles);
29+
const attributes = path.map(print, 'attributes');
30+
const openingTag = group(['<style', indent(group(attributes)), softline, '>']);

0 commit comments

Comments
 (0)