Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/release-eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release ESLint Plugin

on:
push:
branches:
- main
paths:
- 'eslint-plugin-blits/**'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install Dependencies
run: npm install

- name: Install monorepo dependencies
run: npm install --workspaces

- name: Run Tests
run: npm run test --workspace=eslint-plugin-blits

- name: Read package.json
run: |
plugin_name=$(node -p "require('./eslint-plugin-blits/package.json').name")
plugin_version=$(node -p "require('./eslint-plugin-blits/package.json').version")
echo "PLUGIN_NAME=$plugin_name" >> $GITHUB_ENV
echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV

- name: Create GitHub Pre Release
run: |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
gh release create eslint-v${{ env.PLUGIN_VERSION }} --prerelease -t "eslint-plugin-blits v${{ env.PLUGIN_VERSION }}" -n "Version ${{ env.PLUGIN_VERSION }} of ${{ env.PLUGIN_NAME }}"
13 changes: 13 additions & 0 deletions eslint-plugin-blits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## v1.0.0

Initial release of `@lightningjs/eslint-plugin-blits`.

- `valid-template-syntax` — reports mismatched tags, unclosed attributes, and other parse errors with line/column positions pointing at the exact token
- `require-single-root-element` — errors when a template has more than one root element
- `only-valid-attributes-for-tags` — errors when a built-in tag (`<Element>`, `<Text>`, `<Layout>`, `<RouterView>`, `<Component>`) receives an attribute it doesn't support, using the Blits attribute schema as the source of truth
- `valid-attribute-value` — validates static values against the attribute schema (enums, numeric ranges, positive/non-negative constraints, percentage strings, regex patterns, and object-form values like `{x: 0.5, y: 0}`)
- `configs.recommended` — ESLint 9 flat config preset with all four rules set to `error`
- ESLint 8 supported; rules work but no preset is available
- `docs/attributes/` — reference pages for all 47 Blits template attributes
59 changes: 59 additions & 0 deletions eslint-plugin-blits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# @lightningjs/eslint-plugin-blits

An ESLint plugin for Blits apps, linting Blits template syntax in JavaScript and TypeScript files.

## Installation

```sh
npm install @lightningjs/eslint-plugin-blits --save-dev
```

## Usage

### ESLint 9 (flat config) — recommended

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

export default [
blits.configs.recommended
]
```

This enables all rules for `.js` and `.ts` files.

### ESLint 8 (legacy config)

Rules work with ESLint 8 but there is no preset — rules must be enabled manually.

```js
// .eslintrc.js
module.exports = {
plugins: ['@lightningjs/blits'],
overrides: [
{
files: ['**/*.js', '**/*.ts'],
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',
},
},
],
}
```

## Supported Rules

| Rule | Description | Recommended | Fixable |
|---|---|---|---|
| [`valid-template-syntax`](./docs/rules/valid-template-syntax.md) | Disallow template syntax errors (mismatched tags, unclosed attributes, etc.) | error | — |
| [`require-single-root-element`](./docs/rules/require-single-root-element.md) | Enforce that templates have exactly one root element | error | — |
| [`only-valid-attributes-for-tags`](./docs/rules/only-valid-attributes-for-tags.md) | Disallow attributes on built-in elements that don't support them | error | — |
| [`valid-attribute-value`](./docs/rules/valid-attribute-value.md) | Enforce that static attribute values match the allowed set | error | — |

## License

Apache-2.0. See the [LICENSE](LICENSE) file for details.
Loading