Skip to content

Commit

Permalink
test(tests): account for different error handling behavior from diffe…
Browse files Browse the repository at this point in the history
…rent eslint versions
  • Loading branch information
Xunnamius committed Jan 22, 2025
1 parent a3b96ab commit 16bdbf7
Showing 1 changed file with 68 additions and 50 deletions.
118 changes: 68 additions & 50 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -5894,53 +5894,56 @@ context('TypeScript', function () {
},
],
}),
// Documentation failing example #1 for alphabetize
test({
code: `
import React, { PureComponent } from 'react';
import aTypes from 'prop-types';
import { compose, apply } from 'xcompose';
import * as classnames from 'classnames';
import blist2 from 'blist';
import blist from 'BList';
`,
// The reason why this output does not match the success example after being fixed is because eslint will leave overlapping errors alone, so only one import gets reordered when fixes are applied
output: `
import aTypes from 'prop-types';
import React, { PureComponent } from 'react';
import { compose, apply } from 'xcompose';
import * as classnames from 'classnames';
import blist2 from 'blist';
import blist from 'BList';
`,
...parserConfig,
options: [
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
// Multiple errors
...semver.satisfies(eslintPkg.version, '< 3.0.0') ? [] : [
// Documentation failing example #1 for alphabetize
test({
code: `
import React, { PureComponent } from 'react';
import aTypes from 'prop-types';
import { compose, apply } from 'xcompose';
import * as classnames from 'classnames';
import blist2 from 'blist';
import blist from 'BList';
`,
// The reason why this output does not match the success example after being fixed is because eslint will leave overlapping errors alone, so only one import gets reordered when fixes are applied
output: `
import aTypes from 'prop-types';
import React, { PureComponent } from 'react';
import { compose, apply } from 'xcompose';
import * as classnames from 'classnames';
import blist2 from 'blist';
import blist from 'BList';
`,
...parserConfig,
options: [
{
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
},
],
errors: [
{
message: '`prop-types` import should occur before import of `react`',
line: 3,
},
{
message: '`classnames` import should occur before import of `react`',
line: 5,
},
{
message: '`blist` import should occur before import of `react`',
line: 6,
},
{
message: '`BList` import should occur before import of `react`',
line: 7,
},
],
}),
],
errors: [
{
message: '`prop-types` import should occur before import of `react`',
line: 3,
},
{
message: '`classnames` import should occur before import of `react`',
line: 5,
},
{
message: '`blist` import should occur before import of `react`',
line: 6,
},
{
message: '`BList` import should occur before import of `react`',
line: 7,
},
],
}),
],
// Documentation failing example #1 for named
test({
code: `
Expand Down Expand Up @@ -5972,12 +5975,12 @@ context('TypeScript', function () {
import './styles.css';
import path from 'path';
`,
// Should not be fixed
output: `
// Should not be fixed (eslint@>=9 expects null)
output: semver.satisfies(eslintPkg.version, '< 9.0.0') ? `
import fs from 'fs';
import './styles.css';
import path from 'path';
`,
` : null,
...parserConfig,
options: [
{
Expand Down Expand Up @@ -6007,7 +6010,22 @@ context('TypeScript', function () {
import e from "./";
`,
// This is the "correct" behavior, but it's the wrong outcome (expectedly)
output: `
output: semver.satisfies(eslintPkg.version, '< 3.0.0')
// eslint@2 apparently attempts to fix multiple errors in one pass,
// which results in different erroneous output
? `
import type E from './';
import type A from "fs";
import type B from "path";
import type C from "../foo.js";
import type D from "./bar.js";
import a from "fs";
import b from "path";
import c from "../foo.js";
import d from "./bar.js";
import e from "./";
` : `
import type C from "../foo.js";
import type A from "fs";
import type B from "path";
Expand Down

0 comments on commit 16bdbf7

Please sign in to comment.