Skip to content

Commit

Permalink
Build: Enable operator-linebreak "before" ESLint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Jul 31, 2024
1 parent e77a763 commit 6680fa9
Show file tree
Hide file tree
Showing 23 changed files with 502 additions and 484 deletions.
1 change: 1 addition & 0 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config = Object.assign(standard, {
'prefer-const': 'off',
'prefer-promise-reject-errors': 'off',
// extra
'operator-linebreak': ['error', 'before', { overrides: { '=': 'after', '+=': 'after' } }],
eqeqeq: ['error'],
'no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }]
})
Expand Down
21 changes: 14 additions & 7 deletions bin/qunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ program
.description(description)
.option('-f, --filter <filter>', 'run only matching module or test names')
.option('-m, --module <name>', 'run only the specified module')
.option('-r, --reporter [name]', 'specify the reporter to use; ' +
'if no match is found or no name is provided, a list of available ' +
'reporters will be displayed')
.option('--require <module>', 'specify a module or script to include before running ' +
'any tests.', collect, [])
.option('--seed [value]', 'specify a seed to re-order your tests; ' +
'if specified without a value, a seed will be generated')
.option('-r, --reporter [name]',
'specify the reporter to use; '
+ 'if no match is found or no name is provided, a list of available '
+ 'reporters will be displayed'
)
.option('--require <module>',
'specify a module or script to include before running any tests.',
collect,
[]
)
.option('--seed [value]',
'specify a seed to re-order your tests; '
+ 'if specified without a value, a seed will be generated'
)
.option('-w, --watch', 'watch files for changes and re-run the test suite')
.parse(process.argv);

Expand Down
3 changes: 1 addition & 2 deletions build/prep-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ const Repo = {
})
.sort()
.map(change => change.line)
.join('\n') +
'\n';
.join('\n') + '\n';

const today = new Date().toISOString().slice(0, 10);
const newSection = `\n${version} / ${today}
Expand Down
8 changes: 4 additions & 4 deletions build/tasks/test-on-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ module.exports = function (grunt) {
return;
}
testEnd.errors.forEach((assertion) => {
out += `\n\ntest: ${testEnd.fullName.join(' > ')}\n` +
`actual : ${QUnit.dump.parse(assertion.actual)}\n` +
`expected: ${QUnit.dump.parse(assertion.expected)}\n` +
`message: ${assertion.message}\n${assertion.stack || ''}`;
out += `\n\ntest: ${testEnd.fullName.join(' > ')}\n`
+ `actual : ${QUnit.dump.parse(assertion.actual)}\n`
+ `expected: ${QUnit.dump.parse(assertion.expected)}\n`
+ `message: ${assertion.message}\n${assertion.stack || ''}`;
});
});

Expand Down
18 changes: 9 additions & 9 deletions src/cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function onExit () {
const currentTest = QUnit.config.current;
if (currentTest && currentTest.pauses.size > 0) {
const name = currentTest.testName;
console.error('Last test to run (' + name + ') has an async hold. ' +
'Ensure all assert.async() callbacks are invoked and Promises resolve. ' +
'You should also set a standard timeout via QUnit.config.testTimeout.');
console.error('Last test to run (' + name + ') has an async hold. '
+ 'Ensure all assert.async() callbacks are invoked and Promises resolve. '
+ 'You should also set a standard timeout via QUnit.config.testTimeout.');
}
}
}
Expand Down Expand Up @@ -104,10 +104,10 @@ async function run (args, options) {
require(filePath);
} catch (e) {
if (
(e.code === 'ERR_REQUIRE_ESM' ||
(e instanceof SyntaxError &&
e.message === 'Cannot use import statement outside a module')) &&
(!nodeVint || nodeVint >= 72)
(e.code === 'ERR_REQUIRE_ESM'
|| (e instanceof SyntaxError
&& e.message === 'Cannot use import statement outside a module'))
&& (!nodeVint || nodeVint >= 72)
) {
// filePath is an absolute file path here (per path.resolve above).
// On Windows, Node.js enforces that absolute paths via ESM use valid URLs,
Expand Down Expand Up @@ -211,8 +211,8 @@ run.watch = function watch (args, options) {
// Bare minimum delay, we have another debounce in restart().
delay: DEBOUNCE_WATCH_LENGTH,
filter: (fullpath, skip) => {
if (/\/node_modules\//.test(fullpath) ||
ignoreDirs.includes(path.basename(fullpath))
if (/\/node_modules\//.test(fullpath)
|| ignoreDirs.includes(path.basename(fullpath))
) {
return skip;
}
Expand Down
40 changes: 19 additions & 21 deletions src/core/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ class Assert {
currentTest.assert.pushResult({
result: false,
actual: block,
message: 'The value provided to `assert.throws` in ' +
'"' + currentTest.testName + '" was not a function.'
message: 'The value provided to `assert.throws` in '
+ '"' + currentTest.testName + '" was not a function.'
});

return;
Expand Down Expand Up @@ -319,8 +319,8 @@ class Assert {
if (typeof then !== 'function') {
currentTest.assert.pushResult({
result: false,
message: 'The value provided to `assert.rejects` in ' +
'"' + currentTest.testName + '" was not a promise.',
message: 'The value provided to `assert.rejects` in '
+ '"' + currentTest.testName + '" was not a promise.',
actual: promise
});

Expand All @@ -334,8 +334,8 @@ class Assert {
function handleFulfillment () {
currentTest.assert.pushResult({
result: false,
message: 'The promise returned by the `assert.rejects` callback in ' +
'"' + currentTest.testName + '" did not reject.',
message: 'The promise returned by the `assert.rejects` callback in '
+ '"' + currentTest.testName + '" did not reject.',
actual: promise
});

Expand Down Expand Up @@ -371,23 +371,21 @@ function validateExpectedExceptionArgs (expected, message, assertionMethod) {
return [expected, message];
} else {
throw new Error(
'assert.' + assertionMethod +
' does not accept a string value for the expected argument.\n' +
'Use a non-string object value (e.g. RegExp or validator function) ' +
'instead if necessary.'
'assert.' + assertionMethod + ' does not accept a string value for the expected argument.\n'
+ 'Use a non-string object value (e.g. RegExp or validator function) instead if necessary.'
);
}
}

const valid =
!expected || // TODO: be more explicit here
expectedType === 'regexp' ||
expectedType === 'function' ||
expectedType === 'object';
!expected // TODO: be more explicit here
|| expectedType === 'regexp'
|| expectedType === 'function'
|| expectedType === 'object';

if (!valid) {
throw new Error('Invalid expected value type (' + expectedType + ') ' +
'provided to assert.' + assertionMethod + '.');
throw new Error('Invalid expected value type (' + expectedType + ') '
+ 'provided to assert.' + assertionMethod + '.');
}

return [expected, message];
Expand All @@ -413,15 +411,15 @@ function validateException (actual, expected, message) {
// Expected is a constructor, maybe an Error constructor.
// Note the extra check on its prototype - this is an implicit
// requirement of "instanceof", else it will throw a TypeError.
} else if (expectedType === 'function' &&
expected.prototype !== undefined && actual instanceof expected) {
} else if (expectedType === 'function'
&& expected.prototype !== undefined && actual instanceof expected) {
result = true;

// Expected is an Error object
} else if (expectedType === 'object') {
result = actual instanceof expected.constructor &&
actual.name === expected.name &&
actual.message === expected.message;
result = actual instanceof expected.constructor
&& actual.name === expected.name
&& actual.message === expected.message;

// Log the string form of the Error object
expected = errorString(expected);
Expand Down
4 changes: 2 additions & 2 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const config = {
{
id: 'noglobals',
label: 'Check for globals',
tooltip: 'Enabling this will test if any test introduces new properties on the ' +
'global object (e.g. `window` in browsers). Stored as query string.'
tooltip: 'Enabling this will test if any test introduces new properties on the '
+ 'global object (e.g. `window` in browsers). Stored as query string.'
},
{
id: 'notrycatch',
Expand Down
Loading

0 comments on commit 6680fa9

Please sign in to comment.