You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: eslint/babel-eslint-parser/README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,25 +53,25 @@ Additional configuration options can be set in your ESLint configuration under t
53
53
Note: When `requireConfigFile` is `false`, @babel/eslint-parser will still try to load the root babel config. If no configuration file is found, @babel/eslint-parser will not parse any experimental syntax. Though not recommended, if you have a babel config, but would like to prevent @babel/eslint-parser from loading Babel config, please specify
54
54
**.eslintrc.js**
55
55
56
-
```js
57
-
module.exports= {
58
-
parser:"@babel/eslint-parser",
59
-
parserOptions: {
60
-
requireConfigFile:false,
61
-
babelOptions: {
62
-
babelrc:false,
63
-
configFile:false,
64
-
// your babel options
65
-
presets: ["@babel/preset-env"],
56
+
```js
57
+
module.exports= {
58
+
parser:"@babel/eslint-parser",
59
+
parserOptions: {
60
+
requireConfigFile:false,
61
+
babelOptions: {
62
+
babelrc:false,
63
+
configFile:false,
64
+
// your babel options
65
+
presets: ["@babel/preset-env"],
66
+
},
66
67
},
67
-
},
68
-
};
69
-
```
68
+
};
69
+
```
70
70
71
-
-`sourceType` can be set to `"module"`(default) or `"script"`if your code isn't using ECMAScript modules.
71
+
-`sourceType` can be set to `"module"`(default), `"script"`or `"commonjs"`.
72
72
<!-- TODO(Babel 8): Remove this -->
73
73
-`allowImportExportEverywhere` (default `false`) can be set to `true` to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level.
74
-
-`ecmaFeatures.globalReturn` (default `false`) allow return statements in the global scope when used with `sourceType: "script"`.
74
+
-`ecmaFeatures.globalReturn` (default `false`) allow return statements in the global scope when used with `sourceType: "script"`. This option will be deprecated, please use `sourceType: "commonjs"` instead.
75
75
-`babelOptions` is an object containing Babel configuration [options](https://babeljs.io/docs/en/options) that are passed to Babel's parser at runtime. For cases where users might not want to use a Babel configuration file or are running Babel through another tool (such as Webpack with `babel-loader`).
Copy file name to clipboardExpand all lines: packages/babel-parser/data/schema.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -252,8 +252,8 @@
252
252
"type": "string"
253
253
},
254
254
"sourceType": {
255
-
"description": "Indicate the mode the code should be parsed in.\nCan be one of \"script\", \"module\", or \"unambiguous\". Defaults to \"script\".\n\"unambiguous\" will make @babel/parser attempt to guess, based on the presence\nof ES6 import or export statements.\nFiles with ES6 imports and exports are considered \"module\" and are otherwise \"script\".",
256
-
"enum": ["module", "script", "unambiguous"],
255
+
"description": "Indicate the mode the code should be parsed in.\nCan be one of \"script\", \"commonjs\", \"module\", or \"unambiguous\". Defaults to \"script\".\n\"unambiguous\" will make @babel/parser attempt to guess, based on the presence\nof ES6 import or export statements.\nFiles with ES6 imports and exports are considered \"module\" and are otherwise \"script\".",
"The `allowAwaitOutsideFunction` option cannot be used with `sourceType: 'commonjs'`.",
270
+
);
271
+
}
272
+
if(opts.allowReturnOutsideFunction!=null){
273
+
thrownewError(
274
+
"`sourceType: 'commonjs'` implies `allowReturnOutsideFunction: true`, please remove the `allowReturnOutsideFunction` option or use `sourceType: 'script'`.",
275
+
);
276
+
}
277
+
if(opts.allowNewTargetOutsideFunction!=null){
278
+
thrownewError(
279
+
"`sourceType: 'commonjs'` implies `allowNewTargetOutsideFunction: true`, please remove the `allowNewTargetOutsideFunction` option or use `sourceType: 'script'`.",
0 commit comments