Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
getSourceCode
✓ const { getSourceCode } = require('eslint-compat-utils')
✗ import { getSourceCode } from 'eslint-compat-utils'
Package does not ship native ESM; use CJS require or configure bundler to handle CJS. ESM support is planned but not yet implemented. Always use require().
getCwd
✓ const { getCwd } = require('eslint-compat-utils')
✗ const getCwd = require('eslint-compat-utils').default
No default export; import named exports only.
getFilename
✓ const { getFilename } = require('eslint-compat-utils')
✗ import { getFilename } from 'eslint-compat-utils'
Same as above — CJS only for now.
Shows an ESLint rule that uses getSourceCode and getFilename from eslint-compat-utils to remain compatible with ESLint v6–v9.
// eslint rule using eslint-compat-utils
const { getSourceCode, getFilename } = require('eslint-compat-utils');
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'disallow use of process.env',
},
fixable: null,
schema: [],
},
create(context) {
const sourceCode = getSourceCode(context);
const filename = getFilename(context);
return {
MemberExpression(node) {
if (
node.object.type === 'Identifier' &&
node.object.name === 'process' &&
node.property.type === 'Identifier' &&
node.property.name === 'env'
) {
context.report({
node,
message: 'Unexpected use of process.env in {{filename}}.',
data: { filename },
});
}
},
};
},
};
Errors
Common errors & fixes
Cannot find module 'eslint-compat-utils'
Package not installed or missing from node_modules.
fixRun: npm install eslint-compat-utils --save-dev
TypeError: eslint_compat_utils_1.getSourceCode is not a function
Trying to import ESM style with 'import', but package exports CJS only.
fixChange to: const { getSourceCode } = require('eslint-compat-utils'); Error: eslint-compat-utils is not compatible with eslint version x.x.x
ESLint version is below 6.0.0 or above supported range.
fixUpgrade eslint to >=6.0.0 and <10.0.0.
Audit
Dependencies
eslintrequiredPeer dependency; requires eslint >=6.0.0