Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .eslintrc.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
test:
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [18.18.x, 20.x, 22.x]

runs-on: ubuntu-latest

Expand All @@ -34,7 +34,7 @@ jobs:
run: mkdir -p ./junit

- name: Run tests
run: yarn test
run: yarn test --reporter spec --reporter-option output=./junit/test-results.xml
env:
MOCHA_FILE: ./junit/test-results.xml

Expand All @@ -43,4 +43,4 @@ jobs:
if: always()
with:
name: test-results-node-${{ matrix.node-version }}
path: ./junit
path: ./junit
7 changes: 7 additions & 0 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-env node */
/* global process */

const isCI = process.env.CI;
module.exports = {
reporter: isCI ? "mocha-junit-reporter" : "dot",
};
4 changes: 0 additions & 4 deletions .mocharc.js

This file was deleted.

53 changes: 41 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,44 @@ $ yarn add --dev eslint-plugin-ember-a11y-testing

**Note:** If you installed ESLint globally (using the `-g` flag with `npm`, or `yarn global` with yarn) then you must also install `eslint-plugin-ember-a11y-testing` globally.

It's recommended to extend eslint-plugin-ember-a11y-testing's config by
adding it to the `extends` configuration option in your `.eslintrc.js` or
`.eslintrc.json` configuration file:
## ESLint Version Compatibility

This plugin supports both modern ESLint 9+ flat config and legacy ESLint configuration styles.

### ESLint 9+ (Flat Config)

For ESLint 9 and above, use the flat config style in your `eslint.config.mjs`:

```js
import emberA11yTesting from 'eslint-plugin-ember-a11y-testing';

export default [
{
plugins: {
'ember-a11y-testing': emberA11yTesting
},
rules: {
'ember-a11y-testing/a11y-audit-after-test-helper': 'error',
'ember-a11y-testing/a11y-audit-no-expression': 'error',
'ember-a11y-testing/a11y-audit-no-globals': 'error'
}
}
];
```

Or use the recommended configuration:

```js
import recommended from 'eslint-plugin-ember-a11y-testing/recommended';

export default [
recommended
];
```

### Legacy ESLint (Pre-9)

For ESLint versions before 9, use the traditional configuration style in `.eslintrc.js` or `.eslintrc.json`:

```json
{
Expand All @@ -79,23 +114,17 @@ adding it to the `extends` configuration option in your `.eslintrc.js` or
}
```

Otherwise, you can import the plugin:
Or configure manually:

```json
{
"plugins": [
"ember-a11y-testing"
]
}
```

And configure the rules you want to use under the rules section.
```json
{
],
"rules": {
"ember-a11y-testing/a11y-audit-after-test-helper": "error",
"ember-a11y-testing/a11y-audit-no-expression": "error",
"ember-a11y-testing/a11y-audit-no-globals": "error",
"ember-a11y-testing/a11y-audit-no-globals": "error"
}
}
```
Expand Down
100 changes: 100 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import globals from "globals";
import js from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import prettierPluginRecommended from "eslint-plugin-prettier/recommended";
import markdown from "@eslint/markdown";
import nPlugin from "eslint-plugin-n";

export default [
{
ignores: [
"node_modules/**",
"dist/**",
"coverage/**",
".github/**",
".yarn/**",
],
},
js.configs.recommended,
prettierConfig,
prettierPluginRecommended,
{
files: ["**/*.{js,mjs,cjs}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.node,
},
},
plugins: {
n: nPlugin,
},
rules: {
...nPlugin.configs.recommended.rules,
"n/no-missing-import": "off", // Turn off for examples in docs
},
},
{
files: ["**/*.cjs"],
languageOptions: {
sourceType: "commonjs",
globals: {
...globals.node,
},
},
rules: {
"no-redeclare": "off", // Allow redeclaring globals in CJS files
},
},
{
files: ["**/*.md"],
plugins: {
markdown,
},
processor: "markdown/markdown",
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
},
{
files: ["**/*.md/*.js"],
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
rules: {
"n/no-missing-import": "off", // Turn off for code examples
},
},
{
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
},
},
files: ["**/*.js"],
rules: {
"no-undef": "error",
},
},
{
files: ["tests/**/*.js"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
},
},
},
];
29 changes: 0 additions & 29 deletions lib/configs/recommended.js

This file was deleted.

21 changes: 0 additions & 21 deletions lib/index.js

This file was deleted.

56 changes: 56 additions & 0 deletions lib/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @fileoverview ESLint plugin for ember-a11y-testing
* @author Jamie White
*/
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

import a11yAuditAfterTestHelper from "./rules/a11y-audit-after-test-helper.mjs";
import a11yAuditCalled from "./rules/a11y-audit-called.mjs";
import a11yAuditNoExpression from "./rules/a11y-audit-no-expression.mjs";
import a11yAuditNoGlobals from "./rules/a11y-audit-no-globals.mjs";

//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------

const rules = {
"a11y-audit-after-test-helper": a11yAuditAfterTestHelper,
"a11y-audit-called": a11yAuditCalled,
"a11y-audit-no-expression": a11yAuditNoExpression,
"a11y-audit-no-globals": a11yAuditNoGlobals,
};

export default {
rules,
configs: {
recommended: {
languageOptions: {
ecmaVersion: 2018,
sourceType: "module",
globals: {
browser: true,
},
},
plugins: {
"ember-a11y-testing": { rules },
},
settings: {
"ember-a11y-testing": {
auditModule: {
package: "ember-a11y-testing/test-support/audit",
exportName: "default",
},
},
},
rules: {
"ember-a11y-testing/a11y-audit-after-test-helper": "error",
"ember-a11y-testing/a11y-audit-no-expression": "error",
"ember-a11y-testing/a11y-audit-no-globals": "error",
},
},
},
};
3 changes: 3 additions & 0 deletions lib/recommended.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import emberA11yTesting from "./lib/index.mjs";

export default emberA11yTesting.configs.recommended;
Loading
Loading