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

camelcase: Option to ignore imports #12527

kalbert312 opened this issue Nov 4, 2019 · 3 comments · May be fixed by rsumner868/librealsense2.1#1, rsumner868/librealsense#4, O330oei/node#4 or O330oei/node#11


Copy link

@kalbert312 kalbert312 commented Nov 4, 2019

What rule do you want to change?

Does this change cause the rule to produce more or fewer warnings?

How will the change be implemented? (New option, new default behavior, etc.)?

New option: ignoreImports: true/false, default: Debatable. I would say true by default because if the code is in your control, eslint would then only flag the declaration and not where it's imported.
Could possibly accept a string/regexp array to only ignore certain modules.

Existing option: allow (string/regexp array) somehow check these against the module token of an import (ex: import { SomeType } from "react" -> "react") rather than a check on the variable itself. For generated codes/types/etc this will not work well.

Please provide some example code that this change will affect:

import { Some_apolloGenerated_Type } from "./__generated__/graphql-types.ts"; // generated code from apollo codegen

This could be aliased but this code is generated so it's basically futile. Plus it would be hard to come up with aliases for types corresponding to graphql queries/results and their inner types.

What does the rule currently do for this code?
Flags generated types from apollo code gen as violating the rule. These types are dynamically generated based on graphql queries which is the reason for a mix of underscores and camel casing.

What will the rule do after it's changed?
Ignore imports, either selectively or fully.

Are you willing to submit a pull request to implement this change?

Copy link

@kaicataldo kaicataldo commented Nov 5, 2019

I think adding an ignoreImports option similar to ignoreDestructuring makes sense. I don’t think it makes sense to make allow match the module import path - that feels confusing, given how it behaves now.

Copy link

@g-plane g-plane commented Nov 5, 2019

So, should we treat it as a bug or an enhancement?

Copy link

@kaicataldo kaicataldo commented Nov 5, 2019

I don't think this is a bug - it looks like everything is working as intended. I believe this is a rule enhancement request.

g-plane added a commit that referenced this issue Nov 5, 2019
@g-plane g-plane self-assigned this Nov 6, 2019
ilyavolodin added a commit that referenced this issue Nov 10, 2019
* New: add option for camelcase (fixes #12527)

* Docs: add docs about `ignoreImports`

* Chore: add more tests

* Docs: add notice
@eslint eslint bot locked and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.