feat: add hs-web-team/no-abbreviations rule - #66
Open
davidding wants to merge 2 commits into
Open
Conversation
- Add to configs.recommended at 'warn' - Expand declaration sites: array destructuring, function declaration names - Remove reduce/reduceRight from ARRAY_ITERATION_METHODS (false i exemption) - Flip rule meta recommended: false -> true - Add ./plugin export to package.json - Add tests for new declaration sites; document object destructuring skip - Add warn=minor / error=major versioning convention to CLAUDE.md
davidding
marked this pull request as ready for review
August 24, 2026 10:11
davidding
requested review from
TyStelmach,
alex-117,
cfrisoli,
craigayre,
darkmavis1980,
david-mooney,
denisolvr,
mrndhlovu,
nhorilopchan and
swatinigam
August 24, 2026 10:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI-assisted draft — human review required
Summary
Adds a new
hs-web-team/no-abbreviationsESLint rule to the custom plugin, enforcing the HubSpot JS coding standard to avoid abbreviations.Motivated by
const w = await lintRule(...)flagged in hs-components PR #1651.What it flags
Any identifier shorter than
minLength(default: 2) at a declaration site — variable declarators, function params, arrow params, array destructuring bindings, and function declaration names.Object destructuring shorthand (
const { w } = response) is intentionally not flagged —wmay be an external API property name the developer does not own. The idiomatic fix isconst { w: warning } = response, which is correct but non-obvious enough to leave opt-in.Exemptions (AST-aware, not a flat list)
e,_a,b.sort()/.toSorted()callbacks onlyi.map,.forEach,.filter,.find,.some,.every,.flatMap, …)for/for...of/for...ininitNote:
aandbare only exempt inside inline.sort()/.toSorted()callbacks. Named comparator functions (function compare(a, b) {}) are flagged — prefer(left, right)or(prev, next).Configuration
Roll-out
Added to
configs.recommendedat'warn'— enabled by default for all consumers of this package. No action needed beyond bumping the version.To override severity or add exceptions in a project:
Changes
plugins/hs-web-team/rules/no-abbreviations.js— new rule (array destructuring + function declaration names covered;reduce/reduceRightexcluded from iteration method exemption)plugins/hs-web-team/index.js— registers rule in plugin and adds toconfigs.recommendedat'warn'package.json— adds./pluginexport for direct plugin accesstests/plugins/hs-web-team/no-abbreviations.test.js— 27 passing tests (16 valid, 11 invalid cases)🤖 Generated with Claude Code