Skip to content

chore: replace dead airbnb eslint stack with eslint 9 flat config, bump stylelint to 17 - #102

Open
kimlimjustin wants to merge 1 commit into
mainfrom
fix/lint-stack
Open

chore: replace dead airbnb eslint stack with eslint 9 flat config, bump stylelint to 17#102
kimlimjustin wants to merge 1 commit into
mainfrom
fix/lint-stack

Conversation

@kimlimjustin

Copy link
Copy Markdown
Collaborator

背景

npm 生态的 dependabot PR(#90 #98 #100 #101 等)全部红了,根因是 lint 栈早已死亡:

  • 仓库里根本没有 eslint 配置文件lint:js 从来跑不起来
  • eslint-config-airbnb@19 把 eslint 钉在 ^7||^8,和新版本插件形成 ERESOLVE 死锁
  • stylelint 15 与新 config 也互相冲突

改动

  • 新增 eslint.config.mjs(ESLint 9 flat config:js + typescript-eslint + react + react-hooks + jsx-a11y + regexp + prettier)
  • 移除 airbnb 全家桶(eslint-config-airbnb、@kesills/airbnb-typescript、plugin-import、import-resolver-typescript、裸 @typescript-eslint/*)
  • stylelint 15 → 17,stylelint-config-standard 33 → 40
  • 修掉新规则暴露的所有问题:BlogPostItem wrapper 的 rules-of-hooks 违规、SimpleVideoPlayer 的 setState-in-effect、两处 catch (e: any)require() 图片导入改 ESM(补 png/jpg 类型声明)、stylelint 自动修复及选择器顺序
  • dependabot 忽略 eslint >=10(typescript-eslint ^8 的 peer 只支持 eslint ^8.57||^9)

验证

  • npm run lint:js 0 error(此前直接报错退出)
  • npm run lint:css 0 error
  • npm run typecheck 通过
  • npm run build 通过,KaTeX CSS/字体、公众号二维码图片均正常打包

对现有 dependabot PR 的影响

…mp stylelint to 17

The lint stack silently died long ago: there was no eslint config file
at all (lint:js errored immediately), and the airbnb preset chain pinned
eslint to ^8 while its own peers went unmaintained. Every npm dependabot
PR failed on ERESOLVE against this stack.

- add eslint.config.mjs (flat config: js + typescript-eslint + react +
  react-hooks + jsx-a11y + regexp + prettier)
- drop eslint-config-airbnb, @kesills/airbnb-typescript, plugin-import,
  import-resolver-typescript, raw @typescript-eslint/* pair
- bump stylelint 15 -> 17, stylelint-config-standard 33 -> 40
- fix all new lint findings: rules-of-hooks violation in BlogPostItem
  wrapper, setState-in-effect in SimpleVideoPlayer, catch(e: any)
  narrowing, require() -> ESM image import (+ png/jpg type decls),
  stylelint autofixes and specificity order
- ignore eslint >=10 in dependabot (typescript-eslint ^8 peers eslint
  ^8.57 || ^9 only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant