Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 }}"
21 changes: 21 additions & 0 deletions eslint-plugin-blits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
- Blits v2 support — auto-detects version from `package.json`, loads matching attribute schema. Use `settings: { blits: { version: 2 } }` to pin explicitly
- `border`, `rounded`, `shadow`, `shader` added as v2-only attributes. `effects` and `wordwrap` removed in v2
- `rounded` also accepts array form `[tl, tr, br, bl]` in v2
- `slot` attribute added to schema
- `Layout` added to valid tags for `w`, `h`, `width`, `height`, `clipping`, `overflow`
- `valid-attribute-value` now validates object keys for attributes with a closed key set (`color`, `scale`, `mount`, `pivot`, `fit`, etc.)
- `scale` and `mount` accept any numeric value, `letterspacing` accepts negative values
- `$shallow` no longer triggers a false positive in `valid-template-syntax`
90 changes: 90 additions & 0 deletions eslint-plugin-blits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# @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 | — |

## Blits version

The plugin automatically detects which version of Blits your project uses by reading `package.json` and adjusts rule behavior accordingly. No configuration is needed in most cases. If Blits is not listed in `package.json`, version 2 is assumed.

To pin explicitly (useful when the version cannot be detected or you want to be explicit):

**ESLint 9 (flat config):**
```js
// eslint.config.js
import blits from '@lightningjs/eslint-plugin-blits'

export default [
{
settings: { blits: { version: 2 } },
...blits.configs.recommended,
}
]
```

**ESLint 8 (legacy config):**
```js
// .eslintrc.js
module.exports = {
settings: { blits: { version: 2 } },
plugins: ['@lightningjs/blits'],
rules: { ... }
}
```

Accepted values: `1`, `2`, or `'detect'` (same as omitting — triggers auto-detection).

## License

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