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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## [Unreleased]

### Fixed
- ensure plugin exports are equal to the `plugin` object on flat configs ([#3213], thanks [@soren121])

## [2.32.0] - 2025-06-20

### Added
Expand Down Expand Up @@ -1181,6 +1184,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#3213]: https://github.com/import-js/eslint-plugin-import/pull/3213
[#3191]: https://github.com/import-js/eslint-plugin-import/pull/3191
[#3173]: https://github.com/import-js/eslint-plugin-import/pull/3173
[#3172]: https://github.com/import-js/eslint-plugin-import/pull/3172
Expand Down Expand Up @@ -2042,6 +2046,7 @@ for info on changes for earlier releases.
[@skyrpex]: https://github.com/skyrpex
[@snewcomer]: https://github.com/snewcomer
[@sompylasar]: https://github.com/sompylasar
[@soren121]: https://github.com/soren121
[@soryy708]: https://github.com/soryy708
[@sosukesuzuki]: https://github.com/sosukesuzuki
[@spalger]: https://github.com/spalger
Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ export const configs = {
typescript: require('../config/typescript'),
};

export const meta = { name, version };

// Base Plugin Object
const importPlugin = {
meta: { name, version },
meta,
configs,
flatConfigs: {},
rules,
};

Expand All @@ -86,7 +90,7 @@ const createFlatConfig = (baseConfig, configName) => ({
plugins: { import: importPlugin },
});

export const flatConfigs = {
export const flatConfigs = importPlugin.flatConfigs = {
recommended: createFlatConfig(
require('../config/flat/recommended'),
'recommended',
Expand All @@ -101,3 +105,5 @@ export const flatConfigs = {
electron: createFlatConfig(configs.electron, 'electron'),
typescript: createFlatConfig(configs.typescript, 'typescript'),
};

module.exports = importPlugin;
31 changes: 29 additions & 2 deletions tests/src/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('package', function () {
});

it('has every rule', function (done) {

fs.readdir(
path.join(pkg, 'rules')
, function (err, files) {
Expand All @@ -34,7 +33,7 @@ describe('package', function () {
});
});

it('exports all configs', function (done) {
it('exports all legacy configs', function (done) {
fs.readdir(path.join(process.cwd(), 'config'), function (err, files) {
if (err) { done(err); return; }
files.filter(isJSFile).forEach((file) => {
Expand All @@ -45,6 +44,34 @@ describe('package', function () {
});
});

it('exports all flat configs', function (done) {
fs.readdir(path.join(process.cwd(), 'config'), function (err, files) {
if (err) { done(err); return; }
files.filter(isJSFile).forEach((file) => {
if (file[0] === '.') { return; }

const basename = path.basename(file, '.js');
// stage-0 is not included in flat configs
if (basename === 'stage-0') { return; }

expect(module.flatConfigs).to.have.property(basename);
});
done();
});
});

it('exports plugin meta object', function () {
expect(module.meta).to.be.an('object').that.has.all.keys('name', 'version');
expect(module.meta.name).to.equal('eslint-plugin-import');
expect(module.meta.version).to.be.a('string');
});

it('ensures the plugin object in the flat configs is identical to the module', function () {
for (const configFile in module.flatConfigs) {
expect(module.flatConfigs[configFile].plugins.import).to.equal(module);
}
});

function getRulePath(ruleName) {
// 'require' does not work with dynamic paths because of the compilation step by babel
// (which resolves paths according to the root folder configuration)
Expand Down
Loading