Skip to content

Commit

Permalink
Add .mjs and .cjs as default extensions (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Feb 20, 2021
1 parent 8156d42 commit 2e05c81
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
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'));
});

0 comments on commit 2e05c81

Please sign in to comment.