Skip to content

Commit

Permalink
Infrastructure: Upgrade to ESLint 9 (#3011)
Browse files Browse the repository at this point in the history
Bumps:
* eslint from 8.57.0 to 9.4.0
* eslint-plugin-ava from 14.0.0 to 15.0.0

Adds:
* globals 15.1.0

Removes:
* eslint-plugin-prettier
  • Loading branch information
nschonni authored Jul 31, 2024
1 parent 8e5825a commit 081e028
Show file tree
Hide file tree
Showing 8 changed files with 397 additions and 423 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

78 changes: 0 additions & 78 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const HTMLParser = require('node-html-parser');
// returns undefined.
const getAttributeValue = (obj, attribute) => {
if (typeof obj !== 'object' || obj === null) return undefined;
if (obj.hasOwnProperty(attribute)) return obj[attribute];
if (Object.prototype.hasOwnProperty.call(obj, attribute))
return obj[attribute];

if (Array.isArray(obj)) {
for (const element of obj) {
Expand Down
5 changes: 3 additions & 2 deletions content/patterns/grid/examples/js/dataGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ aria.Grid.prototype.isValidCell = function (row, col) {
* Returns whether or not the cell has been hidden.
*/
aria.Grid.prototype.isHidden = function (row, col) {
// prettier-ignore
var cell = this.gridNode
.querySelectorAll(aria.GridSelector.ROW)
[row].querySelectorAll(aria.GridSelector.CELL)[col];
.querySelectorAll(aria.GridSelector.ROW)[row]
.querySelectorAll(aria.GridSelector.CELL)[col];
return aria.Utils.hasClass(cell, aria.CSSClass.HIDDEN);
};

Expand Down
124 changes: 124 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import globals from 'globals';

import js from '@eslint/js';
import babelParser from '@babel/eslint-parser';

import jsdoc from 'eslint-plugin-jsdoc';
import html from 'eslint-plugin-html';
import ava from 'eslint-plugin-ava';

export default [
// Replaces .eslintignore
{
ignores: [
'**/*.min.js',
'common/',
'content/patterns/landmarks/examples/js/visua11y.js', // cspell:ignore visua
'content/shared/js/highlight.pack.js',
'content/shared/js/skipto.js',
],
},
js.configs.recommended,
{
files: ['**/*.js'],

languageOptions: {
ecmaVersion: 2021,
parserOptions: {
ecmaFeatures: {
impliedStrict: false,
},
},
globals: {
...globals.browser,
},
sourceType: 'script',
},

linterOptions: {
reportUnusedDisableDirectives: 'error',
},

plugins: {
jsdoc: jsdoc,
},

rules: {
...jsdoc.configs.recommended.rules,
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
'no-console': 'error',
// https://eslint.org/docs/latest/use/migrate-to-9.0.0#no-unused-vars, but can be fixed
'no-unused-vars': ['error', { caughtErrors: 'none' }],
strict: [2, 'global'],
},
},
{
files: ['test/**/*.js'],

languageOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
globals: {
...globals.node,
},
},

plugins: {
ava: ava,
},

rules: {
...ava.configs.recommended.rules,
'no-restricted-properties': [
2,
{
property: 'findElements',
message: 'Please use t.context.queryElements().',
},
],
strict: 'off',
},
},
{
files: ['scripts/*.js', '.link-checker.js'],

languageOptions: {
parser: babelParser,
ecmaVersion: 'latest',
parserOptions: {
requireConfigFile: false,
},
globals: {
...globals.node,
},
},

rules: {
'no-console': 'off',
strict: 'off',
},
},
{
files: ['**/*.html'],

languageOptions: {
globals: {
sourceCode: true,
},
},

plugins: {
html: html,
},
},
{
files: ['**/*.mjs'],

languageOptions: { sourceType: 'module' },
},
];
Loading

0 comments on commit 081e028

Please sign in to comment.