Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix: do not fail on unknown operators from custom parsers (fixes #10475…
…) (#10476)
- Loading branch information
1 parent
05343fd
commit f93d6ff
Showing
3 changed files
with
193 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
tests/fixtures/parsers/unknown-operators/unknown-logical-operator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/** | ||
* The output AST has been modified to represent an unknown operator | ||
* (replaced ?? with %%) | ||
* | ||
* Parser: babel-eslint v8.2.3 | ||
* (with this fix for tokens: https://github.com/babel/babel-eslint/pull/632) | ||
* Source code: | ||
* null ?? 'foo' | ||
*/ | ||
|
||
exports.parse = () => ({ | ||
type: "Program", | ||
start: 0, | ||
end: 13, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 13 | ||
} | ||
}, | ||
range: [0, 13], | ||
comments: [], | ||
tokens: [ | ||
{ | ||
type: "Null", | ||
value: "null", | ||
start: 0, | ||
end: 4, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 4 | ||
} | ||
}, | ||
range: [0, 4] | ||
}, | ||
{ | ||
type: "Punctuator", | ||
value: "%%", | ||
start: 5, | ||
end: 7, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 5 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 7 | ||
} | ||
}, | ||
range: [5, 7] | ||
}, | ||
{ | ||
type: "String", | ||
value: "'foo'", | ||
start: 8, | ||
end: 13, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 8 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 13 | ||
} | ||
}, | ||
range: [8, 13] | ||
} | ||
], | ||
sourceType: "script", | ||
body: [ | ||
{ | ||
type: "ExpressionStatement", | ||
start: 0, | ||
end: 13, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 13 | ||
} | ||
}, | ||
range: [0, 13], | ||
expression: { | ||
type: "LogicalExpression", | ||
start: 0, | ||
end: 13, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 13 | ||
} | ||
}, | ||
range: [0, 13], | ||
left: { | ||
type: "Literal", | ||
start: 0, | ||
end: 4, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 4 | ||
} | ||
}, | ||
range: [0, 4], | ||
value: null, | ||
raw: "null", | ||
_babelType: "Literal" | ||
}, | ||
operator: "%%", | ||
right: { | ||
type: "Literal", | ||
start: 8, | ||
end: 13, | ||
loc: { | ||
start: { | ||
line: 1, | ||
column: 8 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 13 | ||
} | ||
}, | ||
range: [8, 13], | ||
value: "foo", | ||
raw: "'foo'", | ||
_babelType: "Literal" | ||
}, | ||
_babelType: "LogicalExpression" | ||
}, | ||
_babelType: "ExpressionStatement" | ||
} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters