diff --git a/eslint.config.js b/eslint.config.js index 473b10a..d28a03b 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,83 @@ 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 - } - ), - { - ...mochaConfig, - files: ['test/unit/**/*.test.js'], - rules: { - ...mochaConfig.rules, - 'mocha/no-exclusive-tests': 'error', - 'mocha/no-mocha-arrows': 'off' - } - }, +const importConfigs = [ + importPlugin.flatConfigs.recommended, { - ...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'] } - }, + } +]; +const commandDangleConfig = { + rules: { + 'comma-dangle': 'error' + } +}; +const globalConfigs = [ + ...addExtensions(nodeConfig, ['.js', '.cjs']), + ...importConfigs, + commandDangleConfig +]; +const playwrightConfigs = [ + ...globalConfigs, + playwrightPlugin.configs['flat/recommended'], { - ...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' } - }, - { - files: ['test/unit/**/*.js'], - languageOptions: { - globals: { - ...globals.node - } - } - }, - jsonConfig, + } +]; +const mochaConfigs = [ + ...globalConfigs, + mochaPlugin.configs.flat.recommended, { rules: { - 'comma-dangle': 'error' + 'mocha/no-exclusive-tests': 'error', + 'mocha/no-mocha-arrows': 'off' } } ]; +const webTestRunnerConfigs = [ + ...testingConfig, + commandDangleConfig +]; + +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..6331b7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,6 @@ "eslint-plugin-json": "^4", "eslint-plugin-mocha": "^10", "eslint-plugin-playwright": "^2", - "globals": "^15", "npm-run-all": "^4", "playwright": "^1.49", "sinon": "^19" @@ -4979,6 +4978,7 @@ "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, diff --git a/package.json b/package.json index e735ec4..e5633be 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "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,