Search code examples
reactjstypescripteslinttslint

Why does Eslint report different results on different machines?


In our project we were using tslint but recently migrated to eslint. Running the command "eslint \"packages/**/*.{ts,tsx}\"" on my local machine (Windows) reports 1 error and 409 warnings but running the same command on a linux machine reports 1 error and 2746 warnings.

The result of running linter with --env-info flag is same on both machines

Node version: v12.16.1
npm version: v6.13.4
Local ESLint version: v7.22.0 (Currently used)
Global ESLint version: Not found

The version of the plugins also seems to match.

The folder structure looks like this:

.eslintrc.js
tsconfig.json
package.json
.eslintignore
packages/ (contains subprojects which don't have their own eslint config files)

The contents of the configuration files:

.eslintrc.js file

module.exports = {
    "root": true,
    "env": {
        "browser": true,
        "node": true,
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "./tsconfig.json",
        "sourceType": "module"
    },
    "plugins": [
        "eslint-plugin-jsdoc",
        "eslint-plugin-import",
        "eslint-plugin-react",
        "eslint-plugin-prefer-arrow",
        "react-hooks",
        "@typescript-eslint"
    ],
    "settings": {
        "react": {
            "version": "17.0.0",
        },
    },
    "rules": {...}
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "strictPropertyInitialization": false,
    "jsx": "preserve"
  },
  "exclude": [
    "node_modules",
    "**/*.md",
    "**/dist/**"
  ],
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ]
}

I also checked out some of the warnings that the Linux machine reported but my local Windows machine didn't. For example the following rows both report a warning "Unsafe call of an any typed value"

const {breakPoints} = useTheme();
const currentBreak = useCurrentBreakPoint(breakPoints);

but the types do seem to be correct and typescript is not complaining about them either.

What might be causing the differences in linting results between the two machines?


Solution

  • The problem was caused by missing dependencies. Running "npm install" in all of the subprojects before linting fixed the problem.