Skip to content

Commit

Permalink
test: update cli regression case for v9
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Sep 19, 2024
1 parent 23260f0 commit cbd057a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
28 changes: 28 additions & 0 deletions tests/files/just-json-files/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var jsonPlugin = require('eslint-plugin-json');

if (!jsonPlugin.processors.json) {
jsonPlugin.processors.json = jsonPlugin.processors['.json'];
}

module.exports = [
{
files: ['tests/files/just-json-files/*.json'],
plugins:{
json: jsonPlugin,
},
processor: 'json/json',
rules: Object.assign(
{},
{
'import/no-unused-modules': [
'error',
{
'missingExports': false,
'unusedExports': true,
},
],
},
jsonPlugin.configs.recommended.rules
)
},
];
24 changes: 15 additions & 9 deletions tests/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,24 @@ describe('CLI regression tests', function () {
let eslint;
let cli;
beforeEach(function () {
// TODO: it might be possible to get this working on v9 with a lot of wrangling of eslint-plugin-json v2/4
if (semver.satisfies(eslintPkg.version, '< 6 || >= 9')) {
if (semver.satisfies(eslintPkg.version, '< 6')) {
this.skip();
} else {
if (ESLint) {
eslint = new ESLint({
useEslintrc: false,
overrideConfigFile: './tests/files/just-json-files/.eslintrc.json',
rulePaths: ['./src/rules'],
ignore: false,
plugins: { 'eslint-plugin-import': importPlugin },
});
if (semver.satisfies(eslintPkg.version, '>= 9')) {
eslint = new ESLint({
overrideConfigFile: './tests/files/just-json-files/eslint.config.mjs',
plugins: { 'eslint-plugin-import': importPlugin },
});
} else {
eslint = new ESLint({
useEslintrc: false,
overrideConfigFile: './tests/files/just-json-files/.eslintrc.json',
rulePaths: ['./src/rules'],
ignore: false,
plugins: { 'eslint-plugin-import': importPlugin },
});
}
} else {
cli = new CLIEngine({
useEslintrc: false,
Expand Down

0 comments on commit cbd057a

Please sign in to comment.