Hi Kai, Yes, sorry, I should have mentioned that the documentation might already exist, and it's entirely possible I missed it. So thanks for that link--I see it was there all along :-) Anyway, thanks again to both you and Nicholas. I'm glad my issues is resolved, and this was a good learning experience.
We can consider this resolved. --Carl On Mon, Jan 27, 2020 at 5:31 AM Kai Cataldo <[email protected]> wrote: > Hey Carl, > > Glad you were able to solve your issue! Regarding the behavior of > configuration files, the documentation can be found here: > > https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy > . > > If you feel that the documentation can be improved in some way, please > feel free to file an issue. > > All the best, > Kai > > On Sun, Jan 26, 2020 at 2:12 AM Carl Gross <[email protected]> wrote: > >> Hi Nicholas, >> >> I'm back--sorry for the delay. >> >> OK I did everything you suggested, including adding the 'env' info (with >> the correct syntax, and it appears to have worked. That's great--thanks so >> much for that! >> >> >> When you create a project-level config, the home directory config is >> ignored. >> >> OK thanks. That was my big question: if I have a project-level config >> *and* a home directory config, does one supersede the other, or supplement >> the other, or something else? I couldn't seem to find that info anywhere >> in the ESLint documentation. Is it there? If not, maybe it might be >> worthwhile to make it clear to newbies that this is the behavior. I might >> even be able to add that with a pull request, if so desired. But during >> this exercise, it was even confusing to me why I didn't have a config file >> in my project's directory at all, and in light of that, *where* ESLint >> looked next for a config. i.e. what is the hierarchy for ESLint config >> files? >> >> Anyway, that's just a suggestion. But if I'm the only person that has >> reached out about this issue, then it's probably not worth addressing. >> Chalk it up to user error :-) >> >> Thanks again, >> >> Carl >> >> >> >> On Thu, Jan 23, 2020 at 8:06 AM Nicholas Zakas < >> [email protected]> wrote: >> >>> Okay, so what’s happening is that ESLint is falling back to the config >>> in your home directory. When you create a project-level config, the home >>> directory config is ignored. In general, we recommend always using a >>> project config that contains all of the settings appropriate for your >>> project. That way, you can check in the config and anyone who works on the >>> project can make use of it without any additional steps. >>> >>> So if you copy your home directory config into your project directory >>> and then add in the “env” info, you should be set. >>> >>> For specific syntax, I’d suggest reading through these: >>> https://eslint.org/docs/user-guide/configuring#specifying-environments >>> https://eslint.org/docs/user-guide/configuring#configuration-file-formats >>> >>> https://eslint.org/docs/user-guide/configuring#extending-configuration-files >>> >>> >>> >>> On Wed, Jan 22, 2020 at 6:01 AM Carl Gross <[email protected]> wrote: >>> >>>> OK thanks for that. In my console, I navigated to the JS file >>>> in-question and ran that command. It seemed to complete as expected. The >>>> full output is here. https://pastebin.com/BQT4txGQ In it I see these >>>> lines which may be of interest: >>>> >>>> 2020-01-22T13:51:56.815Z eslint:cascading-config-array-factory Loading >>>> the config file of the home directory. >>>> 2020-01-22T13:51:56.815Z eslint:config-array-factory Loading JSON >>>> config file: C:\Users\snarl\.eslintrc.json >>>> 2020-01-22T13:51:56.816Z eslint:config-array-factory Config file found: >>>> C:\Users\snarl\.eslintrc.json >>>> 2020-01-22T13:51:56.816Z eslint:config-array-factory Loading {extends: >>>> "plugin:@wordpress/eslint-plugin/recommended"} relative to C:\Users\ >>>> snarl\.eslintrc.json >>>> 2020-01-22T13:51:56.816Z eslint:config-array-factory Loading plugin >>>> "@wordpress/eslint-plugin" from C:\Users\snarl\.eslintrc.json >>>> >>>> I then had a look at the file C:\Users\snarl\.eslintrc.json. The >>>> contents of that file are here: https://pastebin.com/8DVfF8h4 >>>> >>>> Thoughts? Should I try adding my env: browser code to that file? If >>>> so, what's the correct code/syntax? Would the contents of .eslintrc.json >>>> then be: >>>> >>>> { >>>> "extends": [ >>>> "plugin:@wordpress/eslint-plugin/recommended" >>>> ]. >>>> "env": { >>>> "browser": true, >>>> } >>>> >>>> } >>>> >>>> Are the square braces and curly braces interchangeable? >>>> >>>> Thanks! >>>> >>>> On Wednesday, January 22, 2020 at 2:49:48 AM UTC+7, Nicholas Zakas >>>> wrote: >>>>> >>>>> You may want to take a look at the Getting Started guide: >>>>> https://eslint.org/docs/user-guide/getting-started >>>>> >>>>> in general you’d use “npx eslint filename.js —debug” >>>>> >>>>> You can also run without —debug time see what you’d get as output, as >>>>> sometimes it’s different than what VS Code gives you. (We don’t own the VS >>>>> Code integration, so sometimes things can get out of sync.) >>>>> >>>>> On Tue, Jan 21, 2020 at 8:46 AM Carl Gross <[email protected]> wrote: >>>>> >>>> Hey thanks for that. Here are my follow-ups. >>>>>> >>>>>> >> I’d suggest deleting your new eslintrc file first >>>>>> >>>>>> OK I'll do that first. >>>>>> >>>>>> >> If you run ESLint on the command line inside your project and use >>>>>> the —debug flag, you should be able to figure out which config files are >>>>>> being used by ESLint. >>>>>> >>>>>> I've never used ESLint from the command line. Would I run: >>>>>> >>>>>> *eslint filename.js --debug* >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Carl >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Tuesday, January 21, 2020 at 11:37:47 PM UTC+7, Nicholas Zakas >>>>>> wrote: >>>>>>> >>>>>>> It sounds like you might have other configuration files in your >>>>>>> hierarchy. If you run ESLint on the command line inside your project and >>>>>>> use the —debug flag, you should be able to figure out which config files >>>>>>> are being used by ESLint. I’d suggest deleting your new eslintrc file >>>>>>> first, run with —debug, and see where config is being loaded from. >>>>>>> >>>>>>> FWIW, you are setting the environment correctly. We just need to >>>>>>> figure out which config is being read at which time. >>>>>>> >>>>>>> On Tue, Jan 21, 2020 at 8:23 AM Carl Gross <[email protected]> wrote: >>>>>>> >>>>>>>> Hello, >>>>>>>> >>>>>>>> I'm currently using ESLint in my project, and have configured it to >>>>>>>> run inside VSCode, and enforce a custom ruleset >>>>>>>> <https://www.npmjs.com/package/@wordpress/eslint-plugin/v/1.0.0>. >>>>>>>> So far it is working as expected, and flagging lines in my code where >>>>>>>> violations occur. I now need to specify that the `environment` is >>>>>>>> `browser` (as suggested in the solution to this issue >>>>>>>> <https://github.com/eslint/eslint/issues/4015>). How exactly do I >>>>>>>> do that, yet keep everything else about ESLint working as-is? >>>>>>>> >>>>>>>> - That GitHub issue indicates I need to edit my `.eslintrc` file. >>>>>>>> But I don't see any such file in the root of my project. I *do* see >>>>>>>> `.eslint` files in several different dependency folders, e.g. >>>>>>>> >>>>>>>> >>>>>>>> C:\Users\snarl\development-snarl\development-wordpress\linting-wordpress\node_modules\is-callable >>>>>>>> >>>>>>>> I could be wrong, but those don't seem related. >>>>>>>> >>>>>>>> - I tried creating a new file--*.eslintrc.json*--in the root of >>>>>>>> my project, and adding to that file: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> *{ "env": { "browser": true }}* >>>>>>>> >>>>>>>> >>>>>>>> But when I did this, and re-checked ESLint inside VSCode, it >>>>>>>> stopped flagging the rules in my custom ruleset (examples >>>>>>>> <https://i.imgur.com/GEcPnWg.jpg>), and actually flagged a new >>>>>>>> rule (screenshot <https://i.imgur.com/tHIVUIy.jpg>). This seems >>>>>>>> to completely supersede some of my existing ESLint settings, rather >>>>>>>> than >>>>>>>> supplement them. >>>>>>>> >>>>>>>> Thanks. >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "ESLint" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/eslint/CAFa23ms5p13gV7ZRFHAHB9RJYUe8f%2B7vkx9Y1toMzpUo9UF2sw%40mail.gmail.com >>>>>>>> <https://groups.google.com/d/msgid/eslint/CAFa23ms5p13gV7ZRFHAHB9RJYUe8f%2B7vkx9Y1toMzpUo9UF2sw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> >>>>>>> -- >>>>>>> >>>>>>> ______________________________ >>>>>>> Nicholas C. Zakas >>>>>>> @slicknet >>>>>>> >>>>>>> Author, Principles of Object-Oriented JavaScript >>>>>>> <http://amzn.to/29Pmfrm> >>>>>>> Author, Understanding ECMAScript 6 <http://amzn.to/29K1mIy> >>>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "ESLint" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> >>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/eslint/c5f77688-93c6-49f4-8a7c-7184782445bd%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/eslint/c5f77688-93c6-49f4-8a7c-7184782445bd%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- >>>>> >>>>> ______________________________ >>>>> Nicholas C. Zakas >>>>> @slicknet >>>>> >>>>> Author, Principles of Object-Oriented JavaScript >>>>> <http://amzn.to/29Pmfrm> >>>>> Author, Understanding ECMAScript 6 <http://amzn.to/29K1mIy> >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "ESLint" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/eslint/0b5e9df3-d812-4b69-9f99-631ba1ec395c%40googlegroups.com >>>> <https://groups.google.com/d/msgid/eslint/0b5e9df3-d812-4b69-9f99-631ba1ec395c%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>> >>> >>>> -- >>> >>> ______________________________ >>> Nicholas C. Zakas >>> @slicknet >>> >>> Author, Principles of Object-Oriented JavaScript >>> <http://amzn.to/29Pmfrm> >>> Author, Understanding ECMAScript 6 <http://amzn.to/29K1mIy> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "ESLint" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/eslint/CAFa23msN6dM3fMh84gD5be45N%3DRyGbc38xXwDgWczb-nsm%2BTJg%40mail.gmail.com >> <https://groups.google.com/d/msgid/eslint/CAFa23msN6dM3fMh84gD5be45N%3DRyGbc38xXwDgWczb-nsm%2BTJg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > Kai Cataldo > Independent Software Developer & maintainer of ESLint > <https://eslint.org/> and Babel <https://babeljs.io/> > kaicataldo.com > -- You received this message because you are subscribed to the Google Groups "ESLint" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/eslint/CAFa23mtt2K9zwUgiskTRxAWaYWa5e%2B0ezMighboPo8ZYmkYcZg%40mail.gmail.com.
