Files
NapCatQQ/.pnpm-store/v3/files/f6/ca0928f749a8554731b1bf5870eb516518f89d560a4e3ecba47f41d5c82b0f40ae8cbcc1f5961d3e4685be6f7598824ffe5285443002ce303e8a1f045fe794
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

94 lines
1.8 KiB
Plaintext

import { version as eslintVersion } from 'eslint/package.json';
import test from 'tape';
import semver from 'semver';
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
const usingLegacy = semver.major(eslintVersion) < 9;
test('parserOptionsMapper', (t) => {
const expectedResult = usingLegacy
? {
code: '<div />',
errors: [],
options: {},
parserOptions: {
ecmaVersion: 2018,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
},
settings: {},
}
: {
code: '<div />',
errors: [],
options: {},
languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
},
},
settings: {},
};
t.deepEqual(
parserOptionsMapper({
code: '<div />',
errors: [],
options: {},
}),
expectedResult,
'returns a test case object',
);
const expectedResult2 = usingLegacy
? {
code: '<div />',
errors: [],
options: {},
parserOptions: {
ecmaVersion: 5,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
},
settings: {},
}
: {
code: '<div />',
errors: [],
options: {},
languageOptions: {
ecmaVersion: 5,
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
},
},
settings: {},
};
t.deepEqual(
parserOptionsMapper({
code: '<div />',
errors: [],
options: {},
languageOptions: {
ecmaVersion: 5,
},
}),
expectedResult2,
'allows for overriding parserOptions',
);
t.end();
});