Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Does not respect .eslintrc files in directory tree #21

Closed
mtscout6 opened this issue Mar 16, 2015 · 14 comments
Closed

Does not respect .eslintrc files in directory tree #21

mtscout6 opened this issue Mar 16, 2015 · 14 comments

Comments

@mtscout6
Copy link

I have a large app that will be transitioning to es6 over the next few months. Which means I need a different .eslintrc configuration for the new es6 javascript and the old es5 scripts. I also have a test directory which has a different configuration. Using eslint from the command line the proper configurations are derived according to the directory structure.

Here is a mockup directory structure:

|--- src
    |--- content
        |--- scripts
            |--- es6
                |--- .eslintrc
                |--- **/*.js               <-- (es6 javascript)
            |--- test
                |--- .eslintrc
                |--- **/*Spec.js       <-- (javascript unit tests)
            |--- **/*.js                   <-- (es5 javascript)
        |--- styles
            |--- **/*.less
    |--- *.cs (C# files)
|--- .eslintrc

What seems to be happening is that the .eslintrc file at the root of my repo is the only one getting picked up. Thoughts?

@mtscout6
Copy link
Author

@MoOx
Copy link
Contributor

MoOx commented Mar 17, 2015

The problem is that webpack loaders do not give the filename but only send the input to process.
So I can't handle this case because I am using eslint CLIEngine#executeOnText().

In order to fix that we need first the filename in the loader (poke @sokra) so we can pass to eslint in order to get proper eslintrc file.

@sokra
Copy link
Member

sokra commented Mar 17, 2015

You have access to the filename in the loader function via this.resourcePath. The jshint-loader also uses .jshintrc

@MoOx
Copy link
Contributor

MoOx commented Mar 17, 2015

Oh good to know. Thanks @sokra.
I will update the loader accordingly.

@mtscout6
Copy link
Author

When you do this can you also respect the .eslintignore file? Or would you prefer a separate issue for that?

@MoOx
Copy link
Contributor

MoOx commented Mar 19, 2015

Yes please, a separate issue. Or a separate PR ;)

@MoOx
Copy link
Contributor

MoOx commented Mar 27, 2015

@mtscout6 I investigated on this issue.

For now this cannot be done properly since method that use text for processing doesn't accept filepath or something that will allow us to adjust the config (executeOnText()/processText() just call getConfig() without arguments, and I cannot change that).
I cannot use something at a lower level (eg: verify()) cause in this case, I can't access private loadPlugins() method (which is called by other higher level method) and so plugins will not be loaded.
I can use processOnFile() but that will use a fs read which is stupid because it has already been done.
We need to open an issue on eslint to

  • add a parameter to text methods to receive a filename to pass to getConfig()
    OR
  • make public loadPlugins() methods and other methods that might be required to use in order to get a full linting.

I hope I am clear on this.

poke @nzakas

@tomchentw
Copy link

Experienced the same issue today, thanks for investigating.
@MoOx ++

@nzakas
Copy link

nzakas commented May 12, 2015

@MoOx please file an issue if you have a request

@punmechanic
Copy link

+1 seems that eslint-loader is still not respecting .eslintrc

@MoOx
Copy link
Contributor

MoOx commented May 15, 2015

It depends on your setup. I sucessfuly use .eslintrc on a lot of project using this loader.
Like Nicholas said, someone can open an issue on eslint repo, I think I gave enough information to help.

@MoOx
Copy link
Contributor

MoOx commented Jun 4, 2015

Closed by 1bf9bf9

@MoOx MoOx closed this as completed Jun 4, 2015
@tomchentw
Copy link

This is awesome! Thanks @MoOx !!

@MoOx
Copy link
Contributor

MoOx commented Jun 9, 2015

Do not thank me. Thanks @mgtitimoli
But... #44

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants