File tree Expand file tree Collapse file tree
babel-eslint-tests/test/integration/eslint Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ export = function normalizeESLintConfig(options: any) {
1313 return {
1414 babelOptions : { cwd : process . cwd ( ) , ...babelOptions } ,
1515 ecmaVersion : ecmaVersion === "latest" ? 1e8 : ecmaVersion ,
16- sourceType,
16+ // https://eslint.org/docs/latest/use/configure/language-options#specifying-javascript-options
17+ // ESLint supports "commonjs" but Babel parser does not.
18+ sourceType : sourceType === "commonjs" ? "script" : sourceType ,
1719 requireConfigFile,
1820 ...otherOptions ,
1921 } as Options ;
Original file line number Diff line number Diff line change @@ -20,4 +20,19 @@ describe("ESLint config", () => {
2020 } ,
2121 ) ;
2222 } ) ;
23+
24+ it ( 'should allow sourceType to be "commonjs"' , ( ) => {
25+ // sourceType "commonjs" allows require() calls.
26+ verifyAndAssertMessages (
27+ 'require("greetings").hello' ,
28+ { } ,
29+ undefined ,
30+ undefined ,
31+ {
32+ parserOptions : {
33+ sourceType : "commonjs" ,
34+ } ,
35+ } ,
36+ ) ;
37+ } ) ;
2338} ) ;
You can’t perform that action at this time.
0 commit comments