From f3b52b0a968b1c33c727dd112de8624096c6119f Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 27 Jul 2023 13:21:47 +0200 Subject: [PATCH] use custom parser for gts/gjs bonus: * enables type aware lints * prettier eslint plugin (with template tag prettier plugin) will just work for gts/gjs * can detect unused block params in templates * can detect undef vars in PathExpression * can add eslint directive comments in mustache or html disadvantage: * prettier will not work without template tag prettier plugin for gts/gjs files --- .github/workflows/ci.yml | 2 +- lib/config/recommended.js | 12 +- lib/index.js | 8 - lib/parsers/gjs-parser.js | 430 +++ lib/parsers/gts-parser.js | 7 + lib/preprocessors/glimmer.js | 313 -- .../no-empty-glimmer-component-classes.js | 5 +- lib/rules/no-unused-services.js | 26 +- lib/utils/document.js | 10 +- package.json | 13 +- .../gjs-gts-processor-test.js | 137 +- tests/lib/rules-preprocessor/my-component.gts | 0 .../rules-preprocessor/tsconfig.eslint.json | 10 + yarn.lock | 3379 +++++++---------- 14 files changed, 2045 insertions(+), 2307 deletions(-) create mode 100644 lib/parsers/gjs-parser.js create mode 100644 lib/parsers/gts-parser.js delete mode 100644 lib/preprocessors/glimmer.js create mode 100644 tests/lib/rules-preprocessor/my-component.gts create mode 100644 tests/lib/rules-preprocessor/tsconfig.eslint.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76ba9052c6..987166b3ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ ubuntu, windows ] - node-version: [14.x, 16.x, 18.x] + node-version: [16.x, 18.x] steps: - uses: actions/checkout@v3 diff --git a/lib/config/recommended.js b/lib/config/recommended.js index e45976c2ef..06a43f39f7 100644 --- a/lib/config/recommended.js +++ b/lib/config/recommended.js @@ -1,5 +1,4 @@ const rules = require('../recommended-rules'); -const util = require('ember-template-imports/src/util'); module.exports = { root: true, @@ -29,11 +28,12 @@ module.exports = { * on -- and isn't relevant to user-land code. */ { - files: ['**/*.gjs', '**/*.gts'], - processor: 'ember/