From 3861ec71c196cb00e5741c41fdadf2e203f32bcb Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Sat, 7 Jun 2025 01:29:12 -0700 Subject: [PATCH 1/2] feat: init v2 --- .ember-cli | 9 - .eslintignore | 25 - .eslintrc.js | 68 - .github/workflows/ci.yml | 80 +- .github/workflows/push-dist.yml | 34 + .gitignore | 37 +- .npmignore | 46 - .prettierignore | 24 +- .prettierrc.cjs | 14 + .prettierrc.js | 5 - .stylelintignore | 2 + .stylelintrc.mjs | 7 + .template-lintrc.js => .template-lintrc.cjs | 1 + .try.mjs | 63 + .watchmanconfig | 3 - CONTRIBUTING.md | 21 +- LICENSE.md | 2 +- addon-main.cjs | 4 + addon-test-support/index.ts | 24 - addon/.gitkeep | 0 app/.gitkeep | 0 babel.config.cjs | 45 + babel.publish.config.cjs | 31 + config/ember-cli-update.json | 21 + config/ember-try-typescript.js | 39 - config/ember-try.js | 62 - config/environment.js | 5 - ember-cli-build.js | 28 - eslint.config.mjs | 146 + node-tests/fixtures/violations.json | 755 +- node-tests/setup-middleware-test.js | 3 +- package.json | 175 +- pnpm-lock.yaml | 8930 ++++++++--------- rollup.config.mjs | 75 + .../cli-options-filter.ts | 0 index.js => src/index.ts | 2 +- src/template-registry.ts | 10 + src/test-support.ts | 30 + .../test-support}/audit.ts | 15 +- .../test-support}/cli-options.ts | 0 .../test-support}/format-violation.ts | 4 +- .../test-support}/logger.ts | 1 + .../test-support}/performance.ts | 3 +- .../test-support}/reporter.ts | 15 +- .../test-support}/run-options.ts | 8 +- .../test-support}/setup-console-logger.ts | 2 +- .../test-support}/setup-global-a11y-hooks.ts | 18 +- .../setup-middleware-reporter.ts | 19 +- .../test-support}/setup-qunit.ts | 0 .../test-support}/should-force-audit.ts | 2 +- .../test-support}/types/index.d.ts | 0 .../test-support}/use-middleware-reporter.ts | 2 +- testem.cjs | 26 + testem.js | 23 - tests/acceptance/a11y-audit-test.ts | 4 +- tests/acceptance/reporter-test.ts | 7 +- .../setup-global-a11y-hooks-test.ts | 17 +- .../setup-middleware-reporter-test.ts | 6 +- tests/dummy/app/app.js | 12 - tests/dummy/app/components/.gitkeep | 0 tests/dummy/app/components/axe-component.hbs | 1 - .../app/components/passing-component.hbs | 2 - .../app/components/violations-grid-item.hbs | 12 - .../app/components/violations-grid-item.js | 6 - tests/dummy/app/components/x-paragraph.hbs | 1 - tests/dummy/app/components/x-paragraph.js | 6 - tests/dummy/app/config/environment.d.ts | 16 - tests/dummy/app/controllers/.gitkeep | 0 tests/dummy/app/helpers/.gitkeep | 0 tests/dummy/app/index.html | 25 - tests/dummy/app/models/.gitkeep | 0 tests/dummy/app/resolver.js | 3 - tests/dummy/app/router.js | 12 - tests/dummy/app/routes/.gitkeep | 0 tests/dummy/app/routes/ignored-image-alt.js | 3 - tests/dummy/app/routes/index.js | 3 - tests/dummy/app/routes/violations.js | 3 - tests/dummy/app/styles/app.css | 10 - .../app/styles/components/_components.scss | 5 - tests/dummy/app/styles/pages/_pages.scss | 1 - tests/dummy/app/styles/typography/_fonts.scss | 10 - .../app/styles/typography/_typography.scss | 2 - tests/dummy/app/templates/application.hbs | 13 - .../dummy/app/templates/ignored-image-alt.hbs | 2 - tests/dummy/app/templates/violations.hbs | 46 - .../img/empire-state-building-moonlight.png | Bin tests/dummy/config/ember-cli-update.json | 21 - tests/dummy/config/environment.js | 56 - tests/dummy/config/optional-features.json | 6 - tests/dummy/config/targets.js | 11 - tests/dummy/public/robots.txt | 3 - tests/dummy/registry.ts | 24 + tests/dummy/{app => }/styles/app.scss | 4 +- .../{app => }/styles/components/_button.scss | 2 +- .../dummy/styles/components/_components.scss | 5 + .../{app => }/styles/components/_image.scss | 0 .../styles/components/_menu-link-item.scss | 4 +- .../styles/components/_radio-track.scss | 35 +- .../components/_violations-grid-item.scss | 4 +- tests/dummy/{app => }/styles/globals.scss | 14 +- .../styles/object-patterns/_content-box.scss | 2 +- .../styles/object-patterns/_menu-link.scss | 0 .../object-patterns/_object-patterns.scss | 4 +- tests/dummy/styles/pages/_pages.scss | 1 + .../{app => }/styles/pages/_violations.scss | 14 +- tests/dummy/styles/typography/_fonts.scss | 10 + .../styles/typography/_headings.scss | 2 +- .../dummy/styles/typography/_typography.scss | 2 + .../styles/utilities/_utilities.scss | 3 + .../styles/variables/_variables.scss | 27 +- tests/dummy/templates/application.gts | 18 + tests/dummy/templates/ignored-image-alt.gts | 4 + tests/dummy/templates/violations.gts | 129 + tests/fixtures/violations.json | 755 +- tests/helpers/.gitkeep | 0 tests/helpers/index.ts | 27 + tests/index.html | 27 +- tests/integration/.gitkeep | 0 ...etup-global-a11y-hooks-for-render-test.gts | 19 +- tests/integration/helpers/a11y-audit-test.gts | 28 +- tests/test-helper.js | 14 - tests/test-helper.ts | 42 + tests/unit/.gitkeep | 0 tests/unit/audit-test.ts | 37 +- tests/unit/calculate-updated-href-test.ts | 4 +- tests/unit/format-violation-test.ts | 25 +- tests/unit/get-current-route-name-test.ts | 4 +- tsconfig.json | 53 +- tsconfig.publish.json | 25 + types/dummy/index.d.ts | 0 types/ember-debug.d.ts | 35 - types/ember-get-config.d.ts | 1 - types/global.d.ts | 6 - unpublished-development-types/index.d.ts | 14 + vite.config.mjs | 32 + 135 files changed, 5588 insertions(+), 7157 deletions(-) delete mode 100644 .ember-cli delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js create mode 100644 .github/workflows/push-dist.yml delete mode 100644 .npmignore create mode 100644 .prettierrc.cjs delete mode 100644 .prettierrc.js create mode 100644 .stylelintignore create mode 100644 .stylelintrc.mjs rename .template-lintrc.js => .template-lintrc.cjs (64%) create mode 100644 .try.mjs delete mode 100644 .watchmanconfig create mode 100644 addon-main.cjs delete mode 100644 addon-test-support/index.ts delete mode 100644 addon/.gitkeep delete mode 100644 app/.gitkeep create mode 100644 babel.config.cjs create mode 100644 babel.publish.config.cjs create mode 100644 config/ember-cli-update.json delete mode 100644 config/ember-try-typescript.js delete mode 100644 config/ember-try.js delete mode 100644 config/environment.js delete mode 100644 ember-cli-build.js create mode 100644 eslint.config.mjs create mode 100644 rollup.config.mjs rename cli-options-filter.js => src/cli-options-filter.ts (100%) rename index.js => src/index.ts (97%) create mode 100644 src/template-registry.ts create mode 100644 src/test-support.ts rename {addon-test-support => src/test-support}/audit.ts (89%) rename {addon-test-support => src/test-support}/cli-options.ts (100%) rename {addon-test-support => src/test-support}/format-violation.ts (89%) rename {addon-test-support => src/test-support}/logger.ts (99%) rename {addon-test-support => src/test-support}/performance.ts (95%) rename {addon-test-support => src/test-support}/reporter.ts (75%) rename {addon-test-support => src/test-support}/run-options.ts (90%) rename {addon-test-support => src/test-support}/setup-console-logger.ts (83%) rename {addon-test-support => src/test-support}/setup-global-a11y-hooks.ts (80%) rename {addon-test-support => src/test-support}/setup-middleware-reporter.ts (90%) rename {addon-test-support => src/test-support}/setup-qunit.ts (100%) rename {addon-test-support => src/test-support}/should-force-audit.ts (96%) rename {addon-test-support => src/test-support}/types/index.d.ts (100%) rename {addon-test-support => src/test-support}/use-middleware-reporter.ts (87%) create mode 100644 testem.cjs delete mode 100644 testem.js delete mode 100644 tests/dummy/app/app.js delete mode 100644 tests/dummy/app/components/.gitkeep delete mode 100644 tests/dummy/app/components/axe-component.hbs delete mode 100644 tests/dummy/app/components/passing-component.hbs delete mode 100644 tests/dummy/app/components/violations-grid-item.hbs delete mode 100644 tests/dummy/app/components/violations-grid-item.js delete mode 100644 tests/dummy/app/components/x-paragraph.hbs delete mode 100644 tests/dummy/app/components/x-paragraph.js delete mode 100644 tests/dummy/app/config/environment.d.ts delete mode 100644 tests/dummy/app/controllers/.gitkeep delete mode 100644 tests/dummy/app/helpers/.gitkeep delete mode 100644 tests/dummy/app/index.html delete mode 100644 tests/dummy/app/models/.gitkeep delete mode 100644 tests/dummy/app/resolver.js delete mode 100644 tests/dummy/app/router.js delete mode 100644 tests/dummy/app/routes/.gitkeep delete mode 100644 tests/dummy/app/routes/ignored-image-alt.js delete mode 100644 tests/dummy/app/routes/index.js delete mode 100644 tests/dummy/app/routes/violations.js delete mode 100644 tests/dummy/app/styles/app.css delete mode 100644 tests/dummy/app/styles/components/_components.scss delete mode 100644 tests/dummy/app/styles/pages/_pages.scss delete mode 100644 tests/dummy/app/styles/typography/_fonts.scss delete mode 100644 tests/dummy/app/styles/typography/_typography.scss delete mode 100644 tests/dummy/app/templates/application.hbs delete mode 100644 tests/dummy/app/templates/ignored-image-alt.hbs delete mode 100644 tests/dummy/app/templates/violations.hbs rename tests/dummy/{public => }/assets/img/empire-state-building-moonlight.png (100%) delete mode 100644 tests/dummy/config/ember-cli-update.json delete mode 100644 tests/dummy/config/environment.js delete mode 100644 tests/dummy/config/optional-features.json delete mode 100644 tests/dummy/config/targets.js delete mode 100644 tests/dummy/public/robots.txt create mode 100644 tests/dummy/registry.ts rename tests/dummy/{app => }/styles/app.scss (82%) rename tests/dummy/{app => }/styles/components/_button.scss (92%) create mode 100644 tests/dummy/styles/components/_components.scss rename tests/dummy/{app => }/styles/components/_image.scss (100%) rename tests/dummy/{app => }/styles/components/_menu-link-item.scss (92%) rename tests/dummy/{app => }/styles/components/_radio-track.scss (89%) rename tests/dummy/{app => }/styles/components/_violations-grid-item.scss (87%) rename tests/dummy/{app => }/styles/globals.scss (54%) rename tests/dummy/{app => }/styles/object-patterns/_content-box.scss (82%) rename tests/dummy/{app => }/styles/object-patterns/_menu-link.scss (100%) rename tests/dummy/{app => }/styles/object-patterns/_object-patterns.scss (87%) create mode 100644 tests/dummy/styles/pages/_pages.scss rename tests/dummy/{app => }/styles/pages/_violations.scss (89%) create mode 100644 tests/dummy/styles/typography/_fonts.scss rename tests/dummy/{app => }/styles/typography/_headings.scss (73%) create mode 100644 tests/dummy/styles/typography/_typography.scss rename tests/dummy/{app => }/styles/utilities/_utilities.scss (98%) rename tests/dummy/{app => }/styles/variables/_variables.scss (63%) create mode 100644 tests/dummy/templates/application.gts create mode 100644 tests/dummy/templates/ignored-image-alt.gts create mode 100644 tests/dummy/templates/violations.gts delete mode 100644 tests/helpers/.gitkeep create mode 100644 tests/helpers/index.ts delete mode 100644 tests/integration/.gitkeep delete mode 100644 tests/test-helper.js create mode 100644 tests/test-helper.ts delete mode 100644 tests/unit/.gitkeep create mode 100644 tsconfig.publish.json delete mode 100644 types/dummy/index.d.ts delete mode 100644 types/ember-debug.d.ts delete mode 100644 types/ember-get-config.d.ts delete mode 100644 types/global.d.ts create mode 100644 unpublished-development-types/index.d.ts create mode 100644 vite.config.mjs diff --git a/.ember-cli b/.ember-cli deleted file mode 100644 index ee64cfed..00000000 --- a/.ember-cli +++ /dev/null @@ -1,9 +0,0 @@ -{ - /** - Ember CLI sends analytics information by default. The data is completely - anonymous, but there are times when you might want to disable this behavior. - - Setting `disableAnalytics` to true will prevent any data from being sent. - */ - "disableAnalytics": false -} diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d474a40b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,25 +0,0 @@ -# unconventional js -/blueprints/*/files/ -/vendor/ - -# compiled output -/dist/ -/tmp/ - -# dependencies -/bower_components/ -/node_modules/ - -# misc -/coverage/ -!.* -.*/ -.eslintcache - -# ember-try -/.node_modules.ember-try/ -/bower.json.ember-try -/npm-shrinkwrap.json.ember-try -/package.json.ember-try -/package-lock.json.ember-try -/yarn.lock.ember-try diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b1150c46..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,68 +0,0 @@ -module.exports = { - root: true, - parser: 'babel-eslint', - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - ecmaFeatures: { - legacyDecorators: true, - }, - }, - plugins: ['ember'], - extends: [ - 'eslint:recommended', - 'plugin:ember/recommended', - 'plugin:prettier/recommended', - ], - env: { - browser: true, - }, - globals: { - axe: false, - }, - rules: {}, - overrides: [ - // node files - { - files: [ - './.eslintrc.js', - './.prettierrc.js', - './.template-lintrc.js', - './cli-options-filter.js', - './ember-cli-build.js', - './index.js', - './testem.js', - './blueprints/*/index.js', - './config/**/*.js', - './node-tests/**/*.js', - './tests/dummy/config/**/*.js', - ], - parserOptions: { - sourceType: 'script', - }, - env: { - browser: false, - node: true, - }, - plugins: ['node'], - extends: ['plugin:node/recommended'], - }, - { - // typescript files - files: ['**/*.ts'], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - rules: { - 'no-unused-vars': 'off', - '@typescript-eslint/no-unused-vars': 'error', - 'no-redeclare': 'off', - '@typescript-eslint/no-redeclare': ['error'], - }, - }, - { - // test files - files: ['tests/**/*-test.{js,ts}'], - extends: ['plugin:qunit/recommended'], - }, - ], -}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c2d0a4e..edc46e20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,10 @@ concurrency: cancel-in-progress: true jobs: - test: - name: 'Tests' + lint: + name: "Lints" runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -29,14 +30,13 @@ jobs: run: pnpm install - name: Lint run: pnpm lint - - name: Run Ember Tests - run: pnpm test:ember - - name: Run Node Tests - run: pnpm test:node - floating: - name: 'Floating Dependencies' + test: + name: "Tests" runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 @@ -46,30 +46,19 @@ jobs: node-version: 18 cache: pnpm - name: Install Dependencies - run: pnpm install --no-lockfile + run: pnpm install --frozen-lockfile - name: Run Tests - run: pnpm test:ember - - name: Run Node Tests - run: pnpm test:node + run: pnpm test + # For the Try Scenarios + - id: set-matrix + run: | + echo "matrix=$(pnpm -s dlx @embroider/try list)" >> $GITHUB_OUTPUT + - try-scenarios: - name: ${{ matrix.try-scenario }} - timeout-minutes: 15 + floating: + name: "Floating Dependencies" runs-on: ubuntu-latest - needs: 'test' - - strategy: - fail-fast: false - matrix: - try-scenario: - - ember-lts-4.4 - - ember-lts-4.8 - - ember-lts-4.12 - - ember-release - - ember-beta - - ember-canary - - embroider-safe - - embroider-optimized + timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -79,24 +68,18 @@ jobs: node-version: 18 cache: pnpm - name: Install Dependencies - run: pnpm install + run: pnpm install --no-lockfile - name: Run Tests - run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }} + run: pnpm test - typescript-compatibility: - name: Type checking - ${{ matrix.typescript-scenario }} + try-scenarios: + name: ${{ matrix.name }} runs-on: ubuntu-latest - needs: 'test' - + needs: "test" + timeout-minutes: 10 strategy: fail-fast: false - matrix: - typescript-scenario: - - typescript-4.2 - - typescript-4.3 - - typescript-4.4 - - typescript-4.5 - - typescript-next + matrix: ${{fromJson(needs.test.outputs.matrix)}} steps: - uses: actions/checkout@v4 @@ -105,7 +88,14 @@ jobs: with: node-version: 18 cache: pnpm + - name: Apply Scenario + run: | + pnpm dlx @embroider/try apply ${{ matrix.name }} + - name: Install Dependencies - run: pnpm install - - name: Type checking - run: ./node_modules/.bin/ember try:one --config-path="./config/ember-try-typescript.js" ${{ matrix.typescript-scenario }} + run: pnpm install --no-lockfile + - name: Run Tests + run: | + pnpm test + + env: ${{ matrix.env }} diff --git a/.github/workflows/push-dist.yml b/.github/workflows/push-dist.yml new file mode 100644 index 00000000..65d296b8 --- /dev/null +++ b/.github/workflows/push-dist.yml @@ -0,0 +1,34 @@ +# Because this library needs to be built, +# we can't easily point package.json files at the git repo for easy cross-repo testing. +# +# This workflow brings back that capability by placing the compiled assets on a "dist" branch +# (configurable via the "branch" option below) +name: Push dist + +on: + push: + branches: + - main + - master + +jobs: + push-dist: + name: Push dist + permissions: + contents: write + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: pnpm + - name: Install Dependencies + run: pnpm install --frozen-lockfile + - uses: kategengler/put-built-npm-package-contents-on-branch@v2.0.0 + with: + branch: dist + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9bab45af..f6626a79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,16 @@ -# See https://help.github.com/ignore-files/ for more about ignoring files. - # compiled output -/dist/ -/tmp/ +dist/ +declarations/ -# dependencies -/bower_components/ -/node_modules/ +# from scenarios +tmp/ +config/optional-features.json +ember-cli-build.js -# misc -/.env* -/.pnp* -/.sass-cache -/.eslintcache -/connect.lock -/coverage/ -/libpeerconnection.log -/npm-debug.log* -/testem.log -/yarn-error.log +# npm/pnpm/yarn pack output +*.tgz -# ember-try -/.node_modules.ember-try/ -/bower.json.ember-try -/npm-shrinkwrap.json.ember-try -/package.json.ember-try -/package-lock.json.ember-try -/yarn.lock.ember-try +# deps & caches +node_modules/ +.eslintcache +.prettiercache diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 6af73a48..00000000 --- a/.npmignore +++ /dev/null @@ -1,46 +0,0 @@ -# compiled output -/dist/ -/tmp/ - -# dependencies -/bower_components/ - -# misc -/.bowerrc -/.editorconfig -/.ember-cli -/.env* -/.eslintcache -/.eslintignore -/.eslintrc.js -/.git/ -/.github/ -/.gitignore -/.prettierignore -/.prettierrc.js -/.template-lintrc.js -/.travis.yml -/.watchmanconfig -/bower.json -/config/ember-try.js -/CONTRIBUTING.md -/ember-cli-build.js -/testem.js -/tests/ -/node-tests/ -/yarn-error.log -/yarn.lock -.gitkeep - -# ember-try -/.node_modules.ember-try/ -/bower.json.ember-try -/npm-shrinkwrap.json.ember-try -/package.json.ember-try -/package-lock.json.ember-try -/yarn.lock.ember-try - -# custom -config/ember-try-typescript.js -/docs/ -/RELEASE.md diff --git a/.prettierignore b/.prettierignore index 4178fd57..95e65602 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,25 +1,15 @@ # unconventional js /blueprints/*/files/ -/vendor/ # compiled output /dist/ -/tmp/ - -# dependencies -/bower_components/ -/node_modules/ +/declarations/ # misc /coverage/ -!.* -.eslintcache -.lint-todo/ - -# ember-try -/.node_modules.ember-try/ -/bower.json.ember-try -/npm-shrinkwrap.json.ember-try -/package.json.ember-try -/package-lock.json.ember-try -/yarn.lock.ember-try +pnpm-lock.yaml +config/ember-cli-update.json +*.yaml +*.yml +*.md +*.html diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 00000000..8e62a451 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + plugins: ['prettier-plugin-ember-template-tag'], + overrides: [ + { + files: '*.{js,gjs,ts,gts,mjs,mts,cjs,cts}', + options: { + singleQuote: true, + templateSingleQuote: false, + }, + }, + ], +}; diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 534e6d35..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - singleQuote: true, -}; diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 00000000..3725ea10 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,2 @@ +# compiled output +/dist/ diff --git a/.stylelintrc.mjs b/.stylelintrc.mjs new file mode 100644 index 00000000..67af435d --- /dev/null +++ b/.stylelintrc.mjs @@ -0,0 +1,7 @@ +export default { + extends: ['stylelint-config-standard-scss'], + rules: { + 'selector-class-pattern': null, + 'scss/dollar-variable-pattern': null, + }, +}; diff --git a/.template-lintrc.js b/.template-lintrc.cjs similarity index 64% rename from .template-lintrc.js rename to .template-lintrc.cjs index f35f61c7..2fedce2c 100644 --- a/.template-lintrc.js +++ b/.template-lintrc.cjs @@ -2,4 +2,5 @@ module.exports = { extends: 'recommended', + checkHbsTemplateLiterals: false, }; diff --git a/.try.mjs b/.try.mjs new file mode 100644 index 00000000..484e974f --- /dev/null +++ b/.try.mjs @@ -0,0 +1,63 @@ +export default scenarios(); + +function scenarios() { + return { + scenarios: [ + compatEmberScenario('ember-lts-5.8', '~5.4.0'), + compatEmberScenario('ember-lts-5.12', '~5.12.0'), + emberScenario('~6.4.0'), + emberScenario('latest'), + emberScenario('beta'), + emberScenario('alpha'), + ], + }; +} + +function emberScenario(tag) { + return { + name: `ember-${tag}`, + npm: { + devDependencies: { + 'ember-source': `npm:ember-source@${tag}`, + }, + }, + }; +} + +function emberCliBuildJS() { + return `const EmberApp = require('ember-cli/lib/broccoli/ember-app'); +const { compatBuild } = require('@embroider/compat'); +module.exports = async function (defaults) { + const { buildOnce } = await import('@embroider/vite'); + let app = new EmberApp(defaults); + return compatBuild(app, buildOnce); +};`; +} + +function compatEmberScenario(name, emberVersion) { + return { + name, + npm: { + devDependencies: { + 'ember-source': emberVersion, + '@embroider/compat': '^4.0.3', + 'ember-cli': '^5.12.0', + 'ember-auto-import': '^2.10.0', + '@ember/optional-features': '^2.2.0', + }, + }, + env: { + ENABLE_COMPAT_BUILD: true, + }, + files: { + 'ember-cli-build.js': emberCliBuildJS(), + 'config/optional-features.json': JSON.stringify({ + 'application-template-wrapper': false, + 'default-async-observers': true, + 'jquery-integration': false, + 'template-only-glimmer-components': true, + 'no-implicit-route-model': true, + }), + }, + }; +} diff --git a/.watchmanconfig b/.watchmanconfig deleted file mode 100644 index e7834e3e..00000000 --- a/.watchmanconfig +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ignore_dirs": ["tmp", "dist"] -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc05be8e..02a81e6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,18 +8,21 @@ ## Linting -* `pnpm lint` -* `pnpm lint:fix` +- `pnpm lint` +- `pnpm lint:fix` + +## Building the addon + +- `pnpm build` ## Running tests -- `ember test` – Runs the test suite on the current Ember version -- `ember test --server` – Runs the test suite in "watch mode" -- `ember try:each` – Runs the test suite against multiple Ember versions +- `pnpm test` – Runs the test suite on the current Ember version +- `pnpm test:watch` – Runs the test suite in "watch mode" -## Running the dummy application +## Running the test application -- `ember serve` -- Visit the dummy application at [http://localhost:4200](http://localhost:4200). +- `pnpm start` +- Visit the test application at [http://localhost:4200](http://localhost:4200). -For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). +For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/). diff --git a/LICENSE.md b/LICENSE.md index 7b6573f5..8ba573fc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 +Copyright (c) 2025 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/addon-main.cjs b/addon-main.cjs new file mode 100644 index 00000000..f868d6b9 --- /dev/null +++ b/addon-main.cjs @@ -0,0 +1,4 @@ +'use strict'; + +const { addonV1Shim } = require('@embroider/addon-shim'); +module.exports = addonV1Shim(__dirname); diff --git a/addon-test-support/index.ts b/addon-test-support/index.ts deleted file mode 100644 index 55a86956..00000000 --- a/addon-test-support/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -export { default as a11yAudit } from './audit'; -export { setRunOptions, getRunOptions } from './run-options'; -export { setEnableA11yAudit, shouldForceAudit } from './should-force-audit'; -export { useMiddlewareReporter } from './use-middleware-reporter'; -export { - setupGlobalA11yHooks, - teardownGlobalA11yHooks, - DEFAULT_A11Y_TEST_HELPER_NAMES, -} from './setup-global-a11y-hooks'; -export { - setCustomReporter, - DEFAULT_REPORTER as _DEFAULT_REPORTER, -} from './reporter'; -export { - TEST_SUITE_RESULTS as _TEST_SUITE_RESULTS, - middlewareReporter as _middlewareReporter, - pushTestResult as _pushTestResult, - setupMiddlewareReporter, -} from './setup-middleware-reporter'; -export { storeResults, printResults } from './logger'; -export { setupConsoleLogger } from './setup-console-logger'; -export { setupQUnitA11yAuditToggle } from './setup-qunit'; - -export type { InvocationStrategy, A11yAuditReporter } from './types'; diff --git a/addon/.gitkeep b/addon/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/.gitkeep b/app/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/babel.config.cjs b/babel.config.cjs new file mode 100644 index 00000000..cb74ca8d --- /dev/null +++ b/babel.config.cjs @@ -0,0 +1,45 @@ +const { buildMacros } = require('@embroider/macros/babel'); + +const { + babelCompatSupport, + templateCompatSupport, +} = require('@embroider/compat/babel'); + +const macros = buildMacros(); + +// For scenario testing +const isCompat = Boolean(process.env.ENABLE_COMPAT_BUILD); + +module.exports = { + plugins: [ + [ + '@babel/plugin-transform-typescript', + { + allExtensions: true, + allowDeclareFields: true, + onlyRemoveTypeImports: true, + }, + ], + [ + 'babel-plugin-ember-template-compilation', + { + transforms: [ + ...(isCompat ? templateCompatSupport() : macros.templateMacros), + ], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: require.resolve('decorator-transforms/runtime-esm'), + }, + }, + ], + ...(isCompat ? babelCompatSupport() : macros.babelMacros), + ], + + generatorOpts: { + compact: false, + }, +}; diff --git a/babel.publish.config.cjs b/babel.publish.config.cjs new file mode 100644 index 00000000..f8517068 --- /dev/null +++ b/babel.publish.config.cjs @@ -0,0 +1,31 @@ +module.exports = { + plugins: [ + [ + '@babel/plugin-transform-typescript', + { + allExtensions: true, + allowDeclareFields: true, + onlyRemoveTypeImports: true, + }, + ], + [ + 'babel-plugin-ember-template-compilation', + { + targetFormat: 'hbs', + transforms: [], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: 'decorator-transforms/runtime-esm', + }, + }, + ], + ], + + generatorOpts: { + compact: false, + }, +}; diff --git a/config/ember-cli-update.json b/config/ember-cli-update.json new file mode 100644 index 00000000..9c840a35 --- /dev/null +++ b/config/ember-cli-update.json @@ -0,0 +1,21 @@ +{ + "schemaVersion": "1.0.0", + "projectName": "ember-a11y-testing", + "packages": [ + { + "name": "@ember/addon-blueprint", + "version": "0.6.0", + "blueprints": [ + { + "name": "@ember/addon-blueprint", + "isBaseBlueprint": true, + "options": [ + "--ci-provider=github", + "--pnpm", + "--typescript" + ] + } + ] + } + ] +} diff --git a/config/ember-try-typescript.js b/config/ember-try-typescript.js deleted file mode 100644 index 5f991da4..00000000 --- a/config/ember-try-typescript.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - usePnpm: true, - command: 'tsc --noEmit', - scenarios: [ - { - name: 'typescript-4.2', - npm: { - typescript: '~4.2', - }, - }, - { - name: 'typescript-4.3', - npm: { - typescript: '~4.3', - }, - }, - { - name: 'typescript-4.4', - npm: { - typescript: '~4.4', - }, - }, - { - name: 'typescript-4.5', - npm: { - typescript: '~4.5', - }, - }, - { - name: 'typescript-next', - allowedToFail: true, - npm: { - devDependencies: { - typescript: 'next', - }, - }, - }, - ], -}; diff --git a/config/ember-try.js b/config/ember-try.js deleted file mode 100644 index d9e08b3d..00000000 --- a/config/ember-try.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; - -const getChannelURL = require('ember-source-channel-url'); -const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); - -module.exports = async function () { - return { - usePnpm: true, - scenarios: [ - { - name: 'ember-lts-4.4', - npm: { - devDependencies: { - 'ember-source': '~4.4.0', - }, - }, - }, - { - name: 'ember-lts-4.8', - npm: { - devDependencies: { - 'ember-source': '~4.8.0', - }, - }, - }, - { - name: 'ember-lts-4.12', - npm: { - devDependencies: { - 'ember-source': '~4.12.0', - }, - }, - }, - { - name: 'ember-release', - npm: { - devDependencies: { - 'ember-source': await getChannelURL('release'), - }, - }, - }, - { - name: 'ember-beta', - npm: { - devDependencies: { - 'ember-source': await getChannelURL('beta'), - }, - }, - }, - { - name: 'ember-canary', - npm: { - devDependencies: { - 'ember-source': await getChannelURL('canary'), - }, - }, - }, - embroiderSafe(), - embroiderOptimized(), - ], - }; -}; diff --git a/config/environment.js b/config/environment.js deleted file mode 100644 index 331ab30d..00000000 --- a/config/environment.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (/* environment, appConfig */) { - return {}; -}; diff --git a/ember-cli-build.js b/ember-cli-build.js deleted file mode 100644 index 50031f04..00000000 --- a/ember-cli-build.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); - -module.exports = function (defaults) { - const self = defaults.project.findAddonByName('ember-a11y-testing'); - const autoImport = self.options.autoImport; - - let app = new EmberAddon(defaults, { - autoImport, - }); - - /* - This build file specifies the options for the dummy test app of this - addon, located in `/tests/dummy` - This build file does *not* influence how the addon or the app using it - behave. You most likely want to be modifying `./index.js` or app's build file - */ - - const { maybeEmbroider } = require('@embroider/test-setup'); - return maybeEmbroider(app, { - skipBabel: [ - { - package: 'qunit', - }, - ], - }); -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..cb773a6c --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,146 @@ +/** + * Debugging: + * https://eslint.org/docs/latest/use/configure/debug + * ---------------------------------------------------- + * + * Print a file's calculated configuration + * + * npx eslint --print-config path/to/file.js + * + * Inspecting the config + * + * npx eslint --inspect-config + * + */ +import babelParser from '@babel/eslint-parser'; +import js from '@eslint/js'; +import prettier from 'eslint-config-prettier'; +import ember from 'eslint-plugin-ember/recommended'; +import importPlugin from 'eslint-plugin-import'; +import n from 'eslint-plugin-n'; +import globals from 'globals'; +import ts from 'typescript-eslint'; + +const esmParserOptions = { + ecmaFeatures: { modules: true }, + ecmaVersion: 'latest', +}; + +const tsParserOptions = { + projectService: true, + project: true, + tsconfigRootDir: import.meta.dirname, +}; + +const config = [ + js.configs.recommended, + prettier, + ember.configs.base, + ember.configs.gjs, + ember.configs.gts, + /** + * Ignores must be in their own object + * https://eslint.org/docs/latest/use/configure/ignore + */ + { + ignores: ['dist/', 'declarations/', 'node_modules/', 'coverage/', '!**/.*'], + }, + /** + * https://eslint.org/docs/latest/use/configure/configuration-files#configuring-linter-options + */ + { + linterOptions: { + reportUnusedDisableDirectives: 'error', + }, + }, + { + files: ['**/*.js'], + languageOptions: { + parser: babelParser, + }, + }, + { + files: ['**/*.{js,gjs}'], + languageOptions: { + parserOptions: esmParserOptions, + globals: { + ...globals.browser, + }, + }, + }, + { + files: ['**/*.{ts,gts}'], + languageOptions: { + parser: ember.parser, + parserOptions: tsParserOptions, + }, + extends: [...ts.configs.recommendedTypeChecked, ember.configs.gts], + rules: { + '@typescript-eslint/ban-ts-comment': 'warn', + // FIXME: new rules that needs to be fixed + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-arguments': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/no-misused-promises': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + }, + }, + { + files: ['src/**/*'], + plugins: { + import: importPlugin, + }, + rules: { + // require relative imports use full extensions + 'import/extensions': ['error', 'always', { ignorePackages: true }], + }, + }, + /** + * CJS node files + */ + { + files: [ + '**/*.cjs', + '.prettierrc.cjs', + '.stylelintrc.js', + '.template-lintrc.cjs', + 'addon-main.cjs', + 'node-tests/**/*.js', + ], + plugins: { + n, + }, + + languageOptions: { + sourceType: 'script', + ecmaVersion: 'latest', + globals: { + ...globals.node, + }, + }, + }, + /** + * ESM node files + */ + { + files: ['**/*.mjs'], + plugins: { + n, + }, + + languageOptions: { + sourceType: 'module', + ecmaVersion: 'latest', + parserOptions: esmParserOptions, + globals: { + ...globals.node, + }, + }, + }, +]; + +export default ts.config(...config); diff --git a/node-tests/fixtures/violations.json b/node-tests/fixtures/violations.json index 6ee8188d..cf938a1d 100644 --- a/node-tests/fixtures/violations.json +++ b/node-tests/fixtures/violations.json @@ -82,9 +82,7 @@ "none": [], "impact": "critical", "html": "", - "target": [ - "#violations__empty-button" - ], + "target": ["#violations__empty-button"], "failureSummary": "Fix any of the following:\n Element does not have inner text that is visible to screen readers\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element's default semantics were not overridden with role=\"presentation\"\n Element's default semantics were not overridden with role=\"none\"\n Element has no title attribute or the title attribute is empty" } ] @@ -152,9 +150,7 @@ "none": [], "impact": "critical", "html": "", - "target": [ - "#violations__img-without-alt" - ], + "target": ["#violations__img-without-alt"], "failureSummary": "Fix any of the following:\n Element does not have an alt attribute\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Element has no title attribute or the title attribute is empty\n Element's default semantics were not overridden with role=\"presentation\"\n Element's default semantics were not overridden with role=\"none\"" } ] @@ -216,9 +212,7 @@ "none": [], "impact": "critical", "html": "", - "target": [ - "#violations__labeless-input" - ], + "target": ["#violations__labeless-input"], "failureSummary": "Fix any of the following:\n aria-label attribute does not exist or is empty\n aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty\n Form element does not have an implicit (wrapped)