diff --git a/scripts/dictionary.txt b/scripts/dictionary.txt index 9772d020af..8f4c230fc6 100644 --- a/scripts/dictionary.txt +++ b/scripts/dictionary.txt @@ -94,6 +94,7 @@ rslog rspack rspress rstack +ruleset selfsign selfsigned sirv diff --git a/website/docs/en/guide/migration/cra.mdx b/website/docs/en/guide/migration/cra.mdx index 67e5143a11..63c7ee34c8 100644 --- a/website/docs/en/guide/migration/cra.mdx +++ b/website/docs/en/guide/migration/cra.mdx @@ -237,6 +237,18 @@ In the Rsbuild project, you can remove the dependency and code related to react- You can read [Browser Compatibility](/guide/advanced/browser-compatibility) to understand how Rsbuild handles polyfills. +## Add ESLint plugin + +CRA has the [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin) enabled by default and includes a set of built-in ESLint rules. + +In an Rsbuild project, if you need similar functionality, you can add [@rsbuild/plugin-eslint](https://github.com/rspack-contrib/rsbuild-plugin-eslint) and use [eslint-config-react-app](https://www.npmjs.com/package/eslint-config-react-app) as the ESLint ruleset. + +```js title=".eslintrc.cjs" +module.exports = { + extends: 'react-app', +}; +``` + ## Reading jsconfig.json In non-TypeScript projects, CRA supports reading the `paths` field in jsconfig.json as the path alias. diff --git a/website/docs/zh/guide/migration/cra.mdx b/website/docs/zh/guide/migration/cra.mdx index b536dc38e9..6002ef56fc 100644 --- a/website/docs/zh/guide/migration/cra.mdx +++ b/website/docs/zh/guide/migration/cra.mdx @@ -237,6 +237,18 @@ CRA 提供了 [react-app-polyfill](https://www.npmjs.com/package/react-app-polyf 你可以参考 [浏览器兼容性](/guide/advanced/browser-compatibility) 来了解 Rsbuild 是如何处理 polyfill 的。 +## 添加 ESLint 插件 + +CRA 默认启用了 [eslint-webpack-plugin](https://github.com/webpack-contrib/eslint-webpack-plugin),并内置了一套 ESLint 规则集。 + +在 Rsbuild 项目中,如果你需要保持类似的行为,可以添加 [@rsbuild/plugin-eslint](https://github.com/rspack-contrib/rsbuild-plugin-eslint),并使用 [eslint-config-react-app](https://www.npmjs.com/package/eslint-config-react-app) 作为 ESLint 规则集。 + +```js title=".eslintrc.cjs" +module.exports = { + extends: 'react-app', +}; +``` + ## 读取 jsconfig.json 在非 TypeScript 项目中,CRA 支持读取 jsconfig.json 中的 `paths` 字段作为路径别名。