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/CAOkd9h%3D8%2BJ4J0_AnqXfFDow2pM-Z9XV4nNq5Wi6dNJzGwW10TQ%40mail.gmail.com.
