File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ required):
8686 will be valid, even if ` ecmaVersion ` is less than 6. If set to ` "commonjs" ` ,
8787 it is the same as ` "script" ` except that the top-level scope behaves like a function.
8888
89+ - ** strict** : When set to true, enable strict parsing mode even if
90+ ` sourceType ` is ` "script" ` .
91+
8992- ** onInsertedSemicolon** : If given a callback, that callback will be
9093 called whenever a missing semicolon is inserted by the parser. The
9194 callback will be given the character offset of the point where the
Original file line number Diff line number Diff line change @@ -619,6 +619,12 @@ export interface Options {
619619 */
620620 sourceType ?: "script" | "module" | "commonjs"
621621
622+ /**
623+ * When set to true, enable strict parsing mode even if `sourceType`
624+ * is `"script"`.
625+ */
626+ strict ?: boolean
627+
622628 /**
623629 * a callback that will be called when a semicolon is automatically inserted.
624630 * @param lastTokEnd the position of the comma as an offset
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ export const defaultOptions = {
1616 // Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
1717 // strict mode and parsing of `import` and `export` declarations.
1818 sourceType : "script" ,
19+ // When set to true, enable strict parsing mode even if `sourceType`
20+ // is `"script"`.
21+ strict : false ,
1922 // `onInsertedSemicolon` can be a callback that will be called when
2023 // a semicolon is automatically inserted. It will be passed the
2124 // position of the inserted semicolon as an offset, and if
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export class Parser {
6464
6565 // Figure out if it's a module code.
6666 this . inModule = options . sourceType === "module"
67- this . strict = this . inModule || this . strictDirective ( this . pos )
67+ this . strict = this . inModule || options . strict == true || this . strictDirective ( this . pos )
6868
6969 // Used to signify the start of a potential arrow function
7070 this . potentialArrowAt = - 1
You can’t perform that action at this time.
0 commit comments