From d39cbb2be1e0e5caae2de9fd9c88ac441dad37e0 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 25 Oct 2021 10:54:46 +0200 Subject: [PATCH 1/4] build: create own bundle for `@angular/compiler` With this change we create a a package to bundle `@angular/compiler`. This is in preparation for version 13 were the angular packages are only shipped in ESM format however due to limitations in ESLint these cannot be consumed directly. Therefore, we have created a "private" `@angular-eslint/bundled-angular-compiler` package which contains the a CJS bundled version of the `@angular/compiler`. All references to `@angular/compiler` in the code base have been changed to reference this change. --- nx.json | 3 ++ packages/bundled-angular-compiler/README.md | 1 + .../bundled-angular-compiler/package.json | 21 +++++++++++ .../bundled-angular-compiler/project.json | 35 +++++++++++++++++++ .../bundled-angular-compiler/src/index.ts | 6 ++++ .../tsconfig.build.json | 7 ++++ .../bundled-angular-compiler/tsconfig.json | 4 +++ packages/eslint-plugin-template/package.json | 2 +- packages/eslint-plugin-template/project.json | 2 +- .../src/rules/accessibility-alt-text.ts | 5 ++- .../rules/accessibility-elements-content.ts | 2 +- .../src/rules/accessibility-label-for.ts | 2 +- ...essibility-label-has-associated-control.ts | 2 +- .../src/rules/accessibility-table-scope.ts | 2 +- .../src/rules/accessibility-valid-aria.ts | 4 +-- .../src/rules/banana-in-box.ts | 2 +- .../src/rules/click-events-have-key-events.ts | 2 +- .../src/rules/conditional-complexity.ts | 4 +-- .../src/rules/cyclomatic-complexity.ts | 2 +- .../src/rules/eqeqeq.ts | 7 ++-- .../eslint-plugin-template/src/rules/i18n.ts | 9 +++-- .../src/rules/mouse-events-have-key-events.ts | 2 +- .../src/rules/no-any.ts | 2 +- .../src/rules/no-autofocus.ts | 2 +- .../src/rules/no-call-expression.ts | 4 +-- .../src/rules/no-distracting-elements.ts | 2 +- .../src/rules/no-duplicate-attributes.ts | 2 +- .../src/rules/no-negated-async.ts | 5 ++- .../src/rules/no-positive-tabindex.ts | 2 +- .../src/rules/use-track-by-function.ts | 7 ++-- .../src/utils/attributes-comparator.ts | 2 +- .../src/utils/create-eslint-rule.ts | 5 ++- .../src/utils/get-attribute-value.ts | 4 +-- .../src/utils/get-nearest-node-from.ts | 6 ++-- .../src/utils/get-original-attribute-name.ts | 4 +-- .../src/utils/is-child-node-of.ts | 2 +- .../src/utils/is-hidden-from-screen-reader.ts | 2 +- .../src/utils/is-interactive-element/index.ts | 2 +- .../src/utils/is-presentation-role.ts | 2 +- packages/eslint-plugin/package.json | 1 - packages/integration-tests/project.json | 1 + packages/template-parser/package.json | 2 +- packages/template-parser/project.json | 2 +- .../src/convert-source-span-to-loc.ts | 12 +++++-- packages/template-parser/src/index.ts | 8 +++-- packages/utils/package.json | 1 + packages/utils/project.json | 2 +- .../utils/src/eslint-plugin/selector-utils.ts | 2 +- tsconfig.base.json | 6 ++++ workspace.json | 1 + yarn.lock | 7 ++++ 51 files changed, 174 insertions(+), 52 deletions(-) create mode 100644 packages/bundled-angular-compiler/README.md create mode 100644 packages/bundled-angular-compiler/package.json create mode 100644 packages/bundled-angular-compiler/project.json create mode 100644 packages/bundled-angular-compiler/src/index.ts create mode 100644 packages/bundled-angular-compiler/tsconfig.build.json create mode 100644 packages/bundled-angular-compiler/tsconfig.json diff --git a/nx.json b/nx.json index f5bafba74..75aabe17e 100644 --- a/nx.json +++ b/nx.json @@ -74,6 +74,7 @@ "implicitDependencies": [ "integration-tests", "builder", + "bundled-angular-compiler", "eslint-plugin", "eslint-plugin-template", "schematics", @@ -85,6 +86,7 @@ "implicitDependencies": [ "integration-tests", "builder", + "bundled-angular-compiler", "eslint-plugin", "eslint-plugin-template", "schematics", @@ -96,6 +98,7 @@ "implicitDependencies": [ "integration-tests", "builder", + "bundled-angular-compiler", "eslint-plugin", "eslint-plugin-template", "schematics", diff --git a/packages/bundled-angular-compiler/README.md b/packages/bundled-angular-compiler/README.md new file mode 100644 index 000000000..e02c6edda --- /dev/null +++ b/packages/bundled-angular-compiler/README.md @@ -0,0 +1 @@ +# @angular-eslint/bundled-angular-compiler diff --git a/packages/bundled-angular-compiler/package.json b/packages/bundled-angular-compiler/package.json new file mode 100644 index 000000000..dfb37efb2 --- /dev/null +++ b/packages/bundled-angular-compiler/package.json @@ -0,0 +1,21 @@ +{ + "name": "@angular-eslint/bundled-angular-compiler", + "version": "12.5.0", + "description": "A CJS bundled version of @angular/compiler", + "license": "MIT", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/angular-eslint/angular-eslint.git", + "directory": "packages/bundled-angular-compiler" + }, + "devDependencies": { + "@angular/compiler": "12.2.11" + }, + "files": [ + "dist", + "package.json", + "README.md" + ] +} diff --git a/packages/bundled-angular-compiler/project.json b/packages/bundled-angular-compiler/project.json new file mode 100644 index 000000000..69250da44 --- /dev/null +++ b/packages/bundled-angular-compiler/project.json @@ -0,0 +1,35 @@ +{ + "root": "packages/bundled-angular-compiler", + "type": "library", + "targets": { + "build": { + "executor": "@nrwl/workspace:run-commands", + "outputs": ["packages/bundled-angular-compiler/dist"], + "options": { + "cwd": "packages/bundled-angular-compiler", + "parallel": false, + "commands": [ + "npx rimraf ./dist", + "npx microbundle --tsconfig tsconfig.build.json --no-sourcemap --target=node --format=cjs --alias @angular/compiler=node_modules/@angular/compiler/fesm2015/compiler.js" + ] + } + }, + "clean": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "cwd": "packages/bundled-angular-compiler", + "parallel": false, + "commands": ["npx rimraf ./dist"] + } + }, + "typecheck": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "cwd": "packages/bundled-angular-compiler", + "parallel": false, + "commands": ["npx tsc -p tsconfig.json --noEmit"] + } + } + }, + "implicitDependencies": [] +} diff --git a/packages/bundled-angular-compiler/src/index.ts b/packages/bundled-angular-compiler/src/index.ts new file mode 100644 index 000000000..1478d76be --- /dev/null +++ b/packages/bundled-angular-compiler/src/index.ts @@ -0,0 +1,6 @@ +export * from '@angular/compiler'; +export type { + Comment, + Node as R3_Node, +} from '@angular/compiler/src/render3/r3_ast'; +export type { Message } from '@angular/compiler/src/i18n/i18n_ast'; diff --git a/packages/bundled-angular-compiler/tsconfig.build.json b/packages/bundled-angular-compiler/tsconfig.build.json new file mode 100644 index 000000000..b0fced27d --- /dev/null +++ b/packages/bundled-angular-compiler/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist" + }, + "include": ["src"] +} diff --git a/packages/bundled-angular-compiler/tsconfig.json b/packages/bundled-angular-compiler/tsconfig.json new file mode 100644 index 000000000..25367c1f7 --- /dev/null +++ b/packages/bundled-angular-compiler/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.build.json", + "include": ["src"] +} diff --git a/packages/eslint-plugin-template/package.json b/packages/eslint-plugin-template/package.json index 770eca1ef..d582199f3 100644 --- a/packages/eslint-plugin-template/package.json +++ b/packages/eslint-plugin-template/package.json @@ -17,6 +17,7 @@ "LICENSE" ], "dependencies": { + "@angular-eslint/bundled-angular-compiler": "12.5.0", "@typescript-eslint/experimental-utils": "4.28.2", "aria-query": "^4.2.2", "axobject-query": "^2.2.0" @@ -26,7 +27,6 @@ "@types/aria-query": "^4.2.0" }, "peerDependencies": { - "@angular/compiler": ">= 12.0.0 < 13.0.0", "eslint": "*", "typescript": "*" }, diff --git a/packages/eslint-plugin-template/project.json b/packages/eslint-plugin-template/project.json index f7102ffe5..feb2493de 100644 --- a/packages/eslint-plugin-template/project.json +++ b/packages/eslint-plugin-template/project.json @@ -75,5 +75,5 @@ } } }, - "implicitDependencies": ["template-parser"] + "implicitDependencies": ["bundled-angular-compiler", "template-parser"] } diff --git a/packages/eslint-plugin-template/src/rules/accessibility-alt-text.ts b/packages/eslint-plugin-template/src/rules/accessibility-alt-text.ts index 987bbc578..e50b127e1 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-alt-text.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-alt-text.ts @@ -1,4 +1,7 @@ -import type { Node, TmplAstElement } from '@angular/compiler'; +import type { + Node, + TmplAstElement, +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/accessibility-elements-content.ts b/packages/eslint-plugin-template/src/rules/accessibility-elements-content.ts index 8644752c1..b81ccab1e 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-elements-content.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-elements-content.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/accessibility-label-for.ts b/packages/eslint-plugin-template/src/rules/accessibility-label-for.ts index 2262266c3..b1386139b 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-label-for.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-label-for.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/accessibility-label-has-associated-control.ts b/packages/eslint-plugin-template/src/rules/accessibility-label-has-associated-control.ts index 4394894c4..430baf82a 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-label-has-associated-control.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-label-has-associated-control.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/accessibility-table-scope.ts b/packages/eslint-plugin-template/src/rules/accessibility-table-scope.ts index bd08f2bba..8470a5635 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-table-scope.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-table-scope.ts @@ -1,7 +1,7 @@ import type { TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/accessibility-valid-aria.ts b/packages/eslint-plugin-template/src/rules/accessibility-valid-aria.ts index 1e2d9897b..731d849bb 100644 --- a/packages/eslint-plugin-template/src/rules/accessibility-valid-aria.ts +++ b/packages/eslint-plugin-template/src/rules/accessibility-valid-aria.ts @@ -1,4 +1,4 @@ -import type { AST } from '@angular/compiler'; +import type { AST } from '@angular-eslint/bundled-angular-compiler'; import { ASTWithSource, LiteralArray, @@ -6,7 +6,7 @@ import { LiteralPrimitive, TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import type { ARIAProperty, ARIAPropertyDefinition } from 'aria-query'; import { aria } from 'aria-query'; import { diff --git a/packages/eslint-plugin-template/src/rules/banana-in-box.ts b/packages/eslint-plugin-template/src/rules/banana-in-box.ts index 9d9f224a0..48e54f913 100644 --- a/packages/eslint-plugin-template/src/rules/banana-in-box.ts +++ b/packages/eslint-plugin-template/src/rules/banana-in-box.ts @@ -1,4 +1,4 @@ -import type { BoundEventAst } from '@angular/compiler'; +import type { BoundEventAst } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/click-events-have-key-events.ts b/packages/eslint-plugin-template/src/rules/click-events-have-key-events.ts index 7f5399b02..9a471d1a1 100644 --- a/packages/eslint-plugin-template/src/rules/click-events-have-key-events.ts +++ b/packages/eslint-plugin-template/src/rules/click-events-have-key-events.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/conditional-complexity.ts b/packages/eslint-plugin-template/src/rules/conditional-complexity.ts index 7075680b5..42f224954 100644 --- a/packages/eslint-plugin-template/src/rules/conditional-complexity.ts +++ b/packages/eslint-plugin-template/src/rules/conditional-complexity.ts @@ -3,14 +3,14 @@ import type { ASTWithSource, Interpolation, TmplAstBoundAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { Binary, BindingPipe, Conditional, Lexer, Parser, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, ensureTemplateParser, diff --git a/packages/eslint-plugin-template/src/rules/cyclomatic-complexity.ts b/packages/eslint-plugin-template/src/rules/cyclomatic-complexity.ts index 3c49c6e08..2fe0f7356 100644 --- a/packages/eslint-plugin-template/src/rules/cyclomatic-complexity.ts +++ b/packages/eslint-plugin-template/src/rules/cyclomatic-complexity.ts @@ -1,7 +1,7 @@ import type { TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/eqeqeq.ts b/packages/eslint-plugin-template/src/rules/eqeqeq.ts index c31bc564d..b5f369d87 100644 --- a/packages/eslint-plugin-template/src/rules/eqeqeq.ts +++ b/packages/eslint-plugin-template/src/rules/eqeqeq.ts @@ -1,5 +1,8 @@ -import type { AST, Binary } from '@angular/compiler'; -import { ASTWithSource, LiteralPrimitive } from '@angular/compiler'; +import type { AST, Binary } from '@angular-eslint/bundled-angular-compiler'; +import { + ASTWithSource, + LiteralPrimitive, +} from '@angular-eslint/bundled-angular-compiler'; import type { TSESLint } from '@typescript-eslint/experimental-utils'; import { createESLintRule, diff --git a/packages/eslint-plugin-template/src/rules/i18n.ts b/packages/eslint-plugin-template/src/rules/i18n.ts index 06b165cdb..91295cc3c 100644 --- a/packages/eslint-plugin-template/src/rules/i18n.ts +++ b/packages/eslint-plugin-template/src/rules/i18n.ts @@ -6,9 +6,12 @@ import type { TmplAstIcu, TmplAstText, TmplAstTextAttribute, -} from '@angular/compiler'; -import { TmplAstBoundText, TmplAstElement } from '@angular/compiler'; -import type { Message } from '@angular/compiler/src/i18n/i18n_ast'; +} from '@angular-eslint/bundled-angular-compiler'; +import { + TmplAstBoundText, + TmplAstElement, +} from '@angular-eslint/bundled-angular-compiler'; +import type { Message } from '@angular-eslint/bundled-angular-compiler'; import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; import { createESLintRule, diff --git a/packages/eslint-plugin-template/src/rules/mouse-events-have-key-events.ts b/packages/eslint-plugin-template/src/rules/mouse-events-have-key-events.ts index e40bda9e1..ba6886856 100644 --- a/packages/eslint-plugin-template/src/rules/mouse-events-have-key-events.ts +++ b/packages/eslint-plugin-template/src/rules/mouse-events-have-key-events.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import type { TSESLint } from '@typescript-eslint/experimental-utils'; import { createESLintRule, diff --git a/packages/eslint-plugin-template/src/rules/no-any.ts b/packages/eslint-plugin-template/src/rules/no-any.ts index b4129ebc8..19ed9c837 100644 --- a/packages/eslint-plugin-template/src/rules/no-any.ts +++ b/packages/eslint-plugin-template/src/rules/no-any.ts @@ -1,4 +1,4 @@ -import type { MethodCall } from '@angular/compiler'; +import type { MethodCall } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, ensureTemplateParser, diff --git a/packages/eslint-plugin-template/src/rules/no-autofocus.ts b/packages/eslint-plugin-template/src/rules/no-autofocus.ts index fef819fb1..f7aca034d 100644 --- a/packages/eslint-plugin-template/src/rules/no-autofocus.ts +++ b/packages/eslint-plugin-template/src/rules/no-autofocus.ts @@ -1,7 +1,7 @@ import type { TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/no-call-expression.ts b/packages/eslint-plugin-template/src/rules/no-call-expression.ts index 3874be83f..bae4e18a1 100644 --- a/packages/eslint-plugin-template/src/rules/no-call-expression.ts +++ b/packages/eslint-plugin-template/src/rules/no-call-expression.ts @@ -2,8 +2,8 @@ import type { FunctionCall, MethodCall, SafeMethodCall, -} from '@angular/compiler'; -import { TmplAstBoundEvent } from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; +import { TmplAstBoundEvent } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, ensureTemplateParser, diff --git a/packages/eslint-plugin-template/src/rules/no-distracting-elements.ts b/packages/eslint-plugin-template/src/rules/no-distracting-elements.ts index 061be9701..6baeda9aa 100644 --- a/packages/eslint-plugin-template/src/rules/no-distracting-elements.ts +++ b/packages/eslint-plugin-template/src/rules/no-distracting-elements.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/no-duplicate-attributes.ts b/packages/eslint-plugin-template/src/rules/no-duplicate-attributes.ts index ab800c5a4..e434c7f44 100644 --- a/packages/eslint-plugin-template/src/rules/no-duplicate-attributes.ts +++ b/packages/eslint-plugin-template/src/rules/no-duplicate-attributes.ts @@ -3,7 +3,7 @@ import type { TmplAstBoundEvent, TmplAstElement, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/no-negated-async.ts b/packages/eslint-plugin-template/src/rules/no-negated-async.ts index 8b83a3aa4..aa1594bc3 100644 --- a/packages/eslint-plugin-template/src/rules/no-negated-async.ts +++ b/packages/eslint-plugin-template/src/rules/no-negated-async.ts @@ -1,4 +1,7 @@ -import type { BindingPipe, PrefixNot } from '@angular/compiler'; +import type { + BindingPipe, + PrefixNot, +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, ensureTemplateParser, diff --git a/packages/eslint-plugin-template/src/rules/no-positive-tabindex.ts b/packages/eslint-plugin-template/src/rules/no-positive-tabindex.ts index d3cf6ee1f..66f7a2f1c 100644 --- a/packages/eslint-plugin-template/src/rules/no-positive-tabindex.ts +++ b/packages/eslint-plugin-template/src/rules/no-positive-tabindex.ts @@ -2,7 +2,7 @@ import type { ParseSourceSpan, TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/rules/use-track-by-function.ts b/packages/eslint-plugin-template/src/rules/use-track-by-function.ts index a6d4b3b01..8e874f336 100644 --- a/packages/eslint-plugin-template/src/rules/use-track-by-function.ts +++ b/packages/eslint-plugin-template/src/rules/use-track-by-function.ts @@ -1,5 +1,8 @@ -import type { TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler'; -import { TmplAstBoundAttribute } from '@angular/compiler'; +import type { + TmplAstTemplate, + TmplAstTextAttribute, +} from '@angular-eslint/bundled-angular-compiler'; +import { TmplAstBoundAttribute } from '@angular-eslint/bundled-angular-compiler'; import { createESLintRule, getTemplateParserServices, diff --git a/packages/eslint-plugin-template/src/utils/attributes-comparator.ts b/packages/eslint-plugin-template/src/utils/attributes-comparator.ts index 9291d48e8..c2761d14c 100644 --- a/packages/eslint-plugin-template/src/utils/attributes-comparator.ts +++ b/packages/eslint-plugin-template/src/utils/attributes-comparator.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import type { ARIARoleRelationConceptAttribute } from 'aria-query'; import { getAttributeValue } from './get-attribute-value'; diff --git a/packages/eslint-plugin-template/src/utils/create-eslint-rule.ts b/packages/eslint-plugin-template/src/utils/create-eslint-rule.ts index 0327228f1..aa5efa0b2 100644 --- a/packages/eslint-plugin-template/src/utils/create-eslint-rule.ts +++ b/packages/eslint-plugin-template/src/utils/create-eslint-rule.ts @@ -1,4 +1,7 @@ -import type { ParseSourceSpan, TmplAstElement } from '@angular/compiler'; +import type { + ParseSourceSpan, + TmplAstElement, +} from '@angular-eslint/bundled-angular-compiler'; import type { ESLintUtils, TSESLint, diff --git a/packages/eslint-plugin-template/src/utils/get-attribute-value.ts b/packages/eslint-plugin-template/src/utils/get-attribute-value.ts index a2299be35..f7f675f28 100644 --- a/packages/eslint-plugin-template/src/utils/get-attribute-value.ts +++ b/packages/eslint-plugin-template/src/utils/get-attribute-value.ts @@ -1,10 +1,10 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { ASTWithSource, LiteralArray, LiteralMap, LiteralPrimitive, -} from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; import { PROPERTY_READ } from './constants'; import { getOriginalAttributeName } from './get-original-attribute-name'; diff --git a/packages/eslint-plugin-template/src/utils/get-nearest-node-from.ts b/packages/eslint-plugin-template/src/utils/get-nearest-node-from.ts index 1df589bd0..87a576b2e 100644 --- a/packages/eslint-plugin-template/src/utils/get-nearest-node-from.ts +++ b/packages/eslint-plugin-template/src/utils/get-nearest-node-from.ts @@ -1,5 +1,7 @@ -import type { AST } from '@angular/compiler'; -import type { Node } from '@angular/compiler/src/render3/r3_ast'; +import type { + AST, + R3_Node as Node, +} from '@angular-eslint/bundled-angular-compiler'; import type { TSESTree } from '@typescript-eslint/experimental-utils'; import { AST_NODE_TYPES } from '@typescript-eslint/types'; diff --git a/packages/eslint-plugin-template/src/utils/get-original-attribute-name.ts b/packages/eslint-plugin-template/src/utils/get-original-attribute-name.ts index f14711c92..fae076663 100644 --- a/packages/eslint-plugin-template/src/utils/get-original-attribute-name.ts +++ b/packages/eslint-plugin-template/src/utils/get-original-attribute-name.ts @@ -1,8 +1,8 @@ import type { TmplAstBoundAttribute, TmplAstTextAttribute, -} from '@angular/compiler'; -import { TmplAstBoundEvent } from '@angular/compiler'; +} from '@angular-eslint/bundled-angular-compiler'; +import { TmplAstBoundEvent } from '@angular-eslint/bundled-angular-compiler'; /** * Returns the original attribute name. diff --git a/packages/eslint-plugin-template/src/utils/is-child-node-of.ts b/packages/eslint-plugin-template/src/utils/is-child-node-of.ts index 935ee3eb6..2f370d75e 100644 --- a/packages/eslint-plugin-template/src/utils/is-child-node-of.ts +++ b/packages/eslint-plugin-template/src/utils/is-child-node-of.ts @@ -1,4 +1,4 @@ -import { TmplAstElement } from '@angular/compiler'; +import { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; export function isChildNodeOf( ast: TmplAstElement, diff --git a/packages/eslint-plugin-template/src/utils/is-hidden-from-screen-reader.ts b/packages/eslint-plugin-template/src/utils/is-hidden-from-screen-reader.ts index c8328e287..7f7bc36b2 100644 --- a/packages/eslint-plugin-template/src/utils/is-hidden-from-screen-reader.ts +++ b/packages/eslint-plugin-template/src/utils/is-hidden-from-screen-reader.ts @@ -1,4 +1,4 @@ -import { TmplAstElement } from '@angular/compiler'; +import { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { getAttributeValue } from './get-attribute-value'; import { getNearestNodeFrom } from './get-nearest-node-from'; diff --git a/packages/eslint-plugin-template/src/utils/is-interactive-element/index.ts b/packages/eslint-plugin-template/src/utils/is-interactive-element/index.ts index f9f4e56b5..f91ad69f6 100644 --- a/packages/eslint-plugin-template/src/utils/is-interactive-element/index.ts +++ b/packages/eslint-plugin-template/src/utils/is-interactive-element/index.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import type { ARIARoleRelationConcept } from 'aria-query'; import { attributesComparator } from '../attributes-comparator'; import { getDomElements } from '../get-dom-elements'; diff --git a/packages/eslint-plugin-template/src/utils/is-presentation-role.ts b/packages/eslint-plugin-template/src/utils/is-presentation-role.ts index 17ea4482e..dc21c5b31 100644 --- a/packages/eslint-plugin-template/src/utils/is-presentation-role.ts +++ b/packages/eslint-plugin-template/src/utils/is-presentation-role.ts @@ -1,4 +1,4 @@ -import type { TmplAstElement } from '@angular/compiler'; +import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler'; import { getAttributeValue } from './get-attribute-value'; const presentationRoles: ReadonlySet = new Set([ diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 0b4910bde..524aeb92d 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -21,7 +21,6 @@ "@typescript-eslint/experimental-utils": "4.28.2" }, "peerDependencies": { - "@angular/compiler": ">= 12.0.0 < 13.0.0", "eslint": "*", "typescript": "*" }, diff --git a/packages/integration-tests/project.json b/packages/integration-tests/project.json index 526ee376d..fe8df3865 100644 --- a/packages/integration-tests/project.json +++ b/packages/integration-tests/project.json @@ -62,6 +62,7 @@ }, "implicitDependencies": [ "builder", + "bundled-angular-compiler", "eslint-plugin", "eslint-plugin-template", "schematics", diff --git a/packages/template-parser/package.json b/packages/template-parser/package.json index 70aa0e357..971222f72 100644 --- a/packages/template-parser/package.json +++ b/packages/template-parser/package.json @@ -17,10 +17,10 @@ "LICENSE" ], "dependencies": { + "@angular-eslint/bundled-angular-compiler": "12.5.0", "eslint-scope": "^5.1.0" }, "peerDependencies": { - "@angular/compiler": ">= 12.0.0 < 13.0.0", "eslint": "*", "typescript": "*" }, diff --git a/packages/template-parser/project.json b/packages/template-parser/project.json index b978c1597..83c37e0b6 100644 --- a/packages/template-parser/project.json +++ b/packages/template-parser/project.json @@ -40,5 +40,5 @@ } } }, - "implicitDependencies": [] + "implicitDependencies": ["bundled-angular-compiler"] } diff --git a/packages/template-parser/src/convert-source-span-to-loc.ts b/packages/template-parser/src/convert-source-span-to-loc.ts index b4e576415..9d468f9bb 100644 --- a/packages/template-parser/src/convert-source-span-to-loc.ts +++ b/packages/template-parser/src/convert-source-span-to-loc.ts @@ -1,5 +1,13 @@ -import type { Node, ParseSourceSpan, TmplAstElement } from '@angular/compiler'; -import { Element, getHtmlTagDefinition, HtmlParser } from '@angular/compiler'; +import type { + Node, + ParseSourceSpan, + TmplAstElement, +} from '@angular-eslint/bundled-angular-compiler'; +import { + Element, + getHtmlTagDefinition, + HtmlParser, +} from '@angular-eslint/bundled-angular-compiler'; import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; export function convertNodeSourceSpanToLoc( diff --git a/packages/template-parser/src/index.ts b/packages/template-parser/src/index.ts index 5c1df1602..e1158144e 100644 --- a/packages/template-parser/src/index.ts +++ b/packages/template-parser/src/index.ts @@ -1,6 +1,8 @@ -import type { ParseSourceSpan } from '@angular/compiler'; -import { parseTemplate } from '@angular/compiler'; -import type { Comment } from '@angular/compiler/src/render3/r3_ast'; +import type { + ParseSourceSpan, + Comment, +} from '@angular-eslint/bundled-angular-compiler'; +import { parseTemplate } from '@angular-eslint/bundled-angular-compiler'; import type { TSESTree } from '@typescript-eslint/types'; import { Scope, ScopeManager } from 'eslint-scope'; import { diff --git a/packages/utils/package.json b/packages/utils/package.json index 0f6939a37..d62fef2a1 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -15,6 +15,7 @@ "typescript": "*" }, "dependencies": { + "@angular-eslint/bundled-angular-compiler": "12.5.0", "@typescript-eslint/experimental-utils": "4.28.2" } } diff --git a/packages/utils/project.json b/packages/utils/project.json index d08a4413f..984113e72 100644 --- a/packages/utils/project.json +++ b/packages/utils/project.json @@ -28,5 +28,5 @@ } } }, - "implicitDependencies": [] + "implicitDependencies": ["bundled-angular-compiler"] } diff --git a/packages/utils/src/eslint-plugin/selector-utils.ts b/packages/utils/src/eslint-plugin/selector-utils.ts index 03c89f6b9..0124c4f54 100644 --- a/packages/utils/src/eslint-plugin/selector-utils.ts +++ b/packages/utils/src/eslint-plugin/selector-utils.ts @@ -1,4 +1,4 @@ -import { CssSelector } from '@angular/compiler'; +import { CssSelector } from '@angular-eslint/bundled-angular-compiler'; import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; import type { SelectorStyle } from './ast-utils'; import { diff --git a/tsconfig.base.json b/tsconfig.base.json index 75e3729de..bb6c93ef7 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -21,6 +21,12 @@ "paths": { "@angular-eslint/builder": ["packages/builder/dist/index"], "@angular-eslint/builder/*": ["packages/builder/*"], + "@angular-eslint/bundled-angular-compiler": [ + "packages/eslint-plugin/dist/index.esm" + ], + "@angular-eslint/bundled-angular-compiler/*": [ + "packages/eslint-plugin/*" + ], "@angular-eslint/eslint-plugin": ["packages/eslint-plugin/dist/index"], "@angular-eslint/eslint-plugin/*": ["packages/eslint-plugin/*"], "@angular-eslint/eslint-plugin-template": [ diff --git a/workspace.json b/workspace.json index 2d001809c..4e4bf355c 100644 --- a/workspace.json +++ b/workspace.json @@ -2,6 +2,7 @@ "version": 2, "projects": { "builder": "packages/builder", + "bundled-angular-compiler": "packages/bundled-angular-compiler", "eslint-plugin": "packages/eslint-plugin", "eslint-plugin-template": "packages/eslint-plugin-template", "integration-tests": "packages/integration-tests", diff --git a/yarn.lock b/yarn.lock index 1aa353108..38bd484fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -196,6 +196,13 @@ dependencies: tslib "^2.2.0" +"@angular/compiler@12.2.11": + version "12.2.11" + resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-12.2.11.tgz#bed059f42b4290f50d6daa464102a8e2bab9dc1b" + integrity sha512-78b5Uf+79gOKEyF/ixFAGJANNHnhueofSxgToBmJkTTpqTX6Xzdfzw8W+ehpJADp52eBjmZ+rv7b9sgBsiJ1tg== + dependencies: + tslib "^2.2.0" + "@apidevtools/json-schema-ref-parser@9.0.9": version "9.0.9" resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz#d720f9256e3609621280584f2b47ae165359268b" From afe9a75ba2930d39afc7f439241be7682b8d3dcf Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 22 Oct 2021 12:46:05 +0200 Subject: [PATCH 2/4] fix(builder): remove peer dependencies on `@angular/cli` Builders don't require a dependency on the `@angular/cli` to be executed. --- packages/builder/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 783e85ed3..0381852c9 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -22,7 +22,6 @@ "@nrwl/devkit": "12.6.0" }, "peerDependencies": { - "@angular/cli": ">= 12.0.0 < 13.0.0", "eslint": "*", "typescript": "*" }, From 6f392a85d1ea03294190c9e7bdafbb2db534078a Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 25 Oct 2021 10:58:16 +0200 Subject: [PATCH 3/4] docs: update readme to include PR --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 053f510a6..98728d4b9 100644 --- a/README.md +++ b/README.md @@ -815,6 +815,4 @@ If you see a rule below that has **no status** against it, then please feel free -[`pr559`]: https://api.github.com/repos/angular-eslint/angular-eslint/pulls/559 - From c40eaa2b8d2420a8bee4760a6e8e4cbedde501bb Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 25 Oct 2021 11:47:39 +0200 Subject: [PATCH 4/4] fixup! build: create own bundle for `@angular/compiler` --- packages/eslint-plugin-template/project.json | 2 +- packages/integration-tests/publish-to-verdaccio.sh | 4 ++++ packages/template-parser/project.json | 2 +- packages/utils/project.json | 2 +- tsconfig.base.json | 4 ++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/eslint-plugin-template/project.json b/packages/eslint-plugin-template/project.json index feb2493de..f7102ffe5 100644 --- a/packages/eslint-plugin-template/project.json +++ b/packages/eslint-plugin-template/project.json @@ -75,5 +75,5 @@ } } }, - "implicitDependencies": ["bundled-angular-compiler", "template-parser"] + "implicitDependencies": ["template-parser"] } diff --git a/packages/integration-tests/publish-to-verdaccio.sh b/packages/integration-tests/publish-to-verdaccio.sh index a32e82cbd..28cefb74c 100755 --- a/packages/integration-tests/publish-to-verdaccio.sh +++ b/packages/integration-tests/publish-to-verdaccio.sh @@ -35,6 +35,10 @@ cd ./packages/builder npm publish --registry $NPM_REGISTRY cd - +cd ./packages/bundled-angular-compiler +npm publish --registry $NPM_REGISTRY +cd - + cd ./packages/eslint-plugin npm publish --registry $NPM_REGISTRY cd - diff --git a/packages/template-parser/project.json b/packages/template-parser/project.json index 83c37e0b6..b978c1597 100644 --- a/packages/template-parser/project.json +++ b/packages/template-parser/project.json @@ -40,5 +40,5 @@ } } }, - "implicitDependencies": ["bundled-angular-compiler"] + "implicitDependencies": [] } diff --git a/packages/utils/project.json b/packages/utils/project.json index 984113e72..d08a4413f 100644 --- a/packages/utils/project.json +++ b/packages/utils/project.json @@ -28,5 +28,5 @@ } } }, - "implicitDependencies": ["bundled-angular-compiler"] + "implicitDependencies": [] } diff --git a/tsconfig.base.json b/tsconfig.base.json index bb6c93ef7..e92c01c4b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -22,10 +22,10 @@ "@angular-eslint/builder": ["packages/builder/dist/index"], "@angular-eslint/builder/*": ["packages/builder/*"], "@angular-eslint/bundled-angular-compiler": [ - "packages/eslint-plugin/dist/index.esm" + "packages/bundled-angular-compiler/dist/index" ], "@angular-eslint/bundled-angular-compiler/*": [ - "packages/eslint-plugin/*" + "packages/bundled-angular-compiler/*" ], "@angular-eslint/eslint-plugin": ["packages/eslint-plugin/dist/index"], "@angular-eslint/eslint-plugin/*": ["packages/eslint-plugin/*"],