Given:
xo reports the same issues in both files:
npx xo source/index.ts test/index.ts
source/index.ts:11:22
✖ 11:22 Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. @typescript-eslint/no-confusing-void-expression
✖ 11:25 Prefer NaN over Number.NaN. unicorn/prefer-global-number-constants
✖ 12:22 Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. @typescript-eslint/no-confusing-void-expression
test/index.ts:11:22
✖ 11:22 Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. @typescript-eslint/no-confusing-void-expression
✖ 11:25 Prefer NaN over Number.NaN. unicorn/prefer-global-number-constants
✖ 12:22 Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function. @typescript-eslint/no-confusing-void-expression
6 errors
xo --fix fixes source/index.ts as expected, but mangles test/index.ts
npx xo --fix source/index.ts test/index.ts
source/index.ts:
void test('throws RangeError for invalid numbers', () => {
- assert.throws(() => fn(Number.NaN), RangeError);
- assert.throws(() => fn(1.5), RangeError);
+ assert.throws(() => { fn(NaN); }, RangeError);
+ assert.throws(() => { fn(1.5); }, RangeError);
});
test/index.ts:
void test('throws RangeError for invalid numbers', () => {
- assert.throws(() => fn(Number.NaN), RangeError);
- assert.throws(() => fn(1.5), RangeError);
+ assert.throws(() => { { { { { { { { ; }{ ; }{ ; }fn; }(N; }um; }be; }r.; }N{ a; }N{ ; }); },{ ; } Rang{ ; }eErro{ ; }r);
+ { ; }asser{ ; }t.thr{ ; }ows(({ ; }) => { ; }fn(1.5); }, RangeError);
});
Given:
XO v3.0.1
Project structure:
TSConfig:
{ "include": ["source/**/*"], "compilerOptions": { "outDir": "distribution", "rootDir": "source", "types": ["node"] } }The same file at both
source/index.tsandtest/index.ts:xoreports the same issues in both files:xo --fixfixessource/index.tsas expected, but manglestest/index.tssource/index.ts:void test('throws RangeError for invalid numbers', () => { - assert.throws(() => fn(Number.NaN), RangeError); - assert.throws(() => fn(1.5), RangeError); + assert.throws(() => { fn(NaN); }, RangeError); + assert.throws(() => { fn(1.5); }, RangeError); });test/index.ts:void test('throws RangeError for invalid numbers', () => { - assert.throws(() => fn(Number.NaN), RangeError); - assert.throws(() => fn(1.5), RangeError); + assert.throws(() => { { { { { { { { ; }{ ; }{ ; }fn; }(N; }um; }be; }r.; }N{ a; }N{ ; }); },{ ; } Rang{ ; }eErro{ ; }r); + { ; }asser{ ; }t.thr{ ; }ows(({ ; }) => { ; }fn(1.5); }, RangeError); });