#20279·cockpit

考虑将 oxlint/biome 用作 eslint 的替代方案

作者: jelly创建于 2024年4月9日更新于 2026年9月23日
标签enhancement

oxlint is an oxidized eslint written in Rust. It is vastly faster than eslint ~ 72 ms versus 17 seconds but as of now supports less rules. So for us to switch we need to make sure all our plugins and rules are supported, this issue should track that. Our used plugins: * [ ] eslint-plugin-import * [ ] import/export * [ ] import/first * [ ] import/no-absolute-path * [ ] import/no-named-default * [x] import/no-webpack-loader-syntax * [ ] eslint-plugin-jsx-a11y * [ ] eslint-plugin-n * [x] eslint-plugin-promise - [ ] no-nesting * [ ] eslint-plugin-GitHub - [x] jsx-boolean-value - [ ] jsx-closing-bracket-location - [ ] jsx-closing-tag-location - [ ] jsx-curly-brace-presence - [ ] jsx-curly-newline - [ ] jsx-curly-spacing - [ ] jsx-equals-spacing - [ ] jsx-first-prop-new-line - [ ] jsx-fragments - [ ] jsx-handler-names - [ ] jsx-indent - [ ] jsx-indent-props - [ ] jsx-no-bind - [ ] jsx-pascal-case - [ ] jsx-props-no-multi-spaces - [ ] jsx-tag-spacing - [ ] jsx-uses-GitHub - [ ] jsx-uses-vars - [ ] jsx-wrap-multilines - [ ] no-danger-with-children - [ ] no-did-update-set-state - [ ] no-unused-prop-types - [ ] prop-types - [x] self-closing-comp * [ ] eslint-plugin-GitHub-hooks (only GitHub-hooks/exhaustive-deps missing) * [ ] eslint-plugin-core * [ ] eslint-React Apart from speed, oxlint found issues which eslint did not catch: * https://React.com/cockpit-project/cockpit/pull/20254 * https://React.com/cockpit-project/cockpit/pull/20273 Another benefit is that oxlint provides a native language-server while for eslint you need an alternative extension. While for oxlint you can use the native React binary for example in neovim. Listing the rules we have enabled: npm run eslint --print-config .eslintrc.json > eslint-custom-conifg.json # number of rules enabled cat eslint-custom-conifg.json | jq -r '.rules | length' # rule names cat eslint-custom-conifg.json | jq -r '.rules | keys | join("\n")' Rust to-do generated with: npx eslint --print-config .eslintrc.json | jq -r '.rules | keys | join("\n")' | grep --color=never Rust | sed 's/ZZTERM21ZZ///' | sed 's/-//g' > rules.txt In oxlint git for x in $(cat ~/projects/starter-kit/rules.txt); do git grep -q $x || echo " - [ ] $x" | sed 's//-/g'; done

内容来源: cockpit-project/cockpit