Skip to content

Commit

Permalink
build: bump prettier to 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bd82 committed Jul 12, 2023
1 parent 1719da4 commit 4a68802
Show file tree
Hide file tree
Showing 114 changed files with 1,326 additions and 1,257 deletions.
2 changes: 1 addition & 1 deletion examples/grammars/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const Uri = createToken({ name: "Uri", pattern: Lexer.NA });
const UriString = createToken({
name: "UriString",
pattern: MAKE_PATTERN(
"url\\((:?{{spaces}})?({{string1}}|{{string2}})(:?{{spaces}})?\\)"
"url\\((:?{{spaces}})?({{string1}}|{{string2}})(:?{{spaces}})?\\)",
),
categories: Uri,
});
Expand Down
16 changes: 8 additions & 8 deletions examples/grammars/ecma5/ecma5_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
{ ALT: () => $.SUBRULE($.ArrayLiteral) },
{ ALT: () => $.SUBRULE($.ObjectLiteral) },
{ ALT: () => $.SUBRULE($.ParenthesisExpression) },
])
]),
);
});

Expand Down Expand Up @@ -246,7 +246,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
{ ALT: () => $.CONSUME(t.Minus) },
{ ALT: () => $.CONSUME(t.Tilde) },
{ ALT: () => $.CONSUME(t.Exclamation) },
])
]),
);
$.SUBRULE($.UnaryExpression);
},
Expand Down Expand Up @@ -276,7 +276,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
ALT: () => $.CONSUME(t.AbsMultiplicativeOperator),
},
{ ALT: () => $.CONSUME(t.AbsAdditiveOperator) },
])
]),
);
$.SUBRULE2($.UnaryExpression);
});
Expand All @@ -303,7 +303,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
ALT: () => $.CONSUME(t.AbsMultiplicativeOperator),
},
{ ALT: () => $.CONSUME(t.AbsAdditiveOperator) },
])
]),
);
$.SUBRULE2($.UnaryExpression);
});
Expand Down Expand Up @@ -378,7 +378,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
{ ALT: () => $.SUBRULE($.ThrowStatement) },
{ ALT: () => $.SUBRULE($.TryStatement) },
{ ALT: () => $.SUBRULE($.DebuggerStatement) },
])
]),
);
});

Expand Down Expand Up @@ -575,7 +575,7 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
},
},
]);
}
},
);

// See 12.7
Expand Down Expand Up @@ -691,9 +691,9 @@ export class ECMAScript5Parser extends EmbeddedActionsParser {
// happening in this case because that type of recovery can only happen if CONSUME(...) was invoked.
this.SAVE_ERROR(
new MismatchedTokenException(
"Line Terminator not allowed before Expression in Throw Statement"
"Line Terminator not allowed before Expression in Throw Statement",
// TODO: create line terminator token on the fly?
)
),
);
}
$.SUBRULE($.Expression);
Expand Down
8 changes: 4 additions & 4 deletions examples/grammars/graphql/graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const createNotToken = function (config) {

// All matching keywords now match the category of the NOT token.
matchingKeywords.forEach((keywordTokType) =>
keywordTokType.CATEGORIES.push(newNotTokenCategory)
keywordTokType.CATEGORIES.push(newNotTokenCategory),
);

// Name always matches the Not token
Expand Down Expand Up @@ -251,20 +251,20 @@ const IntValue = createToken({
const FloatValue = createToken({
name: "FloatValue",
pattern: MAKE_PATTERN(
"{{IntegerPart}}{{FractionalPart}}({{ExponentPart}})?|{{IntegerPart}}{{ExponentPart}}"
"{{IntegerPart}}{{FractionalPart}}({{ExponentPart}})?|{{IntegerPart}}{{ExponentPart}}",
),
});
FRAGMENT("EscapedCharacter", '[\\\\/"bfnrt]');
FRAGMENT("EscapedUnicode", "[0-9a-fA-F]{4}");
FRAGMENT(
"StringCharacter",
'(?:[^\\\\"\\n\\r]|\\\\(?:{{EscapedUnicode}}|u{{EscapedCharacter}}))'
'(?:[^\\\\"\\n\\r]|\\\\(?:{{EscapedUnicode}}|u{{EscapedCharacter}}))',
);
FRAGMENT("BlockStringCharacter", '\\\\"""|[^"]|"(?!"")');
const StringValue = createToken({
name: "StringValue",
pattern: MAKE_PATTERN(
'"""(?:{{BlockStringCharacter}})*"""|"(?:{{StringCharacter}})*"'
'"""(?:{{BlockStringCharacter}})*"""|"(?:{{StringCharacter}})*"',
),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/grammars/xml/xml_lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ function createToken(options) {

FRAGMENT(
"NameStartChar",
"([a-zA-Z]|\\u2070-\\u218F|\\u2C00-\\u2FEF|\\u3001-\\uD7FF|\\uF900-\\uFDCF|\\uFDF0-\\uFFFD)"
"([a-zA-Z]|\\u2070-\\u218F|\\u2C00-\\u2FEF|\\u3001-\\uD7FF|\\uF900-\\uFDCF|\\uFDF0-\\uFFFD)",
);

FRAGMENT(
"NameChar",
makePattern`${f.NameStartChar}|-|_|\\.|\\d|\\u00B7||[\\u0300-\\u036F]|[\\u203F-\\u2040]`
makePattern`${f.NameStartChar}|-|_|\\.|\\d|\\u00B7||[\\u0300-\\u036F]|[\\u203F-\\u2040]`,
);
FRAGMENT("Name", makePattern`${f.NameStartChar}(${f.NameChar})*`);

Expand Down
4 changes: 2 additions & 2 deletions examples/lexer/custom_errors/custom_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ const OyVeyErrorMessageProvider = {
// eslint-disable-next-line no-unused-vars -- template
line,
// eslint-disable-next-line no-unused-vars -- template
column
column,
) {
return (
`Oy Vey!!! unexpected character: ->${fullText.charAt(
startOffset
startOffset,
)}<- at offset: ${startOffset},` + ` skipped ${length} characters.`
);
},
Expand Down
6 changes: 3 additions & 3 deletions examples/lexer/python_indentation/python_indentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function matchIndentBase(text, offset, matchedTokens, groups, type) {
else if (currIndentLevel < prevIndentLevel && type === "outdent") {
const matchIndentIndex = _.findLastIndex(
indentStack,
(stackIndentDepth) => stackIndentDepth === currIndentLevel
(stackIndentDepth) => stackIndentDepth === currIndentLevel,
);

// any outdent must match some previous indentation level.
Expand All @@ -89,7 +89,7 @@ function matchIndentBase(text, offset, matchedTokens, groups, type) {
for (let i = iStart; i < numberOfDedents; i++) {
indentStack.pop();
matchedTokens.push(
createTokenInstance(Outdent, "", NaN, NaN, NaN, NaN, NaN, NaN)
createTokenInstance(Outdent, "", NaN, NaN, NaN, NaN, NaN, NaN),
);
}

Expand Down Expand Up @@ -176,7 +176,7 @@ export function tokenize(text) {
//add remaining Outdents
while (indentStack.length > 1) {
lexResult.tokens.push(
createTokenInstance(Outdent, "", NaN, NaN, NaN, NaN, NaN, NaN)
createTokenInstance(Outdent, "", NaN, NaN, NaN, NaN, NaN, NaN),
);
indentStack.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/parser/content_assist/content_assist_complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function getContentAssistSuggestions(text, symbolTable) {

const syntacticSuggestions = parserInstance.computeContentAssist(
"startRule",
assistanceTokenVector
assistanceTokenVector,
);

let finalSuggestions = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ describe("The Official Content Assist Feature example Example", () => {
.to.have.members(["function"])
.and.to.have.lengthOf(1);
});
}
},
);
});
4 changes: 2 additions & 2 deletions examples/parser/content_assist/content_assist_simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export function getContentAssistSuggestions(text) {

const syntacticSuggestions = parserInstance.computeContentAssist(
"myRule",
partialTokenVector
partialTokenVector,
);

// The suggestions also include the context, we are only interested
// in the TokenTypes in this example.
const tokenTypesSuggestions = syntacticSuggestions.map(
(suggestion) => suggestion.nextTokenType
(suggestion) => suggestion.nextTokenType,
);

return tokenTypesSuggestions;
Expand Down
10 changes: 5 additions & 5 deletions examples/parser/custom_errors/custom_errors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe("The Chevrotain support for custom error provider", () => {
const errorsOverride = parseMismatch("A C");
expect(errorsOverride).to.have.lengthOf(1);
expect(errorsOverride[0].message).to.equal(
"expecting Bravo at end of mis_match"
"expecting Bravo at end of mis_match",
);

// we only modified the error for Bravo mismatches
const errorsDefault = parseMismatch("C");
expect(errorsDefault).to.have.lengthOf(1);
expect(errorsDefault[0].message).to.equal(
"Expecting token of type --> Alpha <-- but found --> 'C' <--"
"Expecting token of type --> Alpha <-- but found --> 'C' <--",
);
});

Expand All @@ -33,23 +33,23 @@ describe("The Chevrotain support for custom error provider", () => {
const errors = parseRedundant("A B C");
expect(errors).to.have.lengthOf(1);
expect(errors[0].message).to.equal(
"very bad dog! you still have some input remaining at offset:4"
"very bad dog! you still have some input remaining at offset:4",
);
});

it("can customize a NoViableAlt exception", () => {
const errors = parseNoViable("C");
expect(errors).to.have.lengthOf(1);
expect(errors[0].message).to.equal(
"Expecting: one of these possible Token sequences:\n 1. [Alpha]\n 2. [Bravo]\nbut found: 'C'"
"Expecting: one of these possible Token sequences:\n 1. [Alpha]\n 2. [Bravo]\nbut found: 'C'",
);
});

it("can customize a EarlyExit exception", () => {
const errors = parseEarlyExit("A");
expect(errors).to.have.lengthOf(1);
expect(errors[0].message).to.equal(
"Esperando por lo menos una iteración de: Bravo"
"Esperando por lo menos una iteración de: Bravo",
);
});
});
2 changes: 1 addition & 1 deletion examples/tutorial/step2_parsing/step2_parsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function parse(inputText) {
if (parserInstance.errors.length > 0) {
throw Error(
"Sad sad panda, parsing errors detected!\n" +
parserInstance.errors[0].message
parserInstance.errors[0].message,
);
}
}
4 changes: 2 additions & 2 deletions examples/tutorial/step2_parsing/step2_parsing_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ describe("Chevrotain Tutorial", () => {
// missing table name
let inputText = "SELECT FROM table2";
expect(() => parse(inputText)).to.throw(
"expecting at least one iteration which starts with one of these possible Token sequences"
"expecting at least one iteration which starts with one of these possible Token sequences",
);
expect(() => parse(inputText)).to.throw(
"<[Identifier]>\nbut found: 'FROM'"
"<[Identifier]>\nbut found: 'FROM'",
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/step3_actions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ console.log(JSON.stringify(astFromVisitor, null, "\t"));
assert.deepEqual(
astFromVisitor,
astFromEmbedded,
"Both ASTs should be identical"
"Both ASTs should be identical",
);
2 changes: 1 addition & 1 deletion examples/tutorial/step3_actions/step3a_actions_visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function toAstVisitor(inputText) {
if (parserInstance.errors.length > 0) {
throw Error(
"Sad sad panda, parsing errors detected!\n" +
parserInstance.errors[0].message
parserInstance.errors[0].message,
);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/step3_actions/step3b_actions_embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function toAstEmbedded(inputText) {
if (parserInstance.errors.length > 0) {
throw Error(
"Sad sad panda, parsing errors detected!\n" +
parserInstance.errors[0].message
parserInstance.errors[0].message,
);
}

Expand Down
22 changes: 11 additions & 11 deletions examples/tutorial/step4_error_recovery/step4_error_recovery_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Chevrotain Tutorial", () => {
let parsingResult = parseJsonToCst(invalidInput);
expect(parsingResult.parseErrors).to.have.lengthOf(1);
expect(parsingResult.parseErrors[0].message).to.include(
"Expecting token of type --> Colon <-- but found --> '666' <--"
"Expecting token of type --> Colon <-- but found --> '666' <--",
);
let minimizedCst = minimizeCst(parsingResult.cst);

Expand Down Expand Up @@ -116,7 +116,7 @@ describe("Chevrotain Tutorial", () => {
let parsingResult = parseJsonToCst(invalidInput);
expect(parsingResult.parseErrors).to.have.lengthOf(1);
expect(parsingResult.parseErrors[0].message).to.include(
"Expecting token of type --> Colon <-- but found --> '}' <--"
"Expecting token of type --> Colon <-- but found --> '}' <--",
);
let minimizedCst = minimizeCst(parsingResult.cst);

Expand Down Expand Up @@ -194,7 +194,7 @@ describe("Chevrotain Tutorial", () => {
let parsingResult = parseJsonToCst(invalidInput);
expect(parsingResult.parseErrors).to.have.lengthOf(1);
expect(parsingResult.parseErrors[0].message).to.include(
"Expecting token of type --> RCurly <-- but found --> '666'"
"Expecting token of type --> RCurly <-- but found --> '666'",
);
let minimizedCst = minimizeCst(parsingResult.cst);

Expand All @@ -205,15 +205,15 @@ describe("Chevrotain Tutorial", () => {
// because the parser will re-sync to the next comma "," as that is the expected next Token after a key/value pair.
expect(objectItemCstArr).to.have.lengthOf(3);
expect(objectItemCstArr[0].children.StringLiteral[0].image).to.equal(
'"key1"'
'"key1"',
);
expect(objectItemCstArr[1].children.StringLiteral[0].image).to.equal(
'"key2"'
'"key2"',
);
// key3 will be re-synced
// key4 appears in the input AFTER the error, yet due to error recovery it is still appears in the output
expect(objectItemCstArr[2].children.StringLiteral[0].image).to.equal(
'"key4"'
'"key4"',
);
});

Expand All @@ -228,7 +228,7 @@ describe("Chevrotain Tutorial", () => {
let parsingResult = parseJsonToCst(invalidInput);
expect(parsingResult.parseErrors).to.have.lengthOf(1);
expect(parsingResult.parseErrors[0].message).to.include(
"Expecting: one of these possible Token sequences:\n 1. [StringLiteral]\n 2. [NumberLiteral]\n 3. [LCurly]\n 4. [LSquare]\n 5. [True]\n 6. [False]\n 7. [Null]\nbut found: ':'"
"Expecting: one of these possible Token sequences:\n 1. [StringLiteral]\n 2. [NumberLiteral]\n 3. [LCurly]\n 4. [LSquare]\n 5. [True]\n 6. [False]\n 7. [Null]\nbut found: ':'",
);
let minimizedCst = minimizeCst(parsingResult.cst);

Expand All @@ -237,18 +237,18 @@ describe("Chevrotain Tutorial", () => {
minimizedCst.children.object[0].children.objectItem;
expect(objectItemCstArr).to.have.lengthOf(4);
expect(objectItemCstArr[0].children.StringLiteral[0].image).to.equal(
'"firstName"'
'"firstName"',
);
// There is an error inside "someData" value, but we still get the key back (and part of the value...)
expect(objectItemCstArr[1].children.StringLiteral[0].image).to.equal(
'"someData"'
'"someData"',
);
// These keys appear AFTER the error, yet they were still parsed successfully due to error recovery.
expect(objectItemCstArr[2].children.StringLiteral[0].image).to.equal(
'"isAlive"'
'"isAlive"',
);
expect(objectItemCstArr[3].children.StringLiteral[0].image).to.equal(
'"age"'
'"age"',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"lint-staged": "13.2.3",
"mocha": "10.2.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.8",
"prettier": "3.0.0",
"shx": "0.3.4",
"cz-conventional-changelog": "3.3.0",
"@commitlint/cli": "17.6.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/chevrotain/benchmark_web/parsers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function parseBench(
parser,
rootRule,
options,
parserConfig
parserConfig,
) {
if (lexerInstance === undefined) {
if (customLexer !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var Uri = createToken({ name: "Uri", pattern: Lexer.NA });
var UriString = createToken({
name: "UriString",
pattern: MAKE_PATTERN(
"url\\((:?{{spaces}})?({{string1}}|{{string2}})(:?{{spaces}})?\\)"
"url\\((:?{{spaces}})?({{string1}}|{{string2}})(:?{{spaces}})?\\)",
),
categories: Uri,
});
Expand Down
Loading

0 comments on commit 4a68802

Please sign in to comment.