Search code examples
eslinttypescript-eslint

eslint doesn't report any errors when run from an npm script


I have installed eslint with typescript using npm init @eslint/config then added a lint script to my package.json but when I run the npm script lint (npm run lint), eslint doesnt report any error. the lint script: "eslint -c ./.eslintrc.js ./src/**/*.ts" oddly enough, when I run eslint -c ./.eslintrc.js ./src/**/*.ts from the terminal works without any issues.

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 }]
  }
};

I have a .eslintignore file but its content limited to this line

!.eslintrc.js

I also checked VSCode output and all is see is

[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

My project structure enter image description here


Solution

  • The solution was to use quotes around the globe in the npm script like "lint": "eslint -c ./.eslintrc.js \"./src/**/*.ts\""