[英]What is the difference between installing eslint as extension and installing as npm package?
I have been following various blogs and videos on setting up and configuring eslint and prettier for vscode and development .我一直在关注有关为 vscode 和开发设置和配置 eslint 和 prettier 的各种博客和视频。 But every article fails to explain why do we need to separately install eslint as an npm package and vs code extension?
但是每篇文章都没有解释why do we need to separately install eslint as an npm package and vs code extension?
what difference it will make if I install either of the ones?如果我安装其中任何一个,会有什么不同?
why do we need to separately install eslint as npm package and vscode extension?为什么我们需要单独安装eslint as npm package 和vscode扩展?
Short answer: you don't.简短的回答:你没有。
Long answer:长答案:
Installing ESLint/Prettier as extension, allows you to format/check your code inside the VSCode.安装 ESLint/Prettier 作为扩展,允许您在 VSCode 中格式化/检查您的代码。
However, installing them also as dependencies brings extra benefits:但是,将它们也作为依赖项安装会带来额外的好处:
script
block of the package.json
, and be able to write custom commands with parameters exactly as you need您将能够通过 package.json 的script
块访问 Prettier/ package.json
,并能够根据需要编写带有参数的自定义命令From my experience, if you can install something locally - install it as package dependency (except CLI like create-react-app or angular-cli that helps you start the app).根据我的经验,如果你可以在本地安装一些东西——将它安装为 package 依赖项(除了像 create-react-app 或 angular-cli 这样的 CLI 可以帮助你启动应用程序)。 This will make your life a bit predictable.这会让你的生活有点可预测。
These programs can format your code (ESLint and Prettier) and detect specific syntax (ESLint).这些程序可以格式化您的代码(ESLint 和 Prettier)并检测特定语法(ESLint)。
When installed as an extension in your IDE (vscode for example), you can get:当作为扩展安装在你的 IDE(例如 vscode)中时,你可以获得:
But someone who starts up your project on their own environment might not have these extensions installed (might not even have the same IDE) and thus might not get these.但是在他们自己的环境中启动您的项目的人可能没有安装这些扩展(甚至可能没有相同的 IDE),因此可能无法获得这些扩展。
When installed as npm packages (and included somewhere in the pipeline, either in the npm start, or in your continuous deployment, or...)当作为 npm 包安装时(并包含在管道中的某处,或者在 npm 开始,或者在你的持续部署中,或者......)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.