Skip to content

Commit

Permalink
fix: more adjustments to eslint config (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
devpow112 authored Nov 27, 2024
1 parent c327bd1 commit 278cbbc
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 98 deletions.
136 changes: 84 additions & 52 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,103 @@
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';
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
];
29 changes: 4 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/github.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const hasContext = () => {
const { env: { GITHUB_ACTIONS } } = process;

Expand Down
2 changes: 0 additions & 2 deletions src/helpers/object.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const flatten = (obj) => {
const result = {};

Expand Down
2 changes: 0 additions & 2 deletions src/helpers/report-builder.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const { getContext, hasContext } = require('./github.cjs');
const { getOperatingSystemType, makeRelativeFilePath } = require('./system.cjs');
const { randomUUID } = require('node:crypto');
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/report-configuration.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const { readFileSync } = require('node:fs');
const { resolve } = require('node:path');
const { formatErrorAjv, validateReportConfigurationV1Ajv } = require('./schema.cjs');
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/report.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const schema = require('./schema.cjs');
const { flatten } = require('./object.cjs');
const fs = require('node:fs');
Expand Down
Loading

0 comments on commit 278cbbc

Please sign in to comment.