Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .mjs and .cjs as default extensions #521

Merged
merged 1 commit into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const TYPESCRIPT_EXTENSION = [
const DEFAULT_EXTENSION = [
'js',
'jsx',
'mjs',
'cjs',
...TYPESCRIPT_EXTENSION
];

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ Use one or more [shareable configs](https://eslint.org/docs/developer-guide/shar

Type: `string[]`

Allow more extensions to be linted besides `.js` and `.jsx`. Make sure they're supported by ESLint or an ESLint plugin.
Allow more extensions to be linted besides `.js`, `.jsx`, `.mjs`, and `.cjs`. Make sure they're supported by ESLint or an ESLint plugin.

### settings

Expand Down
4 changes: 2 additions & 2 deletions test/cli-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ test('space option with boolean strings', async t => {

test('extension option', async t => {
const cwd = path.join(__dirname, 'fixtures/custom-extension');
const {stdout} = await t.throwsAsync(main(['--reporter=json', '--extension=mjs'], {cwd}));
const {stdout} = await t.throwsAsync(main(['--reporter=json', '--extension=unknown'], {cwd}));
const reports = JSON.parse(stdout);

t.is(reports.length, 1);
t.true(reports[0].filePath.endsWith('.mjs'));
t.true(reports[0].filePath.endsWith('.unknown'));
});