Skip to content

Release - ESLint plugin - v1.0.0#40

Open
uguraslan wants to merge 18 commits intomainfrom
release/eslint-plugin-blits-v1.0.0
Open

Release - ESLint plugin - v1.0.0#40
uguraslan wants to merge 18 commits intomainfrom
release/eslint-plugin-blits-v1.0.0

Conversation

@uguraslan
Copy link
Collaborator

@uguraslan uguraslan commented Mar 15, 2026

@lightningjs/eslint-plugin-blits is an ESLint plugin specifically created for Blits framework. This initial version lints Blits templates inside JS/TS files via template literals.

PR updates

  • Blits v2 support added. The plugin auto-detects the installed version from package.json and loads the right schema. Use settings: { blits: { version: 2 } } to pin it explicitly.
  • border, rounded, shadow, shader added as v2-only attributes. effects and wordwrap removed.
  • rounded also accepts array form in v2 ([tl, tr, br, bl]).
  • Layout can have most of the attributes that Element can have.
  • $shallow no longer triggers a false positive in valid-template-syntax.
  • scale and mount now accept any numeric value, letterspacing accepts negative values.
  • only-valid-attributes-for-tags now reports unknown attributes on built-in tags (Element, Text, Layout, RouterView). Previously they were silently skipped.
  • slot attribute added to attribute level checks.
  • valid-attribute-value now validates object keys for attributes with a closed key set (color, scale, fit, etc.).

Rules

  • valid-template-syntax — parser errors (mismatched tags, unclosed attributes, etc.)
  • require-single-root-element — templates must have a single root element
  • only-valid-attributes-for-tags — unknown or tag-incompatible attributes on built-in elements
  • valid-attribute-value — validates attribute values against the Blits schema (enums, ranges, numeric constraints, object-form values, regex patterns)

Structure

  • ESLint 9 flat config with configs.recommended preset; ESLint 8 is supported (rules work, no preset)
  • 168 tests via Node's built-in test runner
  • The template parser from the VSCode extension is used
  • data/template-attributes.json is the full attribute schema used by the validation rules
  • docs/attributes/ has per-attribute documentation (47 files)

Test setup

To try this locally in a Blits project before it's on npm, install from the local path:

npm install path/to/blits-dev-tools/eslint-plugin-blits --save-dev

ESLint 9 (flat config)

// eslint.config.js
import blits from '@lightningjs/eslint-plugin-blits'

export default [
  blits.configs.recommended
]

ESLint 8 (legacy config)

// .eslintrc.cjs
module.exports = {
  plugins: ['@lightningjs/blits'],
  rules: {
    '@lightningjs/blits/valid-template-syntax': 'error',
    '@lightningjs/blits/require-single-root-element': 'error',
    '@lightningjs/blits/only-valid-attributes-for-tags': 'error',
    '@lightningjs/blits/valid-attribute-value': 'error',
  },
}

Notes

  • Only built-in tags are validated (Element, Text, Layout, RouterView). User-defined components are not checked.
  • Reactive bindings (:attr) skip scalar validation where static values don't apply.
  • Dynamic values (e.g. alpha="$opacity") are treated as variable references and skipped.
  • It also provides complete documentation for all attributes and all rules defined for ESLint.

Copy link
Collaborator

@suresh-gangumalla suresh-gangumalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants