You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

npm脚本运行ESLint无报错,终端直接运行却正常的问题排查

ESLint脚本执行无报错,但直接终端执行正常的问题

我通过npm init @eslint/config安装了适配TypeScript的ESLint,并在package.json中添加lint脚本:

"scripts": {
  "lint": "eslint -c ./.eslintrc.js ./src/**/*.ts"
}

但执行npm run lint时ESLint未报告任何错误,奇怪的是直接在终端执行该命令却能正常检测出问题。

相关配置文件

.eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: "standard-with-typescript",
  overrides: [],
  parserOptions: {
    ecmaVersion: "latest",
    sourceType: "module",
    project: ["./tsconfig.json"],
    tsconfigRootDir: __dirname
  },
  ignorePatterns: ["!.*", "dist", "node_modules", "./.eslintrc.js", "./src/config/"],
  rules: {
    "@typescript-eslint/no-var-requires": 0,
    "@typescript-eslint/no-base-to-string": 0,
    "@typescript-eslint/restrict-template-expressions": 0,
    "@typescript-eslint/consistent-type-assertions": 0,
    "@typescript-eslint/strict-boolean-expressions": 0,
    "@javascript-eslint/no-path-concat": 0,
    "@typescript-eslint/semi": [2, "always"],
    "@typescript-eslint/quotes": [2, "double"],
    semi: [2, "always"],
    quotes: [2, "double", { avoidEscape: true, allowTemplateLiterals: true }]
  }
};

.eslintignore

!.eslintrc.js

VSCode ESLint插件输出日志

[Info  - 12:09:28 PM] ESLint server is starting
[Info  - 12:09:30 PM] ESLint server running in node v16.14.2
[Info  - 12:09:30 PM] ESLint server is running.
[Info  - 12:09:31 PM] ESLint library loaded from: /home/user/code/rateassessment/node_modules/eslint/lib/api.js

项目结构

rateassessment/
├── src/
│   ├── config/
│   ├── (其他TypeScript文件及子目录)
├── .eslintrc.js
├── .eslintignore
├── tsconfig.json
├── package.json
├── node_modules/
├── dist/

内容的提问来源于stack exchange,提问作者user96931

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 06:15:19