Skip to content

Commit

Permalink
lint local/camelcase: allow destructure (#36868)
Browse files Browse the repository at this point in the history
* lint local/camelcase: allow destructure

* force rename

* Update build-system/eslint-rules/camelcase.js

Co-authored-by: Ryan Cebulko <ryan@cebulko.com>

* Update build-system/eslint-rules/camelcase.js

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>

Co-authored-by: Ryan Cebulko <ryan@cebulko.com>
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
  • Loading branch information
3 people committed Nov 12, 2021
1 parent 5c8b4ad commit 504411b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion build-system/eslint-rules/camelcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function (context) {
// Excuse membership access, unless we're in the LHS of an assignment.
// This attempts to prevent us from defining new properties with underscores,
// while allowing access to external objects that already have them.
// This mirros google-camelcase's logic.
// This mirrors google-camelcase's logic.
const {parent} = node;
if (parent.type === 'MemberExpression' && parent.property === node) {
const grandParent = parent.parent;
Expand All @@ -46,6 +46,16 @@ module.exports = function (context) {
}
}

// Permit object destructuring, since that is similar to membership access.
// Requires that the key is immediately renamed to a conforming value.
if (
parent.type === 'Property' &&
parent.parent.type === 'ObjectPattern' &&
parent.key === node
) {
return;
}

context.report({
node,
message: `"${node.name}" must use camelCaseCapitalization.`,
Expand Down
1 change: 0 additions & 1 deletion src/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {getBuilders} from './builders';
* @return {import('./types').CompilerResponse}
*/
export function compile(request) {
// eslint-disable-next-line local/camelcase
const {component_versions: versions, document, nodes} = request ?? {};
if (!versions || !(document || nodes)) {
throw new Error(
Expand Down

0 comments on commit 504411b

Please sign in to comment.