Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"chalk": "^4.1.0",
"codecov-lite": "2.0.0",
"del-cli": "^5.0.0",
"eslint": "^8.57.1",
"eslint-config-rollup": "^3.0.1",
"esm": "^3.2.25",
"execa": "^5.1.1",
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"lint"
],
"peerDependencies": {
"eslint": "^8.57.1||^9.0.0",
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
},
"peerDependenciesMeta": {
Expand All @@ -62,18 +63,21 @@
}
},
"dependencies": {
"@rollup/pluginutils": "^5.0.1",
"eslint": "^8.57.1"
"@rollup/pluginutils": "^5.0.1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^9.0.1",
"@types/eslint": "^8.56.12",
"eslint": "^8.57.1",
"eslint9": "npm:eslint@^9.37.0",
"esmock": "^2.7.3",
"rollup": "^4.0.0-24",
"typescript": "^4.8.3"
},
"types": "./types/index.d.ts",
"ava": {
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/helpers/**",
Expand Down
39 changes: 38 additions & 1 deletion packages/eslint/test/test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import fs from 'fs';

import { createRequire } from 'module';
import process from 'process';
import path from 'path';
import { fileURLToPath } from 'url';

import eslint9 from 'eslint9';
import esmock from 'esmock';
import test from 'ava';
import nodeResolve from '@rollup/plugin-node-resolve';
import { rollup } from 'rollup';
Expand Down Expand Up @@ -241,3 +245,36 @@

t.is(count, 1);
});

test.serial('works with ESLint v9', async (t) => {
// Load the plugin with an override to route 'eslint' imports to ESLint v9
const eslint = await esmock('current-package', {

Check warning on line 251 in packages/eslint/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v18

'eslint' is already declared in the upper scope on line 13 column 8

Check warning on line 251 in packages/eslint/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v18

'eslint' is already declared in the upper scope on line 13 column 8

Check warning on line 251 in packages/eslint/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

'eslint' is already declared in the upper scope on line 13 column 8

Check warning on line 251 in packages/eslint/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

'eslint' is already declared in the upper scope on line 13 column 8
eslint: eslint9
});

// ESLint v9 needs to be invoked with a flat config file in the current dir
const cwd = process.cwd();
const testDir = path.dirname(fileURLToPath(import.meta.url));
process.chdir(path.join(testDir, 'fixtures', 'flat-config'));

let count = 0;
try {
await rollup({
input: './undeclared.js',
plugins: [
eslint({
formatter: (results) => {
count += results[0].messages.length;
// eslint-disable-next-line prefer-destructuring
const { message } = results[0].messages[0];
t.is(message, "'x' is not defined.");
}
})
]
});
} finally {
process.chdir(cwd);
}

t.is(count, 1);
});
Loading
Loading