适用于JavaScript和相关框架的可插入linting实用程序。
如何在 VSCode 中使用 Typescript 配置 ESLint 平面配置? (不含 FlatCompat)
我该如何: 过渡到 ESLint 平面配置 以新格式为 Typescript 设置 linting 配置 让 ESLint 扩展在 VSCode 中再次工作
我的项目文件中有一些数字,例如1_000_000和1_000。我使用 _ 让它们更容易阅读,但是 Eslint 抱怨在数字中使用 _。 我怎么能说这些麻木...
如何使用eslint/prettier从React中的className中删除无用的空格?
我遇到了一个问题。我注意到在 React 项目中 prettier 并没有解决类名中无用空格这样的问题。例如:
nx vue-monorepo 构建由于从节点模块内的插件加载 eslint 配置而失败
我正在尝试将一个大型 vue 项目迁移到 monorepo。 ✅ 我设法运行命令来启动本地开发服务器: > nx 运行 texaholdem:dev > vite --mode localdev VITE v5.0.12 已准备就绪
如何将postcss.config.js和tailwind.config.js转换为ES模块?
我通过 npm init vue@latest 使用 Vite 创建了一个新的 Vue 应用程序。我根据官方指南将TailwindCSS添加到项目中。 运行 npm run lint 会引发错误 错误“模块”未定义 no-un...
将 eslint 更新到 V9.0.0 后,react 出现错误
我最近在 create-react-app 项目中更新了我的 eslint 版本。之前我使用的是 eslint V7.24,并且使用的是 .eslintrc.js 文件,但更新到 eslint v9.0.0 后,我开始遇到错误...
ESLint:解析错误:无法在 WSL2 上的 WebStorm IDE 上读取文件 tsconfig.json
当克隆我的存储库并在 WSL2 上执行 npm install 时,我在 IDE 上针对项目中的所有 .ts 文件收到此 ESLint 错误: ESLint:解析错误:无法读取文件 \wsl$\ubuntu-20.04\home\
我们的项目基于 Angular 13,从 tslint 迁移到 eslint 后已经成功使用 eslint。后来我们从 Angular 13 迁移到 Angular 16,ng lint 输出的消息是......
如何在 useCallback 中使用 ESlint 允许 IIFE 语法?
我有以下 lint 错误: 它确实插入 ';' prettier/prettier 错误,如果我让我的 IDE 修复它,我在第一行有一个分号: ;(异步() => { 然后它抱怨另一条规则......
我正在创建一个新的 Next.js 应用程序。 当我运行yarn create-next-app并开始在Visual Studio Code中编写javascript代码时,ESlint扩展每次输入数字时都会返回一个错误。 ...
我在将 eslint 升级到 9.0.0 时遇到下一个问题 ⋊> ~/A/turborepo 上的 fusion ⨯ 面包皮毛 22:21:58 $ eslint 包/*/src/**/* 哎呀!一些...
未找到 Visual Studio Code 的 ESLint 配置
我已经安装了 Visual Studio Code 编辑器的 ESLint 插件,它显示它也已安装,但我仍然看到错误:在...顶部找不到 Visual Studio Code 的 ESLint 配置...
我有一个 Expo React Native 应用程序,其中组件中有大量未使用的导入。 我有 Prettier 设置用于代码格式化,是否可以配置 Prettier 以删除任何未使用的导入 acr...
无法加载要扩展的配置“@ljharb”。 (ESLint 8、Webpack 5)
我正在为一个使用 Babel、Webpack、Eslint 和 React 的项目升级包。在进行软件包更新时,我在重建应用程序时遇到了错误,并且可能......
我们将文件拆分为 component.vue、styles.scss 和 template.html,如下所示: // 公共元素 从 '@/components/Elem... 导入类别</desc> <question vote="0"> <div> </div> <p>我们将文件<a href="https://mokkapps.de/vue-tips/split-your-sfc-into-multiple-files" rel="nofollow noreferrer">分割</a>到component.vue、styles.scss和template.html中,类似于:</p> <pre><code><script setup lang="ts"> // Common elements import Category from '@/components/Elements/Category/Category.vue'; // COMPOSABLES const localePath = useLocalePath(); // DATA const session = ref(getSession()); </script> <template src="./CustomTable.html" /> <style lang="scss" src="./custom-table.scss" /> </code></pre> <p>但即使在 <pre><code>Category</code></pre> 上使用 <pre><code>localePath</code></pre>、<pre><code>session</code></pre> 和 <pre><code>./CustomTable.html</code></pre>,linter 也会带来以下问题:</p> <pre><code>3:8 warning 'Category' is defined but never used @typescript-eslint/no-unused-vars 6:7 warning 'localePath' is assigned a value but never used @typescript-eslint/no-unused-vars 9:7 warning 'session' is assigned a value but never used @typescript-eslint/no-unused-vars </code></pre> <p>我知道我们可以使用<pre><code>eslint-disable</code></pre></p> <pre><code><script setup lang="ts"> /* eslint-disable @typescript-eslint/no-unused-vars */ // Common elements import Category from '@/components/Elements/Category/Category.vue'; // COMPOSABLES const localePath = useLocalePath(); // DATA const session = ref(getSession()); /* eslint-enable @typescript-eslint/no-unused-vars */ </script> <template src="./CustomTable.html" /> <style lang="scss" src="./custom-table.scss" /> </code></pre> <p>但这可能会导致真正未使用的变量被忽略</p> <p>有什么方法可以让 linter 在链接的模板文件中搜索用法吗?否则你建议我们可以做些什么?</p> <p>顺便说一句,这是我们的 eslintrc.ts</p> <pre><code>{ "env": { "browser": true, "es2021": true, "node": true, "vue/setup-compiler-macros": true }, "extends": [ "eslint:recommended", "plugin:vue/vue3-recommended", "@nuxtjs/eslint-config-typescript", "plugin:@typescript-eslint/recommended", "prettier", "plugin:storybook/recommended" ], "overrides": [], "parser": "vue-eslint-parser", "parserOptions": { "parser": "@typescript-eslint/parser" }, "plugins": ["vue", "@typescript-eslint"], "rules": { "no-debugger": "off", "vue/multi-word-component-names": "off", "@typescript-eslint/no-explicit-any": "off", "vue/no-reserved-component-names": "off", "import/no-named-as-default": "off", "arrow-body-style": ["error", "as-needed"], "padding-line-between-statements": ["error", { "blankLine": "always", "prev": "*", "next": "if" }] } } </code></pre> <p>-编辑-</p> <p>还可以</p> <pre><code>defineExpose({ Category, localePath, session }) </code></pre> <p>但我不想在无意的时候避免暴露</p> </question> <answer tick="false" vote="0"> <p>ESLint 默认情况下不会读取您的 HTML 文件,因此预计它不会了解这些文件中的变量用法。</p> 几年前,ESLint 添加了一条规则,允许将 JSX 中访问的变量标记为“已使用”,从而删除警告。有一个 API 可以支持此操作 (<p>markVariableAsUsed<a href="https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md" rel="nofollow noreferrer">),您可以使用它来为 HTML 文件实现类似的规则。</a> <a href="https://github.com/jsx-eslint/eslint-plugin-react/blob/e4ecbcfc8f83099a9bd5da18f45b5a6e66ebfb4a/lib/rules/jsx-uses-vars.js#L55" rel="nofollow noreferrer">还有一个现有的 lint HTML 文件插件 (</a>es-plugin-html</p>),它似乎实现了<p>正是这个<a href="https://github.com/BenoitZugmeyer/eslint-plugin-html" rel="nofollow noreferrer">。使用此插件,在 HTML 文件中访问的全局变量将被标记为“已使用”。</a> <a href="https://github.com/BenoitZugmeyer/eslint-plugin-html/blob/d7e747ef0a2d2a1d1c6f6844525b5d6887a16f6a/src/verifyWithSharedScopes.js#L64" rel="nofollow noreferrer">我建议尝试一些支持 linting HTML 的插件。</a> </p>另一种可能的解决方案是在其他地方定义变量并导出它们。<p> </p> <p></p>
Create React App 上的情感-js - 'jsx' 已定义但从未使用过
所以我第一次尝试使用情感js并被css prop功能迷住了。 在尝试文档所说的内容时,我收到了来自 eslint 的警告。 'jsx' 已定义但从未使用@
通过 ESLint 使用 Prettier 格式化 Markdown 和 CSS 文件?
目前,我已经使用以下 .eslintrc.json 通过 ESLint 设置了 Prettier: { “extends”:[“react-app”,“插件:更漂亮/推荐”] } 这对于检查和格式化效果很好
此代码运行正确(将对象数组转换为对象对象) 然而 ES-lint 给出了这个错误: [eslint] 箭头函数不应返回赋值。 (无返回分配)
Nuxt 更新后出现“当前运行的 TypeScript 版本不受@typescript-eslint/typescript-estree 官方支持”问题
我刚刚通过 npx nuxi Upgrade 在我的项目中升级了 nuxt ,现在当我运行 eslint 时。我有这个输出 ============= 警告:您当前正在运行一个非官方版本的 TypeScript...
为什么我收到“‘any’值的不安全分配”,尽管该值被定义为具有默认值的字符串
下面的代码显示了2个eslint错误,我不明白为什么。该属性定义为具有默认值的字符串: 导出默认值{ 姓名: '...', 道具: { X: { 类型:Str...