@nectary/eslint-plugin
v1.1.0
Published
ESLint plugin for the Nectary monorepo. Two rules.
Downloads
5,155
Keywords
Readme
@nectary/eslint-plugin
ESLint plugin for the Nectary monorepo. Two rules.
Install
pnpm add @nectary/eslint-plugin --save-devRules
@nectary/imports
Checks and autofixes missing or redundant @nectary/components (and friends) imports based on the sinch-* JSX elements present in a file.
plugins: ['@nectary'],
rules: { '@nectary/imports': 'error' }@nectary/observed-attribute-accessor
Requires every entry in a static observedAttributes declaration to have a paired set X / get X accessor on the same class. Without the property setter, el.X = value from consumer code (vanilla JS, Lit .prop=, Vue .prop, React 19 property preference, Storybook controls, imperative test code) becomes a JS expando on the instance, the host's attribute is never updated, and attributeChangedCallback never fires. The custom element silently drops the consumer's intent.
This rule exists because that exact gap caused the accordion-item ellipsis bug fixed across MR !587 and MR !597.
plugins: ['@nectary'],
rules: { '@nectary/observed-attribute-accessor': 'error' }What it checks
For each class with static get observedAttributes() or static observedAttributes = [...], every string literal in the array must have a matching prototype set X and get X method. The acceptable accessor names are:
- The attribute name verbatim (
'foo'→set foo) - The attribute name converted from kebab-case to camelCase (
'icons-version'→set iconsVersion)
What it skips by default
data-*attributes (consumed viadataset).aria-*attributes (typically attribute-only).- HTMLElement-inherited attributes that already have property setters on the prototype chain:
class,contenteditable,dir,draggable,hidden,id,inert,inputmode,lang,role,slot,spellcheck,style,tabindex,title,translate.
Options
['@nectary/observed-attribute-accessor', 'error', {
additionalExempt: ['legacy-attr-name'],
}]additionalExempt — extra attribute names to skip beyond the built-in list. Use sparingly and document why.
Tests
node libs/eslint-plugin/tests/observed-attribute-accessor.test.jsUses ESLint's built-in RuleTester. Exits non-zero on failure.
