madskristensen/JavaScriptPrettier

ignores .eslintrc.json

fbacker opened this issue · 7 comments

Installed product versions

  • Visual Studio 2017
  • This extension: 2.0.33

Description

Able to use .eslintrc.json instead of .prettierrc. Other Prettier formatters e.g. for Visual Studio Code uses this. Often eslint is already used and having 2 files specifying same things is not a good thing.

Steps to recreate

  1. Install extension
  2. place .eslintrc.json
  3. format a js file

Current behavior

Ignores rules set by eslint

Expected behavior

Look for configuration files by order

.prettierrc > .eslintrc > .eslintrc.json

Hi @fbacker

I have looked into the VSCode extensions source-code - and in my understanding the support for eslint is not part of "native" prettier - and we use that to locate the configuration file. It may be part of the prettier-eslint package..

That said - if someone is willing to implement the feature they are welcome - I like the VSCode extension - and I'm sure that there is alot of wisdom in that plugin.

If it should be implemented I think it should be part of the #16's solution - as we can then "probe" if you have prettier-eslint or prettier-tslint installed, and then use their commands instead.

Hmm. I didn't see this before. I could possibly make more mods to my fix for #16 to make this work too.

If someone has both prettier-eslint and prettier-tslint, I guess we'd have to use the right one for the file extension. Right?

Hey @jesperbjensen,

you think we should have a dictionary mapping an extension regex to command path to search like this?

        // TODO: better name
        private static readonly IDictionary<string, string> _specificExtensionCommandMap = new Dictionary<string, string>
        {
            { ".jsx?", "node_modules\\.bin\\prettier-eslint.cmd" },
            { ".tsx?", "node_modules\\.bin\\prettier-tslint.cmd" }
        };

Then, we could search for the more specific extension-related formatter first, then fall back to the default prettier.cmd search?

If so, we can find the local prettier.cmd, yet we should probably keep searching up the directory tree for the specific ones?

I just realized today that prettier-eslint works on strings, which is very useful to us.
prettier-tslint, however, only works on files, which is much less useful (we want to modify the file before save)

I can definitely implement adding prettier-eslint though (and lay the groundwork for future integrations)

@jesperbjensen @madskristensen - should we also be installing our own copy of prettier-eslint or just support a local copy of that?

All, I have a functioning version that runs prettier-eslint if it's present. Was going to add it as part of the additional extension support I'm adding too.

Just wanted to put this here in case someone else tried to start working on this