babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser
MIT License
2.96k stars 208 forks source link

How to check multiple files? #757

Closed mraak closed 5 years ago

mraak commented 5 years ago

I'm following a basic tutorial in the readme. I have the following source code:

/src -lib.js -index.js -eslintrc.js

eslintrc.js

module.exports = {
  parser: "babel-eslint",
  parserOptions: {
    sourceType: "module",
    allowImportExportEverywhere: false,
    ecmaFeatures: {
      globalReturn: false,
    },
    babelOptions: {
      configFile: "path/to/config.js",
    },
  },
  rules: {
    semi: "error"
}
};

index.js

import {getFoo} from './lib'
var k = 0

if(i == "3"){

}

console.log('My Webpack Babel Setup ' + **getFoo(2))

lib.js

export function getFoo(num = 1){
  return "foo"+num
}

When I ran ./node_modules/.bin/eslint .\src\index.js I expected the errors would be reported from all the files and marked in which file it was, but it is only reporting from index.js. How do I need to set this up for multi file checking where the imports are recognized which files need checking?

kaicataldo commented 5 years ago

Hi - this isn't an issue with babel-eslint. ESLint is only linting src/index.js because you're explicitly telling it to only lint that file. If you want to lint all files in the src/ directory you'll want to run ./node_modules/.bin/eslint src.

Check out ESLint's documentation for more details.