Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax rule: Do not enforce camelcase style for global variables (camelcase) #1474

Closed
mcdado opened this issue Jan 13, 2020 · 5 comments
Closed

Comments

@mcdado
Copy link

mcdado commented Jan 13, 2020

What version of this package are you using?
14.3.1

What operating system, Node.js, and npm version?
macOS 10.15.2, Node.js v10.18.1, npm 6.13.4

What happened?
In a JS file for the web, that interacts with a page where there's a variable defined in a template (which comes from an open source e-commerce CMS — changing it would break core functionality because other code expects it) I declare a "global" variable id_product. Using in the code triggers the camelcase rule, but I cannot do anything about it.

/* global $, id_product [...] */

var productId = id_product // Identifier 'id_product' is not in camel case. (camelcase)

What did you expect to happen?
Since it's a global, stylistic rules shouldn't apply. Is it possible to do it with eslint? I just checked my previous configuration and I had camelcase disabled, probably for this reason.

Are you willing to submit a pull request to fix this bug?
Yes.

@mightyiam
Copy link
Member

https://eslint.org/docs/rules/camelcase

I don't see anything regarding globals. Perhaps take a look at ESLint source code; the tests for the camelcase rule; whether there's a test for ignoring globals.

@mcdado
Copy link
Author

mcdado commented Jan 13, 2020

Thank you, sorry I didn't think hard enough about it that it should be an upstream issue... and it seems that there's not much interest there: eslint/eslint#11716

@mcdado mcdado closed this as completed Jan 13, 2020
@mcdado
Copy link
Author

mcdado commented Jan 13, 2020

eslint/eslint#12782 🤞

@mcdado
Copy link
Author

mcdado commented Jul 9, 2020

https://eslint.org/docs/rules/camelcase

I don't see anything regarding globals. Perhaps take a look at ESLint source code; the tests for the camelcase rule; whether there's a test for ignoring globals.

Well, I landed the feature in eslint, and it got released in 7.4.

Whenever the upgrade will come it would be nice for this option to be included 😊

@mcdado mcdado mentioned this issue Jul 9, 2020
6 tasks
@feross feross reopened this Oct 22, 2020
@feross feross modified the milestones: standard 15, standard 16 Oct 22, 2020
@feross feross changed the title camelcase should not apply to globals Relax rule: Do not enforce camelcase style for global variables (camelcase) Oct 29, 2020
@feross
Copy link
Member

feross commented Oct 29, 2020

This will ship in standard 16

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

3 participants