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..f3c2b8da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,17 @@ -# See https://help.github.com/ignore-files/ for more about ignoring files. - # compiled output -/dist/ -/tmp/ +dist/ +dist-tests/ +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..b5f539be 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,25 +1,16 @@ # unconventional js /blueprints/*/files/ -/vendor/ # compiled output /dist/ -/tmp/ - -# dependencies -/bower_components/ -/node_modules/ +/dist-*/ +/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..40bf32cc --- /dev/null +++ b/.try.mjs @@ -0,0 +1,87 @@ +// When building your addon for older Ember versions you need to have the required files +const compatFiles = { + 'ember-cli-build.js': `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); +};`, + '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, + }), +}; + +const compatDeps = { + '@embroider/compat': '^4.0.3', + 'ember-cli': '^5.12.0', + 'ember-auto-import': '^2.10.0', + '@ember/optional-features': '^2.2.0', +}; + +export default { + scenarios: [ + { + name: 'ember-lts-5.8', + npm: { + devDependencies: { + 'ember-source': '~5.8.0', + ...compatDeps, + }, + }, + env: { + ENABLE_COMPAT_BUILD: true, + }, + files: compatFiles, + }, + { + name: 'ember-lts-5.12', + npm: { + devDependencies: { + 'ember-source': '~5.12.0', + ...compatDeps, + }, + }, + env: { + ENABLE_COMPAT_BUILD: true, + }, + files: compatFiles, + }, + { + name: `ember-lts-6.4`, + npm: { + devDependencies: { + 'ember-source': `npm:ember-source@~6.4.0`, + }, + }, + }, + { + name: `ember-latest`, + npm: { + devDependencies: { + 'ember-source': `npm:ember-source@latest`, + }, + }, + }, + { + name: `ember-beta`, + npm: { + devDependencies: { + 'ember-source': `npm:ember-source@beta`, + }, + }, + }, + { + name: `ember-alpha`, + npm: { + devDependencies: { + 'ember-source': `npm:ember-source@alpha`, + }, + }, + }, + ], +}; 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..fe72f41b --- /dev/null +++ b/babel.config.cjs @@ -0,0 +1,50 @@ +/** + * This babel.config is not used for publishing. + * It's only for the local editing experience + * (and linting) + */ +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..85ffa1d6 --- /dev/null +++ b/babel.publish.config.cjs @@ -0,0 +1,36 @@ +/** + * This babel.config is only used for publishing. + * + * For local dev experience, see the babel.config + */ +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/cli-options-filter.js b/cli-options-filter.js deleted file mode 100644 index e8da1d8a..00000000 --- a/cli-options-filter.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -const Filter = require('broccoli-persistent-filter'); - -const enableMiddlewareReporter = - process.env.ENABLE_A11Y_MIDDLEWARE_REPORTER === 'true'; -const enableA11yAudit = process.env.ENABLE_A11Y_AUDIT === 'true'; - -const replacementToken = '$1 true'; - -class CliOptionsFilter extends Filter { - constructor() { - super(...arguments); - } - - /** - * If `ENABLE_A11Y_MIDDLEWARE_REPORTER=true` or `ENABLE_A11Y_AUDIT=true` environmental - * variables are specified, overwrite the corresponding values in `test-support/cli-options` - * at build-time to make them accessible in the browser environment. - * @override - */ - processString(contents) { - if (enableMiddlewareReporter) { - contents = contents.replace( - /(ENABLE_A11Y_MIDDLEWARE_REPORTER = )false/, - replacementToken, - ); - } - - if (enableA11yAudit) { - contents = contents.replace( - /(ENABLE_A11Y_AUDIT = )false/, - replacementToken, - ); - } - - return contents; - } -} - -module.exports = CliOptionsFilter; diff --git a/config/ember-cli-update.json b/config/ember-cli-update.json new file mode 100644 index 00000000..90805871 --- /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.8.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..2c0fbec0 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,153 @@ +/** + * 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/', + '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/index.js b/index.js deleted file mode 100644 index 9f0a0885..00000000 --- a/index.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -const path = require('path'); -const fs = require('fs'); -const VersionChecker = require('ember-cli-version-checker'); -const validatePeerDependencies = require('validate-peer-dependencies'); -const { - setupMiddlewareHooks, -} = require('@scalvert/ember-setup-middleware-reporter'); -const CliOptionsFilter = require('./cli-options-filter'); - -// The different types/area for which we have content for. -const ALLOWED_CONTENT_FOR = ['test-head-footer']; - -module.exports = { - name: require('./package').name, - - init() { - this._super.init.apply(this, arguments); - - let versionChecker = new VersionChecker(this.project); - - validatePeerDependencies(__dirname, { - resolvePeerDependenciesFrom: this.parent.root, - }); - - const hasMagicallyProvidedQUnit = versionChecker - .for('ember-qunit') - .lt('5.0.0-beta.1'); - - this.options = this.options || {}; - this.options.autoImport = { - webpack: { - module: { - noParse: /\baxe\.js$/, - }, - }, - }; - - // Ember-qunit < 5 provides an AMD shim for qunit but newer version now use - // ember-auto-import to include qunit. This means that qunit is no - // longer available for addons (if the parent app is using ember-qunit > 5) to - // directly import under embroider unless they are using ember-auto-import - // themselves. This conditionally falls back to not using ember-auto-import - // when the parent app is providing qunit because without this we would double - // include qunit resulting in a runtime error (qunit detects if it as - // already be added to the window object and errors if so). - if (hasMagicallyProvidedQUnit) { - this.options.autoImport.exclude = ['qunit']; - } - }, - - /** - * Adds content for the areas specified in the array above. It appends the - * contents of the files with the same name to the content-for block. - * @override - */ - contentFor: function (type) { - if ( - process.env.EMBER_ENV !== 'production' && - ~ALLOWED_CONTENT_FOR.indexOf(type) - ) { - return fs.readFileSync( - path.join(__dirname, 'content-for', type + '.html'), - ); - } - }, - - /** - * Allow the option to enable a11y audit and middelware reporter using environmental - * variables. If set, environmental variable values are exposed to the browser - * environment via `test-support/cli-options`. - * @override - */ - treeForAddonTestSupport(tree) { - const processedTree = new CliOptionsFilter(tree); - return this._super.treeForAddonTestSupport.call(this, processedTree); - }, - - ...setupMiddlewareHooks({ - name: 'ember-a11y-testing', - urlPath: 'report-violations', - reportDir: 'ember-a11y-report', - }), -}; 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)