diff --git a/eslint.config.js b/eslint.config.js index 473b10a..f17f1d6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,7 @@ import { addExtensions, nodeConfig, setDirectoryConfigs, testingConfig } from 'eslint-config-brightspace'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import globals from 'globals'; +import importPlugin from 'eslint-plugin-import'; import { includeIgnoreFile } from '@eslint/compat'; import jsonPlugin from 'eslint-plugin-json'; import mochaPlugin from 'eslint-plugin-mocha'; @@ -9,63 +9,95 @@ import playwrightPlugin from 'eslint-plugin-playwright'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const nodeConfigs = addExtensions(nodeConfig, ['.js', '.cjs']); -const playwrightConfig = playwrightPlugin.configs['flat/recommended']; -const mochaConfig = mochaPlugin.configs.flat.recommended; -const jsonConfig = jsonPlugin.configs['recommended']; const gitignorePath = resolve(__dirname, '.gitignore'); - -export default [ - includeIgnoreFile(gitignorePath), - ...setDirectoryConfigs( - nodeConfigs, - { - 'test/': testingConfig, - 'test/integration/data/': nodeConfigs, - 'test/integration/data/tests/mocha/': testingConfig, - 'test/integration/data/tests/web-test-runner/': testingConfig - } - ), +const fileExtensions = ['.js', '.cjs']; +const importConfigs = [ + importPlugin.flatConfigs.recommended, { - ...mochaConfig, - files: ['test/unit/**/*.test.js'], - rules: { - ...mochaConfig.rules, - 'mocha/no-exclusive-tests': 'error', - 'mocha/no-mocha-arrows': 'off' - } - }, - { - ...mochaConfig, - files: ['test/integration/data/tests/{mocha,web-test-runner}/*.test.js'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'module' + }, + settings: { + 'import/resolver': { + node: true + } + }, rules: { - ...mochaConfig.rules, - 'mocha/no-mocha-arrows': 'off', - 'mocha/no-skipped-tests': 'off' + 'import/extensions': ['error', 'ignorePackages'] } - }, - { - ...playwrightConfig, - files: ['test/integration/data/tests/playwright/*.js'], - rules: { - ...playwrightConfig.rules, - 'playwright/expect-expect': 'off', - 'playwright/no-skipped-test': 'off', - 'playwright/no-conditional-in-test': 'off' + } +]; +const commandDangleConfig = { + rules: { + 'comma-dangle': 'error' + } +}; +const globalConfigs = addExtensions( + [ + ...nodeConfig, + ...importConfigs, + commandDangleConfig + ], + fileExtensions +); +const playwrightConfigs = addExtensions( + [ + ...globalConfigs, + playwrightPlugin.configs['flat/recommended'], + { + rules: { + 'playwright/expect-expect': 'off', + 'playwright/no-skipped-test': 'off', + 'playwright/no-conditional-in-test': 'off' + } } - }, - { - files: ['test/unit/**/*.js'], - languageOptions: { - globals: { - ...globals.node + ], + fileExtensions +); +const mochaConfigs = addExtensions( + [ + ...globalConfigs, + mochaPlugin.configs.flat.recommended, + { + rules: { + 'mocha/no-exclusive-tests': 'error', + 'mocha/no-mocha-arrows': 'off' } } - }, - jsonConfig, - { - rules: { - 'comma-dangle': 'error' + ], + fileExtensions +); +const webTestRunnerConfigs = addExtensions( + [ + ...testingConfig, + commandDangleConfig + ], + fileExtensions +); +const jsonConfig = jsonPlugin.configs['recommended']; + +export default [ + includeIgnoreFile(gitignorePath), + ...setDirectoryConfigs( + globalConfigs, + { + 'test/unit': mochaConfigs, + 'test/integration': mochaConfigs, + 'test/integration/data': globalConfigs, + 'test/integration/data/tests/mocha': [ + ...mochaConfigs, + { + rules: { + 'mocha/no-mocha-arrows': 'off', + 'mocha/no-skipped-tests': 'off' + } + } + ], + 'test/integration/data/tests/playwright': playwrightConfigs, + 'test/integration/data/tests/web-test-runner': webTestRunnerConfigs + } - } + ), + jsonConfig ]; diff --git a/package-lock.json b/package-lock.json index db86712..8ae5e69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,10 +31,10 @@ "editorconfig-checker": "^6", "eslint": "^9", "eslint-config-brightspace": "^2", + "eslint-plugin-import": "^2.31.0", "eslint-plugin-json": "^4", "eslint-plugin-mocha": "^10", "eslint-plugin-playwright": "^2", - "globals": "^15", "npm-run-all": "^4", "playwright": "^1.49", "sinon": "^19" @@ -1231,8 +1231,7 @@ "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", "integrity": "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@sinonjs/commons": { "version": "3.0.1", @@ -1450,8 +1449,7 @@ "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/keygrip": { "version": "1.0.6", @@ -2053,7 +2051,6 @@ "integrity": "sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -2106,7 +2103,6 @@ "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -2128,7 +2124,6 @@ "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -2148,7 +2143,6 @@ "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -3365,7 +3359,6 @@ "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "esutils": "^2.0.2" }, @@ -3690,7 +3683,6 @@ "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "hasown": "^2.0.0" } @@ -3856,7 +3848,6 @@ "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "^3.2.7", "is-core-module": "^2.13.0", @@ -3869,7 +3860,6 @@ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ms": "^2.1.1" } @@ -3880,7 +3870,6 @@ "integrity": "sha512-wALZ0HFoytlyh/1+4wuZ9FJCD/leWHQzzrxJ8+rebyReSLk7LApMyd3WJaLVoN+D5+WIdJyDK1c6JnE65V4Zyg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "debug": "^3.2.7" }, @@ -3899,7 +3888,6 @@ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ms": "^2.1.1" } @@ -3924,7 +3912,6 @@ "integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.8", @@ -3959,7 +3946,6 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3971,7 +3957,6 @@ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "ms": "^2.1.1" } @@ -3982,7 +3967,6 @@ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -4979,6 +4963,7 @@ "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, @@ -7328,7 +7313,6 @@ "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -7348,7 +7332,6 @@ "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -7364,7 +7347,6 @@ "integrity": "sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -8573,7 +8555,6 @@ "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "license": "ISC", - "peer": true, "bin": { "semver": "bin/semver.js" } @@ -9324,7 +9305,6 @@ "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.2", @@ -9338,7 +9318,6 @@ "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "minimist": "^1.2.0" }, diff --git a/package.json b/package.json index e735ec4..b8bec64 100644 --- a/package.json +++ b/package.json @@ -69,10 +69,10 @@ "editorconfig-checker": "^6", "eslint": "^9", "eslint-config-brightspace": "^2", + "eslint-plugin-import": "^2", "eslint-plugin-json": "^4", "eslint-plugin-mocha": "^10", "eslint-plugin-playwright": "^2", - "globals": "^15", "npm-run-all": "^4", "playwright": "^1.49", "sinon": "^19" diff --git a/src/helpers/github.cjs b/src/helpers/github.cjs index 373a60d..2372025 100644 --- a/src/helpers/github.cjs +++ b/src/helpers/github.cjs @@ -1,5 +1,3 @@ -'use strict'; - const hasContext = () => { const { env: { GITHUB_ACTIONS } } = process; diff --git a/src/helpers/object.cjs b/src/helpers/object.cjs index 5a33946..f298011 100644 --- a/src/helpers/object.cjs +++ b/src/helpers/object.cjs @@ -1,5 +1,3 @@ -'use strict'; - const flatten = (obj) => { const result = {}; diff --git a/src/helpers/report-builder.cjs b/src/helpers/report-builder.cjs index 5e6b4e2..2eae798 100644 --- a/src/helpers/report-builder.cjs +++ b/src/helpers/report-builder.cjs @@ -1,5 +1,3 @@ -'use strict'; - const { getContext, hasContext } = require('./github.cjs'); const { getOperatingSystemType, makeRelativeFilePath } = require('./system.cjs'); const { randomUUID } = require('node:crypto'); diff --git a/src/helpers/report-configuration.cjs b/src/helpers/report-configuration.cjs index 9b92124..d5e64aa 100644 --- a/src/helpers/report-configuration.cjs +++ b/src/helpers/report-configuration.cjs @@ -1,5 +1,3 @@ -'use strict'; - const { readFileSync } = require('node:fs'); const { resolve } = require('node:path'); const { formatErrorAjv, validateReportConfigurationV1Ajv } = require('./schema.cjs'); diff --git a/src/helpers/report.cjs b/src/helpers/report.cjs index 220067d..1f554bf 100644 --- a/src/helpers/report.cjs +++ b/src/helpers/report.cjs @@ -1,5 +1,3 @@ -'use strict'; - const schema = require('./schema.cjs'); const { flatten } = require('./object.cjs'); const fs = require('node:fs'); diff --git a/src/helpers/schema.cjs b/src/helpers/schema.cjs index 3589f40..72ad975 100644 --- a/src/helpers/schema.cjs +++ b/src/helpers/schema.cjs @@ -1,5 +1,3 @@ -'use strict'; - const Ajv = require('ajv/dist/2019'); const addFormats = require('ajv-formats'); diff --git a/src/helpers/strings.cjs b/src/helpers/strings.cjs index bf3a785..c6f076a 100644 --- a/src/helpers/strings.cjs +++ b/src/helpers/strings.cjs @@ -1,5 +1,3 @@ -'use strict'; - const escapeSpecialCharacters = (str) => { return str .replace(/[\\]/g, '\\\\') diff --git a/src/helpers/system.cjs b/src/helpers/system.cjs index d00e41d..a4159a2 100644 --- a/src/helpers/system.cjs +++ b/src/helpers/system.cjs @@ -1,5 +1,3 @@ -'use strict'; - const { relative, sep: platformSeparator } = require('node:path'); const { join } = require('node:path/posix'); const { type } = require('node:os'); diff --git a/src/reporters/mocha.cjs b/src/reporters/mocha.cjs index 8f54f36..4c6ddee 100644 --- a/src/reporters/mocha.cjs +++ b/src/reporters/mocha.cjs @@ -1,5 +1,3 @@ -'use strict'; - const { reporters: { Base, Spec }, Runner: { constants } } = require('mocha'); const { ReportBuilder } = require('../helpers/report-builder.cjs'); diff --git a/test/integration/data/configs/mocha.cjs b/test/integration/data/configs/mocha.cjs index 908d3ac..09f5c98 100644 --- a/test/integration/data/configs/mocha.cjs +++ b/test/integration/data/configs/mocha.cjs @@ -1,5 +1,3 @@ -'use strict'; - module.exports = { spec: 'test/integration/data/tests/mocha/*.test.js', retries: 3,