How to convince eslint that settings are defined?

AI-generated summary

The discussion revolves around resolving ESLint errors related to undefined ‘settings’ variables in ES6 files within a Discourse plugin. pfaffman is encountering multiple no-undef errors despite using settings, and seeks a way to convince ESLint that these variables are defined. david suggests the issue might stem from the shared lint-configs not properly handling the variables, referencing the config file here. merefield directs pfaffman to the lint-configs README for guidance. cvx proposes removing the .es6 file extension as a potential fix. pfaffman confirms that dropping the .es6 suffix resolves the errors, raising the question of whether a global rename of all .es6 files is advisable.

https://github.com/pfaffman/discourse-custom-homepage-for-groups/actions/runs/7211339319/job/19646550333

/home/runner/work/discourse-custom-homepage-for-groups/discourse-custom-homepage-for-groups/javascripts/discourse/initializers/custom-homepage-set.js.es6
Error:   13:11  error  'settings' is not defined  no-undef
Error:   14:21  error  'settings' is not defined  no-undef
Error:   19:20  error  'settings' is not defined  no-undef
Error:   20:21  error  'settings' is not defined  no-undef
Error:   25:36  error  'settings' is not defined  no-undef
Error:   26:21  error  'settings' is not defined  no-undef
Error:   32:40  error  'settings' is not defined  no-undef
Error:   33:26  error  'settings' is not defined  no-undef

https://github.com/pfaffman/discourse-custom-homepage-for-groups/blob/main/javascripts/discourse/initializers/custom-homepage-set.js.es6

Right. I’m using settings. How do I convince eslint that they are defined? I’ve looked at a bunch of other exemplars (like https://github.com/discourse/discourse-brand-header/blob/main/javascripts/discourse/initializers/initialize-mobile-decorator.js) and tney don’t seem to be defining settings.

In theory this should be handled by the eslint config you’re importing from our shared lint-configs :thinking:

https://github.com/discourse/lint-configs/blob/main/lint-configs/eslint-theme.cjs#L7-L10

But it seems like that’s not working for some reason…

Yeah, make sure you read this @pfaffman if you’ve not done so already :slight_smile:

Hm, maybe there’s an incompatibility between the newest eslint config and es6 files. Could you see if the errors persist after dropping the .es6 suffixes?

Rather than reading that, I copied the stuff blindly from the theme skeleton. :person_shrugging: I think I did one time find that, which explains some of the mystery.

You are very kind to suggest that my theory was not without merit.

Aha. So is there some reason not to do a global rename of all of my es6 files everywhere?