From 5726d51069e5cc4a8c9b263dc5507d74eaf8fafc Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Thu, 17 Apr 2025 18:01:41 -0400 Subject: [PATCH 1/7] WIP introduce eslint-plugin-boxel package, with template-missing-invokable rule --- .github/workflows/ci-lint.yaml | 4 + docs/eslint-plugin-boxel-plan.md | 46 + packages/eslint-plugin-boxel/.babelrc | 4 + packages/eslint-plugin-boxel/.gitignore | 4 + packages/eslint-plugin-boxel/README.md | 53 + .../docs/rules/template-missing-invokable.md | 32 + packages/eslint-plugin-boxel/eslint.config.js | 74 + packages/eslint-plugin-boxel/index.js | 22 + .../eslint-plugin-boxel/lib/config/base.js | 25 + .../lib/config/recommended.js | 12 + packages/eslint-plugin-boxel/lib/index.js | 19 + .../lib/recommended-rules.js | 9 + .../lib/rules/template-missing-invokable.js | 102 + packages/eslint-plugin-boxel/package.json | 74 + .../scripts/update-rules.js | 53 + .../rules/template-missing-invokable-test.js | 281 ++ .../eslint-plugin-boxel/vitest.config.mjs | 19 + packages/host/.eslintrc.js | 10 +- packages/host/package.json | 1 + pnpm-lock.yaml | 4277 +++++++++++++++-- 20 files changed, 4613 insertions(+), 508 deletions(-) create mode 100644 docs/eslint-plugin-boxel-plan.md create mode 100644 packages/eslint-plugin-boxel/.babelrc create mode 100644 packages/eslint-plugin-boxel/.gitignore create mode 100644 packages/eslint-plugin-boxel/README.md create mode 100644 packages/eslint-plugin-boxel/docs/rules/template-missing-invokable.md create mode 100644 packages/eslint-plugin-boxel/eslint.config.js create mode 100644 packages/eslint-plugin-boxel/index.js create mode 100644 packages/eslint-plugin-boxel/lib/config/base.js create mode 100644 packages/eslint-plugin-boxel/lib/config/recommended.js create mode 100644 packages/eslint-plugin-boxel/lib/index.js create mode 100644 packages/eslint-plugin-boxel/lib/recommended-rules.js create mode 100644 packages/eslint-plugin-boxel/lib/rules/template-missing-invokable.js create mode 100644 packages/eslint-plugin-boxel/package.json create mode 100644 packages/eslint-plugin-boxel/scripts/update-rules.js create mode 100644 packages/eslint-plugin-boxel/tests/lib/rules/template-missing-invokable-test.js create mode 100644 packages/eslint-plugin-boxel/vitest.config.mjs diff --git a/.github/workflows/ci-lint.yaml b/.github/workflows/ci-lint.yaml index 03047314cf..3565854416 100644 --- a/.github/workflows/ci-lint.yaml +++ b/.github/workflows/ci-lint.yaml @@ -122,3 +122,7 @@ jobs: if: always() run: pnpm run lint working-directory: packages/vscode-boxel-tools + - name: Lint ESLint Plugin + if: always() + run: pnpm run lint + working-directory: packages/eslint-plugin-boxel diff --git a/docs/eslint-plugin-boxel-plan.md b/docs/eslint-plugin-boxel-plan.md new file mode 100644 index 0000000000..d6b125fa0d --- /dev/null +++ b/docs/eslint-plugin-boxel-plan.md @@ -0,0 +1,46 @@ +# Plan for Creating eslint-plugin-boxel + +## 1. Project Setup + +### Create Plugin Directory Structure +- Create directory `/Users/lmelia/p/cardstack/boxel/packages/eslint-plugin-boxel` +- Initialize npm package +- Install necessary dependencies + +## 2. Basic Plugin Configuration + +- Create `index.js` for the main plugin entry point +- Set up plugin configuration +- Create directory structure for rules + +## 3. Initial Rules Development + +- Identify initial ESLint rules specific to Boxel +- Create rule files with implementations +- Add tests for each rule + +## 4. Documentation + +- Create README.md with usage instructions +- Document each rule with examples + +## 5. Integration with Monorepo + +- Update workspace package.json to include the new package +- Update ESLint configurations across the project to use the new plugin +- Add appropriate scripts for development and testing + +## 6. Publishing and Maintenance + +- Set up continuous integration +- Create release process +- Plan for future rule additions + +## Progress Tracking + +- [x] Project setup +- [x] Basic plugin configuration +- [x] Initial rules development +- [x] Documentation +- [ ] Integration with monorepo +- [ ] Publishing setup diff --git a/packages/eslint-plugin-boxel/.babelrc b/packages/eslint-plugin-boxel/.babelrc new file mode 100644 index 0000000000..c16aba5a29 --- /dev/null +++ b/packages/eslint-plugin-boxel/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": [], + "plugins": ["@babel/plugin-proposal-class-properties"] +} diff --git a/packages/eslint-plugin-boxel/.gitignore b/packages/eslint-plugin-boxel/.gitignore new file mode 100644 index 0000000000..7e6a169ae0 --- /dev/null +++ b/packages/eslint-plugin-boxel/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +coverage/ +.DS_Store +*.log diff --git a/packages/eslint-plugin-boxel/README.md b/packages/eslint-plugin-boxel/README.md new file mode 100644 index 0000000000..d45c9aebf6 --- /dev/null +++ b/packages/eslint-plugin-boxel/README.md @@ -0,0 +1,53 @@ +# eslint-plugin-boxel + +ESLint plugin for Boxel-specific rules + +## Installation + +You'll first need to install [ESLint](https://eslint.org/): + +```sh +pnpm i eslint --save-dev +``` + +Next, install `eslint-plugin-boxel`: + +```sh +pnpm install eslint-plugin-boxel --save-dev +``` + +## Usage + +Add `boxel` to the plugins section of your `.eslintrc` configuration file: + +```json +{ + "plugins": ["boxel"] +} +``` + +Then configure the rules you want to use under the rules section: + +```json +{ + "rules": { + "boxel/rule-name": "error" + } +} +``` + +## Rules + + +💼 Configurations enabled in.\ +✅ Set in the `recommended` configuration.\ +🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix). + +| Name                       | Description | 💼 | 🔧 | +| :--------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- | :- | :- | +| [template-missing-invokable](docs/rules/template-missing-invokable.md) | disallow missing helpers, modifiers, or components in \ with auto-fix to import them | ✅ | 🔧 | + + + + +``` diff --git a/packages/eslint-plugin-boxel/docs/rules/template-missing-invokable.md b/packages/eslint-plugin-boxel/docs/rules/template-missing-invokable.md new file mode 100644 index 0000000000..c89d22bf6e --- /dev/null +++ b/packages/eslint-plugin-boxel/docs/rules/template-missing-invokable.md @@ -0,0 +1,32 @@ +# Disallow missing helpers, modifiers, or components in \ with auto-fix to import them (`@cardstack/boxel/template-missing-invokable`) + +💼 This rule is enabled in the ✅ `recommended` config. + +🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). + + + +Auto-fixes missing imports for helpers, modifiers, and components in your \