-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[naming-convention] add a modifier to identify a variable/parameter as having been destructured #2512
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
Comments
You could just as easily write: const browserWindow = electron.BrowserWindow;
// or
const { BrowserWindow: browserWindow } = electron; You have a choice of the name, it's just that the simplest syntax reuses the existing name. Destructuring creates variables. These variables should adhere to your naming convention. Side note that there is currently a bug with destructured names: #2250. |
Right, but variables that I didn't name. If I did name them (because the come from my codebase) then I'll get a warning at the place where they are defined anyway. The Rust developers agree, if that persuades you! Maybe this should be an option. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It doesn't - pattern matching is a bit different. I don't think there's a way to rename the variable there (I don't know anything about rust syntax but I couldn't see it in a quick scan of the docs). Using PascalCase when your naming convention specified camelCase doesn't seem like to egregious of an issue. But consider that ignoring destructuring naming would allow this: const { mY_rId_ICULOUS_ly_$$$_named_variable } = {}; It's hard to draw that line and says "this is acceptable variance". Perhaps we could mark these variables with a modifier, and allow you to reconfigure it as strict as you like? |
There is - pattern matching is very similar to destructuring in Rust.
That sounds like a perfect solution! |
…lobal`, and `destructured` modifiers - add selectors `classProperty`, `objectLiteralProperty`, `typeProperty`, `classMethod`, `objectLiteralMethod`, `typeMethod` Fixes #2239 Fixes #2512 Fixes #2318 Fixes #1477 Big update to add a bunch of stuff. I couldn't be bothered splitting this out into separate PRs.
…lobal`, and `destructured` modifiers - add selectors `classProperty`, `objectLiteralProperty`, `typeProperty`, `classMethod`, `objectLiteralMethod`, `typeMethod` Fixes #2239 Fixes #2512 Fixes #2318 Fixes #1477 Big update to add a bunch of stuff. I couldn't be bothered splitting this out into separate PRs. Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, ignored: y, z = 2}`). Adds the following selectors (self explanatory - just breaking the selectors up): - `classProperty` - `objectLiteralProperty` - `typeProperty` - `classMethod` - `objectLiteralMethod` - `typeMethod` Converts - `property` to a meta selector for `classProperty`, `objectLiteralProperty`, `typeProperty` - `method` to a meta selector for `classMethod`, `objectLiteralMethod`, `typeMethod`
…lobal`, and `destructured` modifiers - add selectors `classProperty`, `objectLiteralProperty`, `typeProperty`, `classMethod`, `objectLiteralMethod`, `typeMethod` Fixes #2239 Fixes #2512 Fixes #2318 Fixes #1477 Big update to add a bunch of stuff. I couldn't be bothered splitting this out into separate PRs. Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, ignored: y, z = 2}`). Adds the following selectors (self explanatory - just breaking the selectors up): - `classProperty` - `objectLiteralProperty` - `typeProperty` - `classMethod` - `objectLiteralMethod` - `typeMethod` Converts - `property` to a meta selector for `classProperty`, `objectLiteralProperty`, `typeProperty` - `method` to a meta selector for `classMethod`, `objectLiteralMethod`, `typeMethod`
…lobal`, and `destructured` Fixes #2239 Fixes #2512 Fixes #2318 Closes #2802 Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, ignored: y, z = 2}`).
…lobal`, and `destructured` Fixes #2239 Fixes #2512 Fixes #2318 Closes #2802 Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
…lobal`, and `destructured` Fixes #2239 Fixes #2512 Fixes #2318 Closes #2802 Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
…lobal`, and `destructured` (#2808) Fixes #2239 Fixes #2512 Fixes #2318 Closes #2802 Adds the following modifiers: - `exported` - matches anything that is exported from the module. - `global` - matches a variable/function declared in the top-level scope. - `destructured` - matches a variable declared via an object destructuring pattern (`const {x, z = 2}`).
Repro
Expected Result
It shouldn't complain about the name of
BrowserWindow
, because I didn't have any choice in the matter.Actual Result
It does complain.
Additional Info
I feel like there should be an option to don't check destructured names at all.
Versions
All latest.
The text was updated successfully, but these errors were encountered: