From 7b50fd9ddbace0f0286ec51cbec52a47f7ca8834 Mon Sep 17 00:00:00 2001 From: Thom Smith Date: Tue, 22 Jun 2021 10:51:41 -0400 Subject: [PATCH] Patch flow bugs (again). --- JavaScript (Babel).sublime-syntax | 4876 +++++++++++++++-------------- tests/syntax_test_flow.js | 5 +- 2 files changed, 2450 insertions(+), 2431 deletions(-) diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax index 8d53d5e..ee54ef8 100644 --- a/JavaScript (Babel).sublime-syntax +++ b/JavaScript (Babel).sublime-syntax @@ -1,297 +1,202 @@ %YAML 1.2 --- version: 2 -first_line_match: ^#!\s*/.*\b(node|js)\b -variables: - identifier_break: (?!{{identifier_part}}) - func_lookahead: |- - (?x: - (?:async{{identifier_break}}{{nothing}})? - function{{identifier_break}} - ) - either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - function_call_lookahead: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - function_assignment_lookahead: |- - (?x:(?= - \s* = \s* - {{either_func_lookahead}} - )) - oct_digit: '[0-7_]' - identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) - line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) - hex_digit: '[\h_]' - property_name: >- - (?x: - {{identifier_name}} - | [0-9]+ - | '(?:[^\\']|\\.)*' - | "(?:[^\\"]|\\.)*" - | \[ .* \] - ) - identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) - block_comment: (?:/\*{{block_comment_contents}}\*/) - jsdoc_block_tag: \@[^\n\t\f\v *@]+ - identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) - nothing: (?x:(?:\s+|{{block_comment}})*) - block_comment_contents: (?:(?:[^*]|\*(?!/))*) - bin_digit: '[01_]' - left_expression_end_lookahead: (?!\s*[.\[\(]) - jsx_identifier_part: (?:{{identifier_part}}|-) - arrow_func_lookahead: |- - (?x)(?: - \s*(async\s*)? - (?: - {{non_reserved_identifier}} - |\( (?: [^()]|\([^()]*\) )* \) - ) - (?: - \s*: - \s*{{non_reserved_identifier}} - )? - \s*=> - ) - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) - reserved_word: |- - (?x: - break|case|catch|class|const|continue|debugger|default|delete|do|else| - export|extends|finally|for|function|if|import|in|instanceof|new|return| - super|switch|this|throw|try|typeof|var|void|while|with|yield| - enum| - null|true|false - ){{identifier_break}} - constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) - jsx_identifier_break: (?!{{jsx_identifier_part}}) - dec_digit: '[0-9_]' - modifier: (?:static{{identifier_break}}) - method_lookahead: |- - (?x)(?= - (?: get|set|async ){{identifier_break}}(?!\s*:) - | \* - | {{property_name}} \s* (?:\(|<) - ) - dec_integer: (?:0|[1-9]{{dec_digit}}*) - binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) - class_element_name: |- - (?x: - \+? - (?: - \*? - {{property_name}} - | \#{{non_reserved_identifier}} - ) - ) - dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' - dot_accessor: (?:\??\.) - line_continuation_lookahead: >- - (?x:(?= - (?! \+\+ | -- ) - (?= - != | - [-+*/%><=&|^\[(;,.:?] | - (?:in|instanceof){{identifier_break}} - ) - )) - dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) - dollar_only_identifier: (?:\${{identifier_break}}) - identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) - jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' -scope: source.js contexts: - await-expression: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js - - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation - - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - include: jsx-html-escapes - - match: '"' + literal-string-template: + - match: '`' scope: punctuation.definition.string.begin.js set: - meta_include_prototype: false - - meta_scope: string.quoted.double.js - - match: \" + - meta_scope: meta.string.js string.quoted.other.js + - match: '`' scope: punctuation.definition.string.end.js pop: true - - include: jsx-html-escapes + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded + - match: \} + scope: punctuation.section.interpolation.end.js + pop: true + - match: (?=\S) + push: expression + - include: string-content + variable-binding-list-top: + - match: '{{line_ending_ahead}}' + set: + - match: '{{line_continuation_lookahead}}' + set: variable-binding-top + - include: else-pop + - match: ',' + scope: punctuation.separator.comma.js + push: variable-binding-top - include: else-pop - function-declaration-expect-parameters: - - include: function-declaration-parameters + prefixed-object-literal-method: + - match: (?:get|set){{identifier_break}} + scope: storage.type.accessor.js + set: + - meta_scope: meta.function.js + - match: (?={{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-object-literal-method + - match: (?:async){{identifier_break}} + scope: keyword.declaration.async.js + set: + - meta_scope: meta.function.js + - match: (?=\*|{{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-object-literal-method + + object-property-name: + - match: (?=\[) + set: computed-property-name + + - include: literal-string + - include: literal-number + + - match: '{{identifier_name}}' + pop: true + - include: else-pop - class-field: + arrow-function-declaration: + - meta_include_prototype: false - match: '' set: - - initializer - - flow-type-annotation-optional - - class-field-check - - field-name + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow + - flow-arrow-function-return-type-annotation + - arrow-function-expect-parameters - variable-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: variable-binding-pattern + arrow-function-expect-parameters: + - match: (?={{identifier_start}}) + set: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js + - match: '{{identifier_name}}' + scope: variable.parameter.function.js + pop: true + - include: function-declaration-parameters - include: else-pop - literal-number: - # floats - - match: |- - (?x: - # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1 - {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} ) - # .1, .1e1, .1e-1 - | (\.) {{dec_digit}}+ (?:{{dec_exponent}})? - ){{identifier_break}} - scope: meta.number.float.decimal.js constant.numeric.value.js - captures: - 1: punctuation.separator.decimal.js - 2: punctuation.separator.decimal.js + call-method-name: + - include: support-property + - match: '{{identifier_name}}' + scope: variable.function.js pop: true - - # integers - - match: (0)({{dec_digit}}+){{identifier_break}} - scope: meta.number.integer.octal.js + - match: (#){{identifier_name}} + scope: variable.function.js captures: - 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js - 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js + 1: punctuation.definition.js pop: true + - include: else-pop - - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.hexadecimal.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js + call-function-name: + - match: '{{dollar_only_identifier}}' + scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js pop: true - - - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.octal.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js + - match: '{{identifier_name}}' + scope: variable.function.js pop: true + - include: else-pop - - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} - scope: meta.number.integer.binary.js - captures: - 1: constant.numeric.base.js - 2: constant.numeric.value.js - 3: constant.numeric.suffix.js - pop: true + function-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements - - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} - scope: meta.number.integer.decimal.js - captures: - 1: constant.numeric.value.js - 2: constant.numeric.suffix.js - pop: true - - # illegal numbers - - match: 0[Xx]{{identifier_part}}+ - scope: invalid.illegal.numeric.hexadecimal.js + support-property-ecma-json: + - match: (?:parse|stringify){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: 0[Bb]{{identifier_part}}+ - scope: invalid.illegal.numeric.binary.js + special-name: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js pop: true - - - match: 0{{identifier_part}}+ - scope: invalid.illegal.numeric.octal.js + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js pop: true - - - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' - scope: invalid.illegal.numeric.decimal.js + - match: null{{identifier_break}} + scope: constant.language.null.js pop: true - - else-pop: - - match: (?=\S) + - match: super{{identifier_break}} + scope: variable.language.super.js pop: true - - flow-type-module-contents: - - match: \} - scope: punctuation.section.block.end.js + - match: this{{identifier_break}} + scope: variable.language.this.js pop: true - - include: main - - expression-begin: - - include: jsx-tag - - - match: (?=`) - set: - - include: literal-string-template-custom-comments - - include: literal-string-template-custom-lookahead - - include: literal-string-template - - - include: expression-break - - - include: yield-expression - - include: await-expression - - include: regexp-complete - - include: literal-string - - include: tagged-template - - include: literal-string-template - - include: constructor - - include: literal-number - - include: prefix-operators - - include: import-meta-expression + with-meta: + - meta_include_prototype: false + - meta_scope: meta.with.js + - include: immediately-pop - - include: class - - include: special-name + inherited-class-expression-end: + - include: flow-type-generic-arguments - - include: regular-function + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: inherited-class-name + - include: object-property - - match: (?={{reserved_word}}) - pop: true + - include: left-expression-end - - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + jsx-interpolation-comment: + - match: ({)(/\*) + captures: + 1: punctuation.definition.interpolation.begin.js + 2: punctuation.definition.comment.begin.js set: - - function-name-meta - - literal-variable - - - include: object-literal + - meta_include_prototype: false + - meta_scope: meta.interpolation.js comment.block.js + - match: (\*/)(}) + captures: + 1: punctuation.definition.comment.end.js + 2: punctuation.definition.interpolation.end.js + pop: true + - match: (?=\*/) + fail: jsx-interpolation-comment - # Newline not allowed between `async` and parameters. - - match: (?=async{{identifier_break}}{{nothing}}(?:\(|{{identifier_start}})) - pop: true - branch_point: async-arrow-function - branch: - - async-arrow-function - - literal-variable + import-export-from: + - match: from{{identifier_break}} + scope: keyword.control.import-export.js + set: literal-string + - include: else-pop - - include: literal-call + block: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements - - match: (?={{identifier_start}}) + object-literal-element: + - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' + scope: variable.other.readwrite.js pop: true - branch_point: bare-arrow-function - branch: - - branch-possible-bare-arrow-function - - bare-arrow-function-fallback - - - match: (?=\() + - match: (?=\S) pop: true - branch_point: parenthesized-arrow-function + branch_point: object-literal-property branch: - - branch-possible-parenthesized-arrow-function - - parenthesized-arrow-function-fallback - - - include: array-literal - - - include: literal-private-variable - - - include: else-pop + - object-literal-property + - method-declaration constructor: - match: new{{identifier_break}} @@ -306,272 +211,126 @@ contexts: - constructor-body-expect-class-end - constructor-body-expect-class-begin - expression-end: - - include: postfix-operators - - include: binary-operators - - include: ternary-operator + literal-number: + # floats + - match: |- + (?x: + # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1 + {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} ) + # .1, .1e1, .1e-1 + | (\.) {{dec_digit}}+ (?:{{dec_exponent}})? + ){{identifier_break}} + scope: meta.number.float.decimal.js constant.numeric.value.js + captures: + 1: punctuation.separator.decimal.js + 2: punctuation.separator.decimal.js + pop: true - - include: left-expression-end + # integers + - match: (0)({{dec_digit}}+){{identifier_break}} + scope: meta.number.integer.octal.js + captures: + 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js + 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js + pop: true - flow-type-object-indexer-type: - - match: \] - scope: punctuation.section.brackets.end.js + - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.hexadecimal.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js pop: true - - include: flow-type-list - support: - - include: support-variable-ecma - - include: support-variable-console - - include: support-variable-dom - - include: support-variable-node + - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.octal.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: true - flow-type-alias: - - match: (?=type{{identifier_break}}) - set: - - - match: (?={{non_reserved_identifier}}) - set: - - - meta_scope: meta.declaration.type.js - - match: '' - pop: true - - flow-type-alias-initializer - - flow-type-generic-parameters - - - match: '{{non_reserved_identifier}}' - scope: entity.name.type.js - pop: true - - - include: else-pop + - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.binary.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: true - - match: (?=\S) - set: [expression-statement, expression-end] - - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}})) - scope: keyword.declaration.js - set: - - meta_scope: meta.declaration.type.js - - include: else-pop - - include: expression-begin + - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} + scope: meta.number.integer.decimal.js + captures: + 1: constant.numeric.value.js + 2: constant.numeric.suffix.js + pop: true - immediately-pop-2: - - meta_include_prototype: false - - match: '' - pop: 2 + # illegal numbers + - match: 0[Xx]{{identifier_part}}+ + scope: invalid.illegal.numeric.hexadecimal.js + pop: true - block-meta: - - meta_include_prototype: false - - meta_scope: meta.block.js - - include: immediately-pop + - match: 0[Bb]{{identifier_part}}+ + scope: invalid.illegal.numeric.binary.js + pop: true - try-meta: - - meta_include_prototype: false - - meta_scope: meta.try.js - - include: immediately-pop + - match: 0{{identifier_part}}+ + scope: invalid.illegal.numeric.octal.js + pop: true - branch-possible-bare-arrow-function: - - meta_include_prototype: false - - match: '' - push: - - detect-bare-arrow - - literal-variable + - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' + scope: invalid.illegal.numeric.decimal.js + pop: true - variable-binding-object-destructuring: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.binding.destructuring.mapping.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: variable-binding-spread - - match: (?={{identifier_start}}|\[|'|") - push: - - initializer - - variable-binding-object-alias - - object-literal-meta-key - - variable-binding-object-key - - include: comma-separator - - import-check-branch: - - match: (?=[.(]) # Recovery for import expressions - fail: import-statement - - include: else-pop - - for-condition: - - match: \( - scope: punctuation.section.group.js - set: - - for-condition-end - - for-condition-contents - - include: else-pop - - label: - - match: ({{identifier_name}})\s*(:) - captures: - 1: entity.name.label.js - 2: punctuation.separator.js - - expression-statement-end: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: expression-statement-end - - include: else-pop - - include: expression-end - - literal-string-template-custom-tags: [] - function-call-arguments: - - match: ({{dot_accessor}})?(\() - captures: - 1: punctuation.accessor.js - 2: punctuation.section.group.begin.js - set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - - include: expression-list - - decorator-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js + variable-binding-list: + - include: comma-separator + - match: (?={{binding_pattern_lookahead}}) push: - - include: decorator-name - - include: object-property - - - include: left-expression-end - - main: - - include: comments-top-level - - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - # Don't pop or embedding could break. - - - include: statements - - prefixed-method: - - match: (?:get|set){{identifier_break}} - scope: storage.type.accessor.js - set: - - meta_scope: meta.function.js - - match: (?={{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-method - - match: (?:async){{identifier_break}} - scope: keyword.declaration.async.js - set: - - meta_scope: meta.function.js - - match: (?=\*|{{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-method - - for-meta: - - meta_include_prototype: false - - meta_scope: meta.for.js - - include: immediately-pop - - function-declaration-expect-generator-star: - - match: \* - scope: keyword.declaration.generator.js - pop: true + - initializer + - variable-binding-pattern - include: else-pop - flow-type-tuple: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list - - object-property-base: - - match: '{{dollar_only_identifier}}' - scope: meta.property.object.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: meta.property.object.dollar.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: meta.property.object.js - pop: true - - match: '{{identifier_part}}+{{identifier_break}}' - scope: invalid.illegal.illegal-identifier.js - pop: true - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: meta.property.object.js - pop: true - - flow-type: - - match: '' - set: - - flow-type-end - - flow-type-begin - - detect-bare-arrow: - - match: (?==>) - fail: bare-arrow-function - - match: (?=\S) - pop: 2 + flow-type-annotation-optional: + - match: \?(?=:) + scope: storage.modifier.optional.js + - include: flow-type-annotation - support-property-ecma: - - match: constructor{{identifier_break}} - scope: variable.language.constructor.js - pop: true - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js - pop: true + inherited-class-expression-begin: + - include: inherited-class-name + - include: expression-begin - - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} - scope: support.function.js + support-property-ecma-reflect: + - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} + scope: support.function.builtin.js pop: true - # Annex B - - match: __proto__{{identifier_break}} - scope: invalid.deprecated.js variable.language.prototype.js - pop: true - - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} - scope: invalid.deprecated.js support.function.js + support-property-ecma-string: + - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} + scope: support.function.builtin.js pop: true - flow-type-object-indexer-label: - - match: ({{non_reserved_identifier}})\s*(:) - captures: - 1: meta.object-literal.key.js - 2: punctuation.separator.key-value.js - pop: true - - include: else-pop + class-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: class-body-contents - flow-type-generic-arguments: - - match: < - scope: punctuation.section.generic.begin.js - set: - - meta_scope: meta.generic.js - - match: '>' - scope: punctuation.section.generic.end.js - pop: true - - include: flow-type-list - include: else-pop - jsdoc-comment: + expression-no-comma: - meta_include_prototype: false - - meta_scope: comment.block.documentation.js - - match: \*/ - scope: punctuation.definition.comment.end.js - pop: 1 - # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation - # line so directly after the '/**' or after the '*' marker on the next lines. - - match: ^\s*(\*)(?!/) - captures: - 1: punctuation.definition.comment.js - push: jsdoc-block-tag + - match: '' + set: [expression-end-no-comma, expression-begin] - support-property-ecma-object: - - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} + function-parameter-binding-list: + - match: ',' + scope: punctuation.separator.parameter.function.js + - include: function-parameter-binding-spread + - match: (?={{binding_pattern_lookahead}}) + push: function-parameter + - include: else-pop + + support-property-ecma-date: + - match: (?:now|parse|UTC){{identifier_break}} scope: support.function.builtin.js pop: true @@ -583,252 +342,349 @@ contexts: - export-item - include: else-pop - comma-separator: - - match: ',' - scope: punctuation.separator.comma.js - - constructor-body-expect-class-end: - - include: property-access - - include: else-pop - - jsx-body: + for-meta: - meta_include_prototype: false + - meta_scope: meta.for.js + - include: immediately-pop - - match: < - scope: punctuation.definition.tag.begin.js + jsx-tag-name: + - match: '' set: - - meta_scope: meta.tag.js - - - match: / - scope: punctuation.definition.tag.begin.js - set: - - jsx-expect-tag-end - - jsx-tag-name + - - clear_scopes: 1 + - meta_scope: meta.tag.name.js + - include: immediately-pop + - jsx-tag-name-component - - match: (?=\S) - set: - - jsx-body - - jsx-tag-attributes - - jsx-tag-name + object-literal-contents: + - meta_scope: meta.mapping.js - - include: jsx-html-escapes - - include: jsx-interpolation - jsx-interpolation-plain: - - match: '{' - scope: punctuation.definition.interpolation.begin.js - set: - - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.jsx - - match: '}' - scope: punctuation.definition.interpolation.end.js - pop: true - - expression + - match: \} + scope: punctuation.section.block.end.js + pop: true - inherited-class-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js + - match: \.\.\. + scope: keyword.operator.spread.js + push: expression-no-comma + + - match: >- + (?x)(?= + {{property_name}}\s*:\s* + {{either_func_lookahead}} + ) push: - - include: inherited-class-name - - include: object-property + - object-literal-meta-key + - method-name - - include: left-expression-end + - match: (?=\*) + push: method-declaration + + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-object-literal-method + branch: + - prefixed-object-literal-method + - object-literal-element + + - match: (?={{property_name}}) + push: object-literal-element + + - include: comma-separator + + - match: ':' + scope: punctuation.separator.key-value.js + push: expression-no-comma + + # If there's any garbage, parse it as an expression + # so that close braces won't break things. + - match: (?=\S) + push: expression-no-comma block-scope: - include: block - include: else-pop - jsx-interpolation-comment: - - match: ({)(/\*) - captures: - 1: punctuation.definition.interpolation.begin.js - 2: punctuation.definition.comment.begin.js + for-condition-contents: + # This could be either type of for loop. + - match: (?:const|let|var){{identifier_break}} + scope: storage.type.js set: - - meta_include_prototype: false - - meta_scope: meta.interpolation.js comment.block.js - - match: (\*/)(}) - captures: - 1: punctuation.definition.comment.end.js - 2: punctuation.definition.interpolation.end.js - pop: true - - match: (?=\*/) - fail: jsx-interpolation-comment + - - include: for-of-rest + - match: (?=\S) + set: + - for-oldstyle-rest + - variable-binding-list + - initializer + - variable-binding-pattern - flow-type-declare: - - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) - scope: keyword.declaration.js + - match: (?=\S) set: - - match: opaque{{identifier_break}} - scope: storage.modifier.js - pop: true - - match: module{{identifier_break}} - scope: keyword.declaration.js - set: - - flow-type-module-meta - - flow-type-module-body - - flow-type-module-name - - match: export{{identifier_break}} - scope: keyword.declaration.js - set: flow-type-declare-export - - include: else-pop + - - include: for-of-rest + - match: (?=\S) + set: for-oldstyle-rest + - expression-end-no-in + - expression-begin - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js + immediately-pop: + - match: '' pop: true - - include: else-pop - inherited-class-name: - - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' - scope: entity.other.inherited-class.js - pop: true + flow-type-function: + - match: \( + scope: punctuation.section.grouping.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.grouping.end.js + pop: true + - include: flow-type-list - call-function-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.js - - include: else-pop + parenthesized-expression: + - match: \( + scope: punctuation.section.group.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - match: (?=:) + push: flow-type-annotation + - match: (?=\S) + push: expression - export-extended: - - include: flow-type-export-type + statement: + - include: flow-type-declare + - include: flow-type-alias + + - match: \; + scope: punctuation.terminator.statement.empty.js + pop: true + - include: import-statement-or-import-meta + - include: export-statement + - include: conditional + - include: block + - include: label - include: variable-declaration - - include: class - - include: regular-function - - match: default{{identifier_break}} - scope: keyword.control.import-export.js + - match: break{{identifier_break}} + scope: keyword.control.flow.break.js set: - - include: class - - include: regular-function - - match: (?=\S) - set: expression-statement + - expect-semicolon + - expect-label - - match: (?=\S) + - match: continue{{identifier_break}} + scope: keyword.control.flow.continue.js set: - expect-semicolon - - import-export-from - - export-list - - import-export-alias - - export-item + - expect-label - flow-type-alias-initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: - - flow-type-meta - - flow-type - - include: else-pop - comments-top-level: - - match: ^(#!).*$\n? - scope: comment.line.shebang.js - captures: - 1: punctuation.definition.comment.js + - match: debugger{{identifier_break}} + scope: keyword.control.flow.debugger.js + set: expect-semicolon - function-parameter-binding-list: - - match: ',' - scope: punctuation.separator.parameter.function.js - - include: function-parameter-binding-spread - - match: (?={{binding_pattern_lookahead}}) - push: function-parameter - - include: else-pop + - match: return{{identifier_break}} + scope: keyword.control.flow.return.js + set: restricted-production - function-block: - - match: \{ - scope: punctuation.section.block.begin.js + - match: throw{{identifier_break}} + scope: keyword.control.flow.throw.js + set: restricted-production + + - include: class + - include: regular-function + + - include: decorator + + - include: expression-statement + + variable-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js pop: true - - include: statements + - include: variable-binding-spread + - include: variable-binding-list - prototype: - - include: comments + comma-separator: + - match: ',' + scope: punctuation.separator.comma.js - method-name: - - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js entity.name.function.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: entity.name.function.js - pop: true - - match: (#){{identifier_name}} - scope: entity.name.function.js - captures: - 1: punctuation.definition.js - pop: true - - match: "'" - scope: punctuation.definition.string.begin.js + function-parameter-binding-pattern: + - match: '' set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - meta_content_scope: entity.name.function.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - meta_content_scope: entity.name.function.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content + - - include: flow-type-annotation-optional + - - include: function-parameter-binding-name + - include: function-parameter-binding-array-destructuring + - include: function-parameter-binding-object-destructuring + - include: else-pop - - match: (?=\[) - push: computed-property-name + jsx-interpolation: + - match: (?={/\*) + branch_point: jsx-interpolation-comment + branch: + - jsx-interpolation-comment + - jsx-interpolation-plain + - match: (?={) + push: jsx-interpolation-plain + function-declaration-expect-parameters: + - include: function-declaration-parameters - include: else-pop - method-declaration: - - match: '' - set: - - function-meta - - function-declaration-expect-body - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - method-name - - method-declaration-expect-asterisk + binary-operators: + - match: instanceof{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: in{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: =(?![=>]) + scope: keyword.operator.assignment.js + push: expression-begin + - match: |- + (?x) + %= | # assignment right-to-left both + &= | # assignment right-to-left both + \*= | # assignment right-to-left both + \+= | # assignment right-to-left both + -= | # assignment right-to-left both + /= | # assignment right-to-left both + \^= | # assignment right-to-left both + \|= | # assignment right-to-left both + <<= | # assignment right-to-left both + >>= | # assignment right-to-left both + >>>= | # assignment right-to-left both + &&= | + \|\|= | + \?\?= + scope: keyword.operator.assignment.augmented.js + push: expression-begin + - match: '&&|\|\||\?\?' + scope: keyword.operator.logical.js + push: expression-begin + - match: |- + (?x) + << | # bitwise-shift left-to-right both + >>> | # bitwise-shift left-to-right both + >> | # bitwise-shift left-to-right both + & | # bitwise-and left-to-right both + \^ | # bitwise-xor left-to-right both + \| # bitwise-or left-to-right both + scope: keyword.operator.bitwise.js + push: expression-begin + - match: |- + (?x) + <= | # comparison left-to-right both + >= | # comparison left-to-right both + < | # comparison left-to-right both + > # comparison left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + === | # equality left-to-right both + !== | # equality left-to-right both + == | # equality left-to-right both + != # equality left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + / | # division left-to-right both + % | # modulus left-to-right both + \* | # multiplication left-to-right both + \+ | # addition left-to-right both + - # subtraction left-to-right both + scope: keyword.operator.arithmetic.js + push: expression-begin + - match: ',' + scope: keyword.operator.comma.js # Comma operator, not punctuation. + push: expression-begin - export-brace: - - meta_scope: meta.block.js - - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias + call-method-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.method.js - include: else-pop - class-element-modifiers: - - match: (?={{modifier}}) - branch_point: class-element-modifier + support-variable-console: + # https://console.spec.whatwg.org/ + - match: console{{identifier_break}} + scope: support.type.object.console.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: builtin-console-properties + - include: else-pop + + literal-string-template-custom-comments: [] + import-statement-or-import-meta: + - match: (?=import{{identifier_break}}) + branch_point: import-statement branch: - - class-element-modifier - - class-element + - import-statement + - expression-statement - import-item: - - include: flow-type-import-type + flow-type-generic-arguments: + - match: < + scope: punctuation.section.generic.begin.js + set: + - meta_scope: meta.generic.js + - match: '>' + scope: punctuation.section.generic.end.js + pop: true + - include: flow-type-list + + prefixed-method: + - match: (?:get|set){{identifier_break}} + scope: storage.type.accessor.js + set: + - meta_scope: meta.function.js + - match: (?={{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-method + - match: (?:async){{identifier_break}} + scope: keyword.declaration.async.js + set: + - meta_scope: meta.function.js + - match: (?=\*|{{class_element_name}}) + set: method-declaration + - match: (?=\S) + fail: prefixed-method + + jsx-tag: + - match: < + scope: punctuation.definition.tag.begin.js + set: + - jsx-meta + - jsx-tag-attributes-top + + variable-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: variable-binding-pattern + - include: else-pop + + styled-component-begin: + - match: '{{non_reserved_identifier}}(?=\s*\()' + scope: variable.function.js + pop: true + + - match: '{{non_reserved_identifier}}(?=\s*`)' + scope: variable.function.tagged-template.js + pop: true + + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: true + - include: else-pop + export-item: - match: \{ scope: punctuation.section.block.begin.js - set: import-brace + set: export-brace - match: '{{non_reserved_identifier}}' scope: variable.other.readwrite.js pop: true @@ -837,89 +693,82 @@ contexts: pop: true - include: else-pop - support-property-ecma-bigint: - - match: (?:asUintN|asIntN){{identifier_break}} - scope: support.function.builtin.js - pop: true - - conditional: - - match: switch{{identifier_break}} - scope: keyword.control.conditional.switch.js + variable-binding-pattern: + - match: '' set: - - switch-meta - - switch-block - - expect-parenthesized-expression + - - include: flow-type-annotation + - - include: variable-binding-name + - include: variable-binding-array-destructuring + - include: variable-binding-object-destructuring + - include: else-pop - - match: do{{identifier_break}} - scope: keyword.control.loop.do-while.js - set: - - do-while-meta - - do-while-condition - - statement + expression-end: + - include: postfix-operators + - include: binary-operators + - include: ternary-operator - - match: for{{identifier_break}} - scope: keyword.control.loop.for.js - set: - - for-meta - - block-scope - - for-condition - - for-await + - include: left-expression-end - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: - - while-meta - - block-scope - - expect-parenthesized-expression + builtin-console-properties: + - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} + scope: support.function.console.js + pop: true + - include: object-property - - match: with{{identifier_break}} - scope: keyword.control.import.with.js + expression-statement-end: + - match: '{{line_ending_ahead}}' set: - - with-meta - - block-scope - - expect-parenthesized-expression + - match: '{{line_continuation_lookahead}}' + set: expression-statement-end + - include: else-pop + - include: expression-end - - match: if{{identifier_break}} - scope: keyword.control.conditional.if.js - set: - - conditional-meta - - statement - - expect-parenthesized-expression + import-meta-expression: + - match: import{{identifier_break}} + scope: keyword.import.js + set: import-expression-end - - match: else\s+if{{identifier_break}} - scope: keyword.control.conditional.elseif.js - set: - - conditional-meta - - statement - - expect-parenthesized-expression + block-meta: + - meta_include_prototype: false + - meta_scope: meta.block.js + - include: immediately-pop - - match: else{{identifier_break}} - scope: keyword.control.conditional.else.js + constructor-body-expect-class-begin: + - match: (?={{non_reserved_identifier}}\s*\() set: - - conditional-meta - - statement + - include: support + - match: '{{dollar_only_identifier}}' + scope: variable.type.dollar.only.js punctuation.dollar.js + pop: true + - match: '{{dollar_identifier}}' + scope: variable.type.dollar.js + captures: + 1: punctuation.dollar.js + pop: true + - match: '{{identifier_name}}' + scope: variable.type.js + pop: true + - include: else-pop - - match: try{{identifier_break}} - scope: keyword.control.exception.try.js - set: - - try-meta - - block-scope + - include: expression-begin - - match: finally{{identifier_break}} - scope: keyword.control.exception.finally.js - set: - - finally-meta - - block-scope + detect-parenthesized-arrow: + - match: (?=:) + pop: true + branch_point: flow-arrow-function-return-type + branch: + - flow-detect-arrow-function-return-type + - immediately-pop-2 - - match: catch{{identifier_break}} - scope: keyword.control.exception.catch.js - set: - - catch-meta - - block-scope - - expect-parenthesized-expression + - match: (?==>) + fail: parenthesized-arrow-function + - match: (?=\S) + pop: 2 - constructor-body-expect-arguments: - - include: function-call-arguments + expect-case-colon: + - match: ':' + scope: punctuation.separator.js + pop: true - include: else-pop export-statement: @@ -929,70 +778,37 @@ contexts: - export-meta - export-extended - prefixed-object-literal-method: - - match: (?:get|set){{identifier_break}} - scope: storage.type.accessor.js - set: - - meta_scope: meta.function.js - - match: (?={{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-object-literal-method - - match: (?:async){{identifier_break}} - scope: keyword.declaration.async.js - set: - - meta_scope: meta.function.js - - match: (?=\*|{{class_element_name}}) - set: method-declaration - - match: (?=\S) - fail: prefixed-object-literal-method + import-item: + - include: flow-type-import-type - builtin-console-properties: - - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} - scope: support.function.console.js + - match: \{ + scope: punctuation.section.block.begin.js + set: import-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: true + - match: \* + scope: constant.other.js pop: true - - include: object-property - - object-literal-meta-key: - - meta_scope: meta.mapping.key.js string.unquoted.js - include: else-pop - import-export-alias: - - match: as{{identifier_break}} + flow-type-declare-export: + - match: default{{identifier_break}} scope: keyword.control.import-export.js - set: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true - - include: else-pop - - include: else-pop - - flow-type-object: - - match: \{\| - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.type.object.exact.js - - match: \|\} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents + set: flow-type + - match: (?=\S) + pop: true - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.type.object.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents + finally-meta: + - meta_include_prototype: false + - meta_scope: meta.finally.js + - include: immediately-pop - method-declaration-expect-asterisk: - - match: \* - scope: keyword.generator.asterisk.js - - include: else-pop + postfix-operators: + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js arrow-function-expect-arrow: - match: => @@ -1000,477 +816,469 @@ contexts: pop: true - include: else-pop - support-property-ecma-array: - - match: (?:from|isArray|of){{identifier_break}} - scope: support.function.builtin.js + method-name: + - match: '{{dollar_identifier}}' + scope: meta.mapping.key.dollar.js entity.name.function.js + captures: + 1: punctuation.dollar.js pop: true - - support-property-ecma-promise: - - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} - scope: support.function.builtin.js + - match: '{{identifier_name}}' + scope: entity.name.function.js pop: true - - regexp: - - meta_include_prototype: false - - meta_scope: meta.string.js string.regexp.js - - match: / - scope: punctuation.definition.string.end.js + - match: (#){{identifier_name}} + scope: entity.name.function.js + captures: + 1: punctuation.definition.js + pop: true + - match: "'" + scope: punctuation.definition.string.begin.js set: - meta_include_prototype: false - - meta_content_scope: meta.string.js string.regexp.js - - match: '[gimyus]' - scope: keyword.other.js - - match: '[A-Za-z0-9]' # Ignore unknown flags for future-compatibility - - include: immediately-pop - - match: (?=.|\n) - push: + - meta_scope: meta.string.js string.quoted.single.js + - meta_content_scope: entity.name.function.js + - match: \' + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + - match: '"' + scope: punctuation.definition.string.begin.js + set: - meta_include_prototype: false - - match: (?=/) + - meta_scope: meta.string.js string.quoted.double.js + - meta_content_scope: entity.name.function.js + - match: \" + scope: punctuation.definition.string.end.js pop: true - - include: scope:source.regexp.js + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + + - match: (?=\[) + push: computed-property-name - expect-parenthesized-expression: - - include: parenthesized-expression - include: else-pop - for-condition-contents: - # This could be either type of for loop. - - match: (?:const|let|var){{identifier_break}} - scope: storage.type.js - set: - - - include: for-of-rest - - match: (?=\S) - set: - - for-oldstyle-rest - - variable-binding-list - - initializer - - variable-binding-pattern + regular-function: + - match: (?={{func_lookahead}}) + set: function-declaration - - match: (?=\S) - set: - - - include: for-of-rest - - match: (?=\S) - set: for-oldstyle-rest - - expression-end-no-in - - expression-begin + class-body-contents: + - meta_scope: meta.block.js - support-property-ecma-number: - - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} - scope: support.constant.builtin.js - pop: true - - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} - scope: support.function.builtin.js + - match: \} + scope: punctuation.section.block.end.js pop: true - binary-operators: - - match: instanceof{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: in{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: =(?![=>]) - scope: keyword.operator.assignment.js - push: expression-begin - - match: |- - (?x) - %= | # assignment right-to-left both - &= | # assignment right-to-left both - \*= | # assignment right-to-left both - \+= | # assignment right-to-left both - -= | # assignment right-to-left both - /= | # assignment right-to-left both - \^= | # assignment right-to-left both - \|= | # assignment right-to-left both - <<= | # assignment right-to-left both - >>= | # assignment right-to-left both - >>>= | # assignment right-to-left both - &&= | - \|\|= | - \?\?= - scope: keyword.operator.assignment.augmented.js - push: expression-begin - - match: '&&|\|\||\?\?' - scope: keyword.operator.logical.js - push: expression-begin - - match: |- - (?x) - << | # bitwise-shift left-to-right both - >>> | # bitwise-shift left-to-right both - >> | # bitwise-shift left-to-right both - & | # bitwise-and left-to-right both - \^ | # bitwise-xor left-to-right both - \| # bitwise-or left-to-right both - scope: keyword.operator.bitwise.js - push: expression-begin - - match: |- - (?x) - <= | # comparison left-to-right both - >= | # comparison left-to-right both - < | # comparison left-to-right both - > # comparison left-to-right both - scope: keyword.operator.comparison.js - push: expression-begin - - match: |- - (?x) - === | # equality left-to-right both - !== | # equality left-to-right both - == | # equality left-to-right both - != # equality left-to-right both - scope: keyword.operator.comparison.js - push: expression-begin + - match: \; + scope: punctuation.terminator.statement.js + + - include: decorator + + - match: constructor{{identifier_break}} + scope: entity.name.function.constructor.js + push: + - function-meta + - function-declaration-expect-body + - function-declaration-expect-parameters + + - include: class-element-modifiers + - match: |- - (?x) - / | # division left-to-right both - % | # modulus left-to-right both - \* | # multiplication left-to-right both - \+ | # addition left-to-right both - - # subtraction left-to-right both - scope: keyword.operator.arithmetic.js - push: expression-begin - - match: ',' - scope: keyword.operator.comma.js # Comma operator, not punctuation. - push: expression-begin + (?x)(?= + \#? {{identifier_name}} + \s* = \s* + {{either_func_lookahead}} + ) + push: + - initializer + - function-name-meta + - literal-variable-base - support-variable-ecma: - - match: Array{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-array - - include: object-property - - include: else-pop - - include: else-pop + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-method + branch: + - prefixed-method + - class-element - - match: ArrayBuffer{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-arraybuffer - - include: object-property - - include: else-pop - - include: else-pop + - match: (?=\*) + push: method-declaration - - match: Atomics{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-atomics - - include: object-property - - include: else-pop - - include: else-pop + - match: (?={{class_element_name}}) + push: class-element - - match: BigInt{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-bigint - - include: object-property - - include: else-pop - - include: else-pop + expression: + - meta_include_prototype: false + - match: '' + set: [expression-end, expression-begin] - - match: Date{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-date - - include: object-property - - include: else-pop - - include: else-pop + do-while-condition: + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: parenthesized-expression + - include: else-pop - - match: JSON{{identifier_break}} - scope: support.constant.builtin.js + function-name-meta: + - meta_include_prototype: false + - meta_scope: entity.name.function.js + - include: immediately-pop + + function-parameter-binding-object-destructuring: + - match: \{ + scope: punctuation.section.block.begin.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-json - - include: object-property - - include: else-pop - - include: else-pop + - meta_scope: meta.binding.destructuring.mapping.js + - match: ',' + scope: punctuation.separator.parameter.function.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: function-parameter-binding-spread + - match: (?={{identifier_start}}|\[|'|") + push: + - initializer + - function-parameter-binding-object-alias + - object-literal-meta-key + - function-parameter-binding-object-key - - match: Math{{identifier_break}} - scope: support.constant.builtin.js + jsdoc-comment: + - meta_include_prototype: false + - meta_scope: comment.block.documentation.js + - match: \*/ + scope: punctuation.definition.comment.end.js + pop: 1 + # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation + # line so directly after the '/**' or after the '*' marker on the next lines. + - match: ^\s*(\*)(?!/) + captures: + 1: punctuation.definition.comment.js + push: jsdoc-block-tag + + jsx-tag-name-component: + - match: '{{jsx_identifier}}' + scope: entity.name.tag.js set: - - match: '{{dot_accessor}}' + - match: '[:.]' scope: punctuation.accessor.js - set: - - include: support-property-ecma-math - - include: object-property - - include: else-pop + set: jsx-tag-name - include: else-pop + - include: else-pop - - match: Number{{identifier_break}} - scope: support.class.builtin.js + export-extended: + - include: flow-type-export-type + + - include: variable-declaration + - include: class + - include: regular-function + + - match: default{{identifier_break}} + scope: keyword.control.import-export.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-number - - include: object-property - - include: else-pop - - include: else-pop + - include: class + - include: regular-function + - match: (?=\S) + set: expression-statement - - match: Object{{identifier_break}} - scope: support.class.builtin.js + - match: (?=\S) set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-object - - include: object-property - - include: else-pop - - include: else-pop + - expect-semicolon + - import-export-from + - export-list + - import-export-alias + - export-item + + arrow-function-expect-arrow-or-fail-async: + - match: => + scope: keyword.declaration.function.arrow.js + pop: true + - match: (?=\S) + fail: async-arrow-function - - match: Promise{{identifier_break}} - scope: support.class.builtin.js + class: + - match: class{{identifier_break}} + scope: keyword.declaration.class.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-promise - - include: object-property - - include: else-pop - - include: else-pop + - class-meta + - class-body + - class-extends + - class-name - - match: Proxy{{identifier_break}} - scope: support.class.builtin.js + method-declaration: + - meta_include_prototype: false + - match: '' set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-proxy - - include: object-property - - include: else-pop - - include: else-pop + - function-meta + - function-declaration-expect-body + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - method-name + - method-declaration-expect-asterisk - - match: Reflect{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-reflect - - include: object-property - - include: else-pop - - include: else-pop + jsx-attribute-value: + - include: jsx-tag + - include: jsx-interpolation - - match: String{{identifier_break}} - scope: support.class.builtin.js + - match: "'" + scope: punctuation.definition.string.begin.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-string - - include: object-property - - include: else-pop - - include: else-pop - - - match: Symbol{{identifier_break}} - scope: support.class.builtin.js + - meta_include_prototype: false + - meta_scope: string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: true + - include: jsx-html-escapes + - match: '"' + scope: punctuation.definition.string.begin.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-symbol - - include: object-property - - include: else-pop - - include: else-pop + - meta_include_prototype: false + - meta_scope: string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: true + - include: jsx-html-escapes - - match: |- - (?x: - (?: - BigInt64| - BigUint64| - Float(?:32|64)| - Int(?:8|16|32)| - Uint(?:8|16|32|32Clamped) - ) - Array{{identifier_break}} - ) - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-typedarray - - include: object-property - - include: else-pop - - include: else-pop + - include: else-pop - # Classes with no constructor properties - - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} - scope: support.class.builtin.js - pop: true - - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} - scope: support.class.builtin.js + support-property-ecma-proxy: + - match: revocable{{identifier_break}} + scope: support.function.builtin.js pop: true - - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} - scope: support.function.js + function-parameter: + - match: '' + set: + - initializer + - function-parameter-binding-pattern + + support-property-ecma-atomics: + - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} + scope: support.function.builtin.js pop: true - class-extends: - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js + flow-type-literal: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js + pop: true + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js + pop: true + - match: (?=\d) set: - - flow-type-generic-arguments - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop + - - match: '{{identifier_part}}+' + scope: invalid.illegal.js + - include: immediately-pop + - literal-number + - match: (?=['"]) + set: literal-string - import-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - import-item + object-literal-property-check: + - match: (?=\() + fail: object-literal-property - include: else-pop - variable-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' + function-declaration-expect-function-keyword: + - match: function{{identifier_break}} + scope: keyword.declaration.function.js pop: true - - include: literal-string - - include: computed-property-name - - include: variable-binding-name - include: else-pop - switch-block-contents: - - meta_scope: meta.block.js + call-path: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: object-property + - include: else-pop - - match: \} - scope: punctuation.section.block.end.js - pop: true + expect-label: + - meta_include_prototype: false + - match: (?={{nothing}}{{identifier_name}}) + set: + - match: '{{non_reserved_identifier}}' + scope: variable.label.js + pop: true + - match: '{{identifier_name}}' + scope: invalid.illegal.identifier.js variable.label.js + pop: true + - include: else-pop + - include: immediately-pop - - match: case{{identifier_break}} - scope: keyword.control.conditional.case.js - push: - - expect-case-colon - - expression + async-arrow-function: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + set: + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow-or-fail-async + - arrow-function-expect-parameters - - match: default{{identifier_break}} - scope: keyword.control.conditional.default.js + while-meta: + - meta_include_prototype: false + - meta_scope: meta.while.js + - include: immediately-pop + + variable-binding-object-destructuring: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.binding.destructuring.mapping.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: variable-binding-spread + - match: (?={{identifier_start}}|\[|'|") + push: + - initializer + - variable-binding-object-alias + - object-literal-meta-key + - variable-binding-object-key + - include: comma-separator + + jsx-html-escapes: + - match: (&)#?[[:alnum:]]+(;) + scope: constant.character.escape.js + captures: + 1: punctuation.definition.entity.js + 2: punctuation.definition.entity.js + + branch-possible-parenthesized-arrow-function: + - meta_include_prototype: false + - match: '' push: - - expect-case-colon + - detect-parenthesized-arrow + - parenthesized-expression + + conditional: + - match: switch{{identifier_break}} + scope: keyword.control.conditional.switch.js + set: + - switch-meta + - switch-block + - expect-parenthesized-expression + + - match: do{{identifier_break}} + scope: keyword.control.loop.do-while.js + set: + - do-while-meta + - do-while-condition + - statement + + - match: for{{identifier_break}} + scope: keyword.control.loop.for.js + set: + - for-meta + - block-scope + - for-condition + - for-await - - include: statements + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: + - while-meta + - block-scope + - expect-parenthesized-expression - regexp-complete: - - match: / - scope: punctuation.definition.string.begin.js - set: regexp + - match: with{{identifier_break}} + scope: keyword.control.import.with.js + set: + - with-meta + - block-scope + - expect-parenthesized-expression - expression-end-no-in: - - match: (?=in{{identifier_break}}) - pop: true - - include: expression-end + - match: if{{identifier_break}} + scope: keyword.control.conditional.if.js + set: + - conditional-meta + - statement + - expect-parenthesized-expression - styled-components: - - match: (?=(?:styled|css|createGlobalStyle|injectGlobal|keyframes){{identifier_break}}) + - match: else\s+if{{identifier_break}} + scope: keyword.control.conditional.elseif.js set: - - styled-component-end - - styled-component-begin - jsx-tag: - - match: < - scope: punctuation.definition.tag.begin.js + - conditional-meta + - statement + - expect-parenthesized-expression + + - match: else{{identifier_break}} + scope: keyword.control.conditional.else.js set: - - jsx-meta - - jsx-tag-attributes-top + - conditional-meta + - statement - styled-component-end: - - match: \. - scope: punctuation.accessor.dot.js - push: styled-component-begin + - match: try{{identifier_break}} + scope: keyword.control.exception.try.js + set: + - try-meta + - block-scope - - match: (?=`) + - match: finally{{identifier_break}} + scope: keyword.control.exception.finally.js set: - - match: '`' - scope: string.quoted.other.js punctuation.definition.string.begin.js - push: - - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - include: immediately-pop - - - clear_scopes: 1 - - include: immediately-pop - - - match: '' - set: scope:source.js.css - with_prototype: - - match: (?=`) - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.expression - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content - - include: else-pop - - include: expression-end + - finally-meta + - block-scope - bare-arrow-function-fallback: - - meta_include_prototype: false - - match: '' - push: - - immediately-pop-2 - - arrow-function-declaration + - match: catch{{identifier_break}} + scope: keyword.control.exception.catch.js + set: + - catch-meta + - block-scope + - expect-parenthesized-expression + + flow-type-begin: + - include: flow-type-existential + - include: flow-type-literal + - include: flow-type-special + - include: flow-type-primitive + - include: flow-type-utility + - include: flow-type-typeof + - include: flow-type-class + - include: flow-type-function + - include: flow-type-tuple + - include: flow-type-object - call-method-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.method.js - include: else-pop - ternary-operator: - - match: \?(?=[^.]|\.[0-9]) - scope: keyword.operator.ternary.js + conditional-meta: + - meta_include_prototype: false + - meta_scope: meta.conditional.js + - include: immediately-pop + + variable-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: variable-binding-pattern + + new-target: + - match: \. + scope: punctuation.accessor.dot.js set: - - ternary-operator-expect-colon - - expression-no-comma + - match: target{{identifier_break}} + scope: variable.language.target.js + pop: true + - include: else-pop - flow-type-object-value: - - match: (\?)?(:) - captures: - 1: storage.modifier.optional.js - 2: punctuation.separator.key-value.js - set: flow-type - include: else-pop - object-literal-element: - - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' - scope: variable.other.readwrite.js + decorator-name: + - match: '{{identifier_name}}{{left_expression_end_lookahead}}' + scope: variable.annotation.js pop: true - - match: (?=\S) + + for-oldstyle-rest: + - match: (?=\)) pop: true - branch_point: object-literal-property - branch: - - object-literal-property - - method-declaration + - match: ; + scope: punctuation.separator.expression.js + - match: (?=\S) + push: expression - variable-binding-pattern: - - match: '' - set: - - - include: flow-type-annotation - - - include: variable-binding-name - - include: variable-binding-array-destructuring - - include: variable-binding-object-destructuring - - include: else-pop + expect-semicolon: + - match: \; + scope: punctuation.terminator.statement.js + pop: true + - include: else-pop field-name: - match: '{{dollar_identifier}}' @@ -1517,624 +1325,682 @@ contexts: - include: else-pop - literal-string: - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - jsx-tag-attributes: - - meta_scope: meta.tag.attributes.js - - - match: '>' - scope: punctuation.definition.tag.end.js - set: jsx-body - - - match: / - scope: punctuation.definition.tag.end.js - set: jsx-expect-tag-end + switch-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: switch-block-contents + - include: else-pop - - include: jsx-interpolation + expression-end-no-in: + - match: (?=in{{identifier_break}}) + pop: true + - include: expression-end - - match: '{{jsx_identifier}}' - scope: entity.other.attribute-name.js + flow-type-typeof: + - match: typeof{{identifier_break}} + scope: keyword.operator.js + set: + - left-expression-end + - expression-begin - - match: '=' - scope: punctuation.separator.key-value.js - push: jsx-attribute-value + jsdoc-block-tag: + - match: '{{jsdoc_block_tag}}' + scope: entity.other.attribute-name.documentation.js + pop: 1 + - match: (?=\S)|$ + pop: 1 - special-identifier: - # These are ordinary identifiers, not reserved words - - match: arguments{{identifier_break}} - scope: variable.language.arguments.js - pop: true - - match: globalThis{{identifier_break}} - scope: variable.language.global.js + support-property-node-module: + - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} + scope: support.constant.node.js pop: true - - match: undefined{{identifier_break}} - scope: constant.language.undefined.js + - match: require{{identifier_break}} + scope: support.function.node.js pop: true - - match: NaN{{identifier_break}} - scope: constant.language.nan.js + + inherited-class-name: + - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' + scope: entity.other.inherited-class.js pop: true - - match: Infinity{{identifier_break}} - scope: constant.language.infinity.js + + support-property-ecma-array: + - match: (?:from|isArray|of){{identifier_break}} + scope: support.function.builtin.js pop: true - function-parameter-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + function-declaration-expect-body: + - include: function-block + - include: else-pop + + flow-type-declare: + - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) + scope: keyword.declaration.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js + - match: opaque{{identifier_break}} + scope: storage.modifier.js pop: true - - include: function-parameter-binding-list + - match: module{{identifier_break}} + scope: keyword.declaration.js + set: + - flow-type-module-meta + - flow-type-module-body + - flow-type-module-name + - match: export{{identifier_break}} + scope: keyword.declaration.js + set: flow-type-declare-export + - include: else-pop - jsx-html-escapes: - - match: (&)#?[[:alnum:]]+(;) - scope: constant.character.escape.js - captures: - 1: punctuation.definition.entity.js - 2: punctuation.definition.entity.js + tagged-template: + - include: literal-string-template-custom-comments + - include: literal-string-template-custom-tags + - include: styled-components - jsx-tag-name: + - match: '{{identifier_name}}(?=\s*`)' + scope: variable.function.tagged-template.js + pop: true + + initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: expression-no-comma + - include: else-pop + + immediately-pop-2: + - meta_include_prototype: false - match: '' - set: - - - clear_scopes: 1 - - meta_scope: meta.tag.name.js - - include: immediately-pop - - jsx-tag-name-component + pop: 2 - jsx-tag-attributes-top: - - meta_scope: meta.tag.js - - match: / - scope: punctuation.definition.tag.begin.js + literal-string-template-custom-tags: [] + class-extends: + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js set: - - - meta_scope: invalid.illegal.unmatched-tag.js - - include: immediately-pop - - jsx-expect-tag-end - - jsx-tag-name + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop + arrow-function-expect-body: + - include: function-block - match: (?=\S) set: - - jsx-tag-attributes - - jsx-tag-name + - block-meta + - expression-no-comma - function-declaration-expect-function-keyword: - - match: function{{identifier_break}} - scope: keyword.declaration.function.js + decorator-expression-end: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: decorator-name + - include: object-property + + - include: left-expression-end + + support-property-ecma-arraybuffer: + - match: isView{{identifier_break}} + scope: support.function.builtin.js pop: true - - include: else-pop - class-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: class-body-contents + import-statement: + - match: import{{identifier_break}} + scope: keyword.control.import-export.js + set: + - import-meta + - expect-semicolon + - import-string-or-items + - import-check-branch + import-list: + - match: ',' + scope: punctuation.separator.comma.js + push: + - import-export-alias + - import-item - include: else-pop - styled-component-begin: - - match: '{{non_reserved_identifier}}(?=\s*\()' - scope: variable.function.js + support-variable-node: + - match: global{{identifier_break}} + scope: support.type.object.node.js pop: true - - match: '{{non_reserved_identifier}}(?=\s*`)' - scope: variable.function.tagged-template.js + - match: Buffer{{identifier_break}} + scope: support.class.node.js pop: true - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js + - match: process{{identifier_break}} + scope: support.constant.node.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-process + - include: object-property + - include: else-pop + - include: else-pop + + # Module-level variables + - match: (?:__dirname|__filename|exports){{identifier_break}} + scope: support.constant.node.js + pop: true + - match: module{{identifier_break}} + scope: support.constant.node.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-module + - include: object-property + - include: else-pop + - include: else-pop + - match: require{{identifier_break}} + scope: support.function.node.js pop: true - - include: else-pop - do-while-meta: + decorator-meta: - meta_include_prototype: false - - meta_scope: meta.do-while.js + - meta_scope: meta.annotation.js - include: immediately-pop - import-statement: - - match: import{{identifier_break}} - scope: keyword.control.import-export.js + function-declaration: + - match: '' + set: + - function-meta + - function-declaration-expect-body + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - function-declaration-expect-name + - function-declaration-expect-generator-star + - function-declaration-expect-function-keyword + - function-declaration-expect-async + + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop + + expression-statement: + - match: (?=\S) set: - - import-meta - expect-semicolon - - import-string-or-items - - import-check-branch + - expression-statement-end + - expression-begin - branch-possible-parenthesized-arrow-function: - - meta_include_prototype: false - - match: '' - push: - - detect-parenthesized-arrow - - parenthesized-expression + regexp-complete: + - match: / + scope: punctuation.definition.string.begin.js + set: regexp - flow-type-function: - - match: \( - scope: punctuation.section.grouping.begin.js + class-element-modifiers: + - match: (?={{modifier}}) + branch_point: class-element-modifier + branch: + - class-element-modifier + - class-element + + object-literal-property: + - match: '' set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.grouping.end.js - pop: true - - include: flow-type-list + - object-literal-property-check + - object-literal-meta-key + - object-property-name - while-meta: - - meta_include_prototype: false - - meta_scope: meta.while.js + jsx-meta: + - meta_scope: meta.jsx.js - include: immediately-pop - statement: - - include: flow-type-declare - - include: flow-type-alias - - - match: \; - scope: punctuation.terminator.statement.empty.js + expression-break: + - match: (?=[;})\]]) pop: true - - include: import-statement-or-import-meta - - include: export-statement - - include: conditional - - include: block - - include: label - - include: variable-declaration + comments-top-level: + - match: ^(#!).*$\n? + scope: comment.line.shebang.js + captures: + 1: punctuation.definition.comment.js - - match: break{{identifier_break}} - scope: keyword.control.flow.break.js - set: - - expect-semicolon - - expect-label + flow-detect-arrow-after-return-type: + - match: (?==>) + fail: parenthesized-arrow-function + - match: (?=\S) + fail: flow-arrow-function-return-type - - match: continue{{identifier_break}} - scope: keyword.control.flow.continue.js + flow-type-alias: + - match: (?=type{{identifier_break}}) set: - - expect-semicolon - - expect-label + - - match: (?={{non_reserved_identifier}}) + set: + - - meta_scope: meta.declaration.type.js + - match: '' + pop: true + - flow-type-alias-initializer + - flow-type-generic-parameters + - - match: '{{non_reserved_identifier}}' + scope: entity.name.type.js + pop: true + - - include: else-pop - - match: debugger{{identifier_break}} - scope: keyword.control.flow.debugger.js - set: expect-semicolon + - match: (?=\S) + set: [expression-statement, expression-end] + - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}})) + scope: keyword.declaration.js + set: + - meta_scope: meta.declaration.type.js + - include: else-pop + - include: expression-begin - - match: return{{identifier_break}} - scope: keyword.control.flow.return.js - set: restricted-production + detect-bare-arrow: + - match: (?==>) + fail: bare-arrow-function + - match: (?=\S) + pop: 2 - - match: throw{{identifier_break}} - scope: keyword.control.flow.throw.js - set: restricted-production + expect-parenthesized-expression: + - include: parenthesized-expression + - include: else-pop - - include: class - - include: regular-function + for-await: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js + pop: true + - include: else-pop - - include: decorator + function-meta: + - meta_include_prototype: false + - meta_scope: meta.function.js + - include: immediately-pop - - include: expression-statement + support-property-ecma-object: + - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} + scope: support.function.builtin.js + pop: true - property-access: - - match: ({{dot_accessor}})?(\[) + function-call-arguments: + - match: ({{dot_accessor}})?(\() captures: 1: punctuation.accessor.js - 2: punctuation.section.brackets.begin.js - push: - - meta_scope: meta.brackets.js + 2: punctuation.section.group.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - include: expression-list + + function-declaration-expect-generator-star: + - match: \* + scope: keyword.declaration.generator.js + pop: true + - include: else-pop + + array-literal: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - meta_scope: meta.sequence.js - match: \] scope: punctuation.section.brackets.end.js pop: true - - match: (?=\S) - push: expression + - include: expression-list - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: - - call-method-meta - - function-call-arguments - - call-path - - object-property - - include: object-property + class-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.class.js + set: flow-type-generic-parameters + - include: else-pop - export-meta: + jsx-body: - meta_include_prototype: false - - meta_scope: meta.export.js - - include: immediately-pop - - arrow-function-expect-body: - - include: function-block - - match: (?=\S) - set: - - block-meta - - expression-no-comma - - flow-type-pragma: - - match: (//)\s*(?=@) - scope: comment.line.double-slash.pragma.js - captures: - 1: punctuation.definition.comment.js - push: - - meta_include_prototype: false - - match: (@)(flow) - captures: - 1: punctuation.definition.pragma.js - 2: support.function.pragma.js - pop: true - - include: else-pop - flow-type-typeof: - - match: typeof{{identifier_break}} - scope: keyword.operator.js + - match: < + scope: punctuation.definition.tag.begin.js set: - - left-expression-end - - expression-begin + - meta_scope: meta.tag.js - function-parameter: - - match: '' - set: - - initializer - - function-parameter-binding-pattern + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-expect-tag-end + - jsx-tag-name - function-meta: - - meta_include_prototype: false - - meta_scope: meta.function.js - - include: immediately-pop + - match: (?=\S) + set: + - jsx-body + - jsx-tag-attributes + - jsx-tag-name - function-parameter-binding-object-destructuring: + - include: jsx-html-escapes + - include: jsx-interpolation + object-literal: - match: \{ scope: punctuation.section.block.begin.js + set: object-literal-contents + + flow-type-generic-parameters: + - match: < + scope: punctuation.section.generic.begin.js set: - - meta_scope: meta.binding.destructuring.mapping.js - - match: ',' - scope: punctuation.separator.parameter.function.js - - match: \} - scope: punctuation.section.block.end.js + - meta_scope: meta.generic.declaration.js + - match: '>' + scope: punctuation.section.generic.end.js pop: true - - include: function-parameter-binding-spread - - match: (?={{identifier_start}}|\[|'|") + - include: comma-separator + - match: \+ + scope: storage.modifier.variance.js + - match: '{{non_reserved_identifier}}' + scope: variable.parameter.type.js push: - - initializer - - function-parameter-binding-object-alias - - object-literal-meta-key - - function-parameter-binding-object-key - - flow-type-export-type: - - match: type{{identifier_break}}(?=\s*\{) - scope: keyword.declaration.js - set: export-item - - include: flow-type-alias - - flow-type-object-contents: - - include: comma-separator - - match: ; - scope: punctuation.separator.semicolon.js - - match: '{{method_lookahead}}' - push: method-declaration - - match: \+ - scope: storage.modifier.variance.js - - match: '{{non_reserved_identifier}}' - scope: meta.object-literal.key.js - push: flow-type-object-value - - match: \[ - scope: punctuation.section.brackets.begin.js - push: - - flow-type-object-value - - flow-type-object-indexer-type - - flow-type-object-indexer-label + - - match: '=' + scope: keyword.operator.assignment.js + set: flow-type + - include: else-pop + - flow-type-annotation + - include: else-pop - expression: + catch-meta: - meta_include_prototype: false - - match: '' - set: [expression-end, expression-begin] - - constructor-body-expect-class-begin: - - match: (?={{non_reserved_identifier}}\s*\() - set: - - include: support - - match: '{{dollar_only_identifier}}' - scope: variable.type.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: variable.type.dollar.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: variable.type.js - pop: true - - include: else-pop - - - include: expression-begin + - meta_scope: meta.catch.js + - include: immediately-pop - prefix-operators: - - match: '~' - scope: keyword.operator.bitwise.js - - match: '!(?!=)' - scope: keyword.operator.logical.js - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - match: \.\.\. - scope: keyword.operator.spread.js - - match: \+|\- - scope: keyword.operator.arithmetic.js - - match: (?:delete|typeof|void){{identifier_break}} - scope: keyword.operator.js + expression-begin: + - include: jsx-tag - expression-statement: - - match: (?=\S) + - match: (?=`) set: - - expect-semicolon - - expression-statement-end - - expression-begin + - include: literal-string-template-custom-comments + - include: literal-string-template-custom-lookahead + - include: literal-string-template - class-element: - - match: '' - pop: true - branch_point: class-field - branch: - - class-field - - method-declaration + - include: expression-break - jsx-meta: - - meta_scope: meta.jsx.js - - include: immediately-pop + - include: yield-expression + - include: await-expression - function-parameter-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: function-parameter + - include: regexp-complete + - include: literal-string + - include: tagged-template + - include: literal-string-template + - include: constructor + - include: literal-number + - include: prefix-operators + - include: import-meta-expression - object-literal-property: - - match: '' - set: - - object-literal-property-check - - object-literal-meta-key - - object-property-name + - include: class + - include: special-name - object-literal-contents: - - meta_scope: meta.mapping.js + - include: regular-function - - match: \} - scope: punctuation.section.block.end.js + - match: (?={{reserved_word}}) pop: true - - match: \.\.\. - scope: keyword.operator.spread.js - push: expression-no-comma + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + set: + - function-name-meta + - literal-variable - - match: >- - (?x)(?= - {{property_name}}\s*:\s* - {{either_func_lookahead}} - ) - push: - - object-literal-meta-key - - method-name + - include: object-literal - - match: (?=\*) - push: method-declaration + # Newline not allowed between `async` and parameters. + - match: (?=async{{identifier_break}}{{nothing}}(?:\(|{{identifier_start}})) + pop: true + branch_point: async-arrow-function + branch: + - async-arrow-function + - literal-variable - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-object-literal-method + - include: literal-call + + - match: (?={{identifier_start}}) + pop: true + branch_point: bare-arrow-function branch: - - prefixed-object-literal-method - - object-literal-element + - branch-possible-bare-arrow-function + - bare-arrow-function-fallback - - match: (?={{property_name}}) - push: object-literal-element + - match: (?=\() + pop: true + branch_point: parenthesized-arrow-function + branch: + - branch-possible-parenthesized-arrow-function + - parenthesized-arrow-function-fallback - - include: comma-separator + - include: array-literal - - match: ':' - scope: punctuation.separator.key-value.js - push: expression-no-comma + - include: literal-private-variable - # If there's any garbage, parse it as an expression - # so that close braces won't break things. - - match: (?=\S) - push: expression-no-comma + - include: else-pop - variable-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + flow-arrow-function-return-type-annotation: + - match: ':' + scope: punctuation.separator.type.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: variable-binding-spread - - include: variable-binding-list + - flow-type-meta + - flow-type-end-no-arrow + - flow-type-begin + - match: (?!\s*(?:$|:|//|/\*)) + pop: true - function-parameter-binding-pattern: + flow-type: - match: '' set: - - - include: flow-type-annotation-optional - - - include: function-parameter-binding-name - - include: function-parameter-binding-array-destructuring - - include: function-parameter-binding-object-destructuring - - include: else-pop + - flow-type-end + - flow-type-begin - statements: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js + flow-type-existential: + - match: \* + scope: constant.language.type.existential.js pop: true - - match: (?=\S) - push: statement - - class: - - match: class{{identifier_break}} - scope: keyword.declaration.class.js + regexp: + - meta_include_prototype: false + - meta_scope: meta.string.js string.regexp.js + - match: / + scope: punctuation.definition.string.end.js set: - - class-meta - - class-body - - class-extends - - class-name + - meta_include_prototype: false + - meta_content_scope: meta.string.js string.regexp.js + - match: '[gimyus]' + scope: keyword.other.js + - match: '[A-Za-z0-9]' # Ignore unknown flags for future-compatibility + - include: immediately-pop + - match: (?=.|\n) + push: + - meta_include_prototype: false + - match: (?=/) + pop: true + - include: scope:source.regexp.js - class-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.class.js - set: flow-type-generic-parameters - - include: else-pop + prefix-operators: + - match: '~' + scope: keyword.operator.bitwise.js + - match: '!(?!=)' + scope: keyword.operator.logical.js + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js + - match: \.\.\. + scope: keyword.operator.spread.js + - match: \+|\- + scope: keyword.operator.arithmetic.js + - match: (?:delete|typeof|void){{identifier_break}} + scope: keyword.operator.js - flow-type-existential: - - match: \* - scope: constant.language.type.existential.js + support-property-ecma-number: + - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} + scope: support.constant.builtin.js + pop: true + - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} + scope: support.function.builtin.js pop: true - variable-binding-top: - - match: (?={{binding_pattern_lookahead}}) + styled-component-end: + - match: \. + scope: punctuation.accessor.dot.js + push: styled-component-begin + + - match: (?=`) set: - - initializer - - variable-binding-pattern - - include: else-pop + - match: '`' + scope: string.quoted.other.js punctuation.definition.string.begin.js + push: + - - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.other.js + - match: '`' + scope: punctuation.definition.string.end.js + pop: true + - include: immediately-pop + - - clear_scopes: 1 + - include: immediately-pop + - - match: '' + set: scope:source.js.css + with_prototype: + - match: (?=`) + pop: true + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.expression + - match: \} + scope: punctuation.section.interpolation.end.js + pop: true + - match: (?=\S) + push: expression + - include: string-content + - include: else-pop + - include: expression-end - class-body-contents: - - meta_scope: meta.block.js + flow-type-end-no-arrow: + - match: (?==>) + pop: true + - include: flow-type-end - - match: \} - scope: punctuation.section.block.end.js + support-variable-dom: + - match: XMLHttpRequest{{identifier_break}} + scope: support.class.dom.js + pop: true + - match: (?:document|window|navigator){{identifier_break}} + scope: support.type.object.dom.js + pop: true + - match: (?:clearTimeout|setTimeout){{identifier_break}} + scope: support.function.dom.js pop: true - - match: \; - scope: punctuation.terminator.statement.js + string-content: + - match: \\\n + scope: constant.character.escape.newline.js + - match: \\(?:x\h\h|u\h\h\h\h|.) + scope: constant.character.escape.js + + jsx-tag-attributes-top: + - meta_scope: meta.tag.js + - match: / + scope: punctuation.definition.tag.begin.js + set: + - - meta_scope: invalid.illegal.unmatched-tag.js + - include: immediately-pop + - jsx-expect-tag-end + - jsx-tag-name - - include: decorator + - match: (?=\S) + set: + - jsx-tag-attributes + - jsx-tag-name - - match: constructor{{identifier_break}} - scope: entity.name.function.constructor.js - push: - - function-meta - - function-declaration-expect-body - - function-declaration-expect-parameters + else-pop: + - match: (?=\S) + pop: true - - include: class-element-modifiers + literal-private-variable: + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js + pop: true - - match: |- - (?x)(?= - \#? {{identifier_name}} - \s* = \s* - {{either_func_lookahead}} - ) + branch-possible-bare-arrow-function: + - meta_include_prototype: false + - match: '' push: - - initializer - - function-name-meta - - literal-variable-base + - detect-bare-arrow + - literal-variable - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-method - branch: - - prefixed-method - - class-element + import-string-or-items: + - include: literal-string + - match: (?=\S) + set: + - import-export-from + - import-list + - import-export-alias + - import-item - - match: (?=\*) + flow-type-object-contents: + - include: comma-separator + - match: ; + scope: punctuation.separator.semicolon.js + - match: '{{method_lookahead}}' push: method-declaration + - match: \+ + scope: storage.modifier.variance.js + - match: '{{non_reserved_identifier}}' + scope: meta.object-literal.key.js + push: flow-type-object-value + - match: \[ + scope: punctuation.section.brackets.begin.js + push: + - flow-type-object-value + - flow-type-object-indexer-type + - flow-type-object-indexer-label - - match: (?={{class_element_name}}) - push: class-element - - postfix-operators: - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - object-literal-property-check: - - match: (?=\() - fail: object-literal-property - - include: else-pop - - with-meta: - - meta_include_prototype: false - - meta_scope: meta.with.js - - include: immediately-pop + main: + - include: comments-top-level - class-field-check: - - match: (?=\() - fail: class-field - - include: else-pop + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + # Don't pop or embedding could break. - special-name: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js - pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js - pop: true - - match: null{{identifier_break}} - scope: constant.language.null.js - pop: true - - match: super{{identifier_break}} - scope: variable.language.super.js - pop: true - - match: this{{identifier_break}} - scope: variable.language.this.js - pop: true + - include: statements - parenthesized-expression: - - match: \( - scope: punctuation.section.group.begin.js + flow-type-object: + - match: \{\| + scope: punctuation.section.block.begin.js set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js + - meta_scope: meta.type.object.exact.js + - match: \|\} + scope: punctuation.section.block.end.js pop: true - - match: (?=:) - push: flow-type-annotation - - match: (?=\S) - push: expression + - include: flow-type-object-contents - support-property-ecma-arraybuffer: - - match: isView{{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.type.object.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: flow-type-object-contents - for-await: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js - pop: true + import-check-branch: + - match: (?=[.(]) # Recovery for import expressions + fail: import-statement - include: else-pop - support-property-ecma-json: - - match: (?:parse|stringify){{identifier_break}} - scope: support.function.builtin.js - pop: true - - decorator-name: - - match: '{{identifier_name}}{{left_expression_end_lookahead}}' - scope: variable.annotation.js - pop: true - - import-export-from: - - match: from{{identifier_break}} - scope: keyword.control.import-export.js - set: literal-string - - include: else-pop + literal-call: + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: + - call-function-meta + - function-call-arguments + - literal-variable - variable-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: variable-binding-pattern + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() + set: + - call-method-meta + - function-call-arguments + - call-path + - literal-variable import-brace: - include: flow-type-import-type @@ -2152,201 +2018,311 @@ contexts: push: import-export-alias - include: else-pop - variable-declaration: - - match: (?:const|let|var){{identifier_break}} - scope: keyword.declaration.js - set: - - expect-semicolon - - variable-binding-list-top - - variable-binding-top + function-parameter-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: function-parameter-binding-pattern + - include: else-pop - support-property-ecma-math: - - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} - scope: support.constant.builtin.js + support-property-ecma: + - match: constructor{{identifier_break}} + scope: variable.language.constructor.js pop: true - - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} - scope: support.function.builtin.js + - match: prototype{{identifier_break}} + scope: support.constant.prototype.js pop: true - flow-type-special: - - match: any{{identifier_break}} - scope: support.type.any.js + - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} + scope: support.function.js pop: true - - match: mixed{{identifier_break}} - scope: support.type.mixed.js + # Annex B + - match: __proto__{{identifier_break}} + scope: invalid.deprecated.js variable.language.prototype.js + pop: true + - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} + scope: invalid.deprecated.js support.function.js pop: true - yield-expression: - - match: yield{{identifier_break}} - scope: keyword.control.flow.yield.js - set: - - match: $ - pop: true - - match: \* - scope: keyword.generator.asterisk.js - set: expression-begin - - match: (?=\S) - set: expression-begin + flow-type-operators: + - match: \|(?!\}) + scope: keyword.operator.type.union.js + push: flow-type-begin + - match: \& + scope: keyword.operator.type.intersection.js + push: flow-type-begin + - match: => + scope: keyword.declaration.function.arrow.js + push: flow-type-begin + - match: \? + scope: storage.modifier.maybe.js + push: flow-type-begin + - match: \. + scope: punctuation.separator.accessor.js + push: flow-type-begin - import-string-or-items: - - include: literal-string - - match: (?=\S) - set: - - import-export-from - - import-list - - import-export-alias - - import-item + - match: \[\] + scope: storage.modifier.array.js + - match: '%checks{{identifier_break}}' + scope: storage.modifier.checks.js - function-name-meta: + parenthesized-arrow-function-fallback: - meta_include_prototype: false - - meta_scope: entity.name.function.js - - include: immediately-pop + - match: '' + push: + - immediately-pop-2 + - arrow-function-declaration - expect-semicolon: - - match: \; - scope: punctuation.terminator.statement.js + flow-type-object-indexer-label: + - match: ({{non_reserved_identifier}})\s*(:) + captures: + 1: meta.object-literal.key.js + 2: punctuation.separator.key-value.js pop: true - include: else-pop - conditional-meta: + variable-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + pop: true + - include: literal-string + - include: computed-property-name + - include: variable-binding-name + - include: else-pop + + export-meta: - meta_include_prototype: false - - meta_scope: meta.conditional.js + - meta_scope: meta.export.js - include: immediately-pop - expression-no-comma: - - meta_include_prototype: false - - match: '' - set: [expression-end-no-comma, expression-begin] + jsx-tag-attributes: + - meta_scope: meta.tag.attributes.js - flow-type-declare-export: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: flow-type - - match: (?=\S) - pop: true + - match: '>' + scope: punctuation.definition.tag.end.js + set: jsx-body - expression-end-no-comma: - - match: (?=,) - pop: true - - include: expression-end + - match: / + scope: punctuation.definition.tag.end.js + set: jsx-expect-tag-end - function-declaration-parameters: - - match: \( - scope: punctuation.section.group.begin.js + - include: jsx-interpolation + + - match: '{{jsx_identifier}}' + scope: entity.other.attribute-name.js + + - match: '=' + scope: punctuation.separator.key-value.js + push: jsx-attribute-value + + flow-type-module-meta: + - meta_scope: meta.module.js + - include: immediately-pop + + support: + - include: support-variable-ecma + - include: support-variable-console + - include: support-variable-dom + - include: support-variable-node + + support-variable-ecma: + - match: Array{{identifier_break}} + scope: support.class.builtin.js set: - - clear_scopes: 1 - - meta_scope: meta.function.parameters.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - - include: function-parameter-binding-list + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-array + - include: object-property + - include: else-pop + - include: else-pop - flow-type-end: - - include: flow-type-operators - - match: (?=<) - push: flow-type-generic-arguments - - include: else-pop + - match: ArrayBuffer{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-arraybuffer + - include: object-property + - include: else-pop + - include: else-pop - support-property-ecma-symbol: - - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} + - match: Atomics{{identifier_break}} scope: support.constant.builtin.js - pop: true - - match: (?:for|keyFor){{identifier_break}} - scope: support.function.builtin.js - pop: true + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-atomics + - include: object-property + - include: else-pop + - include: else-pop - object-property: - - include: support-property + - match: BigInt{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-bigint + - include: object-property + - include: else-pop + - include: else-pop - - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) + - match: Date{{identifier_break}} + scope: support.class.builtin.js set: - - function-name-meta - - object-property-base + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-date + - include: object-property + - include: else-pop + - include: else-pop - - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: call-method-name + - match: JSON{{identifier_break}} + scope: support.constant.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-json + - include: object-property + - include: else-pop + - include: else-pop - - include: object-property-base - - include: else-pop + - match: Math{{identifier_break}} + scope: support.constant.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-math + - include: object-property + - include: else-pop + - include: else-pop - variable-binding-list-top: - - match: '{{line_ending_ahead}}' + - match: Number{{identifier_break}} + scope: support.class.builtin.js set: - - match: '{{line_continuation_lookahead}}' - set: variable-binding-top + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-number + - include: object-property + - include: else-pop - include: else-pop - - match: ',' - scope: punctuation.separator.comma.js - push: variable-binding-top - - include: else-pop - export-item: - - match: \{ - scope: punctuation.section.block.begin.js - set: export-brace - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js - pop: true - - match: \* - scope: constant.other.js - pop: true - - include: else-pop + - match: Object{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-object + - include: object-property + - include: else-pop + - include: else-pop - parenthesized-arrow-function-fallback: - - meta_include_prototype: false - - match: '' - push: - - immediately-pop-2 - - arrow-function-declaration + - match: Promise{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-promise + - include: object-property + - include: else-pop + - include: else-pop - catch-meta: - - meta_include_prototype: false - - meta_scope: meta.catch.js - - include: immediately-pop + - match: Proxy{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-proxy + - include: object-property + - include: else-pop + - include: else-pop - support-property-node-module: - - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} - scope: support.constant.node.js - pop: true - - match: require{{identifier_break}} - scope: support.function.node.js - pop: true + - match: Reflect{{identifier_break}} + scope: support.constant.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-reflect + - include: object-property + - include: else-pop + - include: else-pop + + - match: String{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-string + - include: object-property + - include: else-pop + - include: else-pop - literal-call: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + - match: Symbol{{identifier_break}} + scope: support.class.builtin.js set: - - call-function-meta - - function-call-arguments - - literal-variable + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-symbol + - include: object-property + - include: else-pop + - include: else-pop - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() + - match: |- + (?x: + (?: + BigInt64| + BigUint64| + Float(?:32|64)| + Int(?:8|16|32)| + Uint(?:8|16|32|32Clamped) + ) + Array{{identifier_break}} + ) + scope: support.class.builtin.js set: - - call-method-meta - - function-call-arguments - - call-path - - literal-variable + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-typedarray + - include: object-property + - include: else-pop + - include: else-pop - for-of-rest: - - match: (?:of|in){{identifier_break}} - scope: keyword.operator.word.js - set: expression + # Classes with no constructor properties + - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} + scope: support.class.builtin.js + pop: true + - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} + scope: support.class.builtin.js + pop: true - call-path: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: object-property - - include: else-pop + - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + scope: support.function.js + pop: true - new-target: - - match: \. - scope: punctuation.accessor.dot.js - set: - - match: target{{identifier_break}} - scope: variable.language.target.js - pop: true - - include: else-pop + expression-end-no-comma: + - match: (?=,) + pop: true + - include: expression-end + function-parameter-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + pop: true + - include: literal-string + - include: computed-property-name + - include: function-parameter-binding-name - include: else-pop flow-type-module-name: @@ -2356,301 +2332,351 @@ contexts: pop: true - include: else-pop - function-parameter-binding-name: - - match: '{{non_reserved_identifier}}' - scope: meta.binding.name.js variable.parameter.function.js + method-declaration-expect-asterisk: + - match: \* + scope: keyword.generator.asterisk.js + - include: else-pop + + function-declaration-expect-async: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + pop: true + - include: else-pop + + object-property-base: + - match: '{{dollar_only_identifier}}' + scope: meta.property.object.dollar.only.js punctuation.dollar.js + pop: true + - match: '{{dollar_identifier}}' + scope: meta.property.object.dollar.js + captures: + 1: punctuation.dollar.js + pop: true - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js + scope: meta.property.object.js + pop: true + - match: '{{identifier_part}}+{{identifier_break}}' + scope: invalid.illegal.illegal-identifier.js + pop: true + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: meta.property.object.js + pop: true - finally-meta: + object-literal-meta-key: + - meta_scope: meta.mapping.key.js string.unquoted.js + - include: else-pop + + variable-declaration: + - match: (?:const|let|var){{identifier_break}} + scope: keyword.declaration.js + set: + - expect-semicolon + - variable-binding-list-top + - variable-binding-top + + flow-type-object-indexer-type: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: flow-type-list + + import-meta: - meta_include_prototype: false - - meta_scope: meta.finally.js + - meta_scope: meta.import.js - include: immediately-pop - import-meta-expression: - - match: import{{identifier_break}} - scope: keyword.import.js - set: import-expression-end - - array-literal: + function-parameter-binding-array-destructuring: - match: \[ scope: punctuation.section.brackets.begin.js set: - - meta_scope: meta.sequence.js + - meta_scope: meta.binding.destructuring.sequence.js - match: \] scope: punctuation.section.brackets.end.js pop: true - - include: expression-list + - include: function-parameter-binding-list - arrow-function-declaration: - - meta_include_prototype: false - - match: '' + flow-type-annotation: + - match: ':' + scope: punctuation.separator.type.js set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow - - flow-type-annotation - - arrow-function-expect-parameters - - arrow-function-expect-arrow-or-fail-async: - - match: => - scope: keyword.declaration.function.arrow.js + - flow-type-meta + - flow-type + - match: (?!\s*(?:$|:|//|/\*)) pop: true - - match: (?=\S) - fail: async-arrow-function - - object-property-name: - - match: (?=\[) - set: computed-property-name - - include: literal-string - - include: literal-number + flow-type-class: + - match: '{{non_reserved_identifier}}' + scope: variable.other.class.js + pop: true - - match: '{{identifier_name}}' + support-property-ecma-math: + - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} + scope: support.constant.builtin.js + pop: true + - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} + scope: support.function.builtin.js pop: true + call-function-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.js - include: else-pop - call-function-name: - - match: '{{dollar_only_identifier}}' - scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: variable.function.js + for-condition-end: + - meta_scope: meta.group.js + + - match: \) + scope: punctuation.section.group.js pop: true + + bare-arrow-function-fallback: + - meta_include_prototype: false + - match: '' + push: + - immediately-pop-2 + - arrow-function-declaration + + class-field-check: + - match: (?=[(<]) + fail: class-field - include: else-pop - regular-function: - - match: (?={{func_lookahead}}) - set: function-declaration + flow-type-end: + - include: flow-type-operators + - include: flow-type-generic-arguments + - include: else-pop - flow-detect-arrow-after-return-type: - - match: (?==>) - fail: parenthesized-arrow-function - - match: (?=\S) - fail: flow-arrow-function-return-type + decorator: + - match: '@' + scope: punctuation.definition.annotation.js + push: + - decorator-meta + - decorator-expression-end + - decorator-expression-begin - support-variable-dom: - - match: XMLHttpRequest{{identifier_break}} - scope: support.class.dom.js - pop: true - - match: (?:document|window|navigator){{identifier_break}} - scope: support.type.object.dom.js - pop: true - - match: (?:clearTimeout|setTimeout){{identifier_break}} - scope: support.function.dom.js - pop: true + for-of-rest: + - match: (?:of|in){{identifier_break}} + scope: keyword.operator.word.js + set: expression - jsx-tag-name-component: - - match: '{{jsx_identifier}}' - scope: entity.name.tag.js - set: - - match: '[:.]' - scope: punctuation.accessor.js - set: jsx-tag-name - - include: else-pop - - include: else-pop + function-parameter-binding-name: + - match: '{{non_reserved_identifier}}' + scope: meta.binding.name.js variable.parameter.function.js + - match: '{{identifier_name}}' + scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js - support-property-node-process: - - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} - scope: support.constant.node.js + flow-type-utility: + - match: |- + (?x) (?: + Class|Function| + \$(?: + Keys|Values|ReadOnly|Exact|Diff|Rest|PropertyType|ElementType| + ObjMap|TupleMap|Call|Supertype|Subtype + ) + ){{identifier_break}} + scope: support.type.utility.js pop: true - - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} - scope: support.function.node.js + + statements: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js pop: true - ternary-operator-expect-colon: - - match: ':' - scope: keyword.operator.ternary.js - set: expression-no-comma - - include: else-pop + - match: (?=\S) + push: statement - function-declaration-expect-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.function.js - pop: true + constructor-body-expect-arguments: + - include: function-call-arguments - include: else-pop - decorator-expression-begin: - - include: decorator-name - - include: expression-begin - - switch-block: + flow-type-module-body: - match: \{ scope: punctuation.section.block.begin.js - set: switch-block-contents + set: flow-type-module-contents - include: else-pop - flow-type-meta: - - meta_scope: meta.flow-type.js - - include: immediately-pop + function-parameter-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: function-parameter - import-statement-or-import-meta: - - match: (?=import{{identifier_break}}) - branch_point: import-statement - branch: - - import-statement - - expression-statement + export-brace: + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js + pop: true + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + push: import-export-alias + - match: \* + scope: constant.other.js + push: import-export-alias + - include: else-pop - object-literal: - - match: \{ - scope: punctuation.section.block.begin.js - set: object-literal-contents + property-access: + - match: ({{dot_accessor}})?(\[) + captures: + 1: punctuation.accessor.js + 2: punctuation.section.brackets.begin.js + push: + - meta_scope: meta.brackets.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - match: (?=\S) + push: expression - decorator: - - match: '@' - scope: punctuation.definition.annotation.js + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js push: - - decorator-meta - - decorator-expression-end - - decorator-expression-begin + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: + - call-method-meta + - function-call-arguments + - call-path + - object-property + - include: object-property - variable-binding-name: - - match: (?={{non_reserved_identifier}}) + import-expression-end: + - match: (?=\() + set: function-call-arguments + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - - meta_scope: meta.binding.name.js - - include: immediately-pop - - literal-variable + - match: meta{{identifier_break}} + scope: variable.language.import.js + pop: true + - include: object-property + - include: else-pop + expression-list: + - include: expression-break + - include: comma-separator + - match: (?=\S) + push: expression-no-comma - flow-type-annotation: - - match: ':' - scope: punctuation.separator.type.js + flow-type-list: + - include: comma-separator + - match: (?=\S) + push: flow-type + + literal-string-template-custom-lookahead: [] + flow-type-alias-initializer: + - match: '=' + scope: keyword.operator.assignment.js set: - flow-type-meta - flow-type - - match: (?!\s*(?:$|:|//|/\*)) - pop: true - - expect-label: - - meta_include_prototype: false - - match: (?={{nothing}}{{identifier_name}}) + - include: else-pop + literal-string: + - match: "'" + scope: punctuation.definition.string.begin.js set: - - match: '{{non_reserved_identifier}}' - scope: variable.label.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js pop: true - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js variable.label.js + - match: \n + scope: invalid.illegal.newline.js pop: true - - include: else-pop - - include: immediately-pop - - decorator-meta: - - meta_include_prototype: false - - meta_scope: meta.annotation.js - - include: immediately-pop - - expression-break: - - match: (?=[;})\]]) - pop: true - - comments: - - include: flow-type-pragma - - - match: /\*\*(?!/) - scope: punctuation.definition.comment.begin.js - push: - - jsdoc-comment - - jsdoc-block-tag - - match: /\* - scope: punctuation.definition.comment.begin.js - push: + - include: string-content + - match: '"' + scope: punctuation.definition.string.begin.js + set: - meta_include_prototype: false - - meta_scope: comment.block.js - - match: \*/ - scope: punctuation.definition.comment.end.js + - meta_scope: meta.string.js string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js pop: true - - match: // - scope: punctuation.definition.comment.js - push: - - meta_include_prototype: false - - meta_scope: comment.line.double-slash.js - match: \n + scope: invalid.illegal.newline.js pop: true + - include: string-content - support-variable-node: - - match: global{{identifier_break}} - scope: support.type.object.node.js - pop: true + ternary-operator-expect-colon: + - match: ':' + scope: keyword.operator.ternary.js + set: expression-no-comma + - include: else-pop - - match: Buffer{{identifier_break}} - scope: support.class.node.js - pop: true + label: + - match: ({{identifier_name}})\s*(:) + captures: + 1: entity.name.label.js + 2: punctuation.separator.js - - match: process{{identifier_break}} - scope: support.constant.node.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-process - - include: object-property - - include: else-pop - - include: else-pop + class-element: + - match: '' + pop: true + branch_point: class-field + branch: + - class-field + - method-declaration - # Module-level variables - - match: (?:__dirname|__filename|exports){{identifier_break}} - scope: support.constant.node.js + literal-variable-base: + - match: '{{dollar_only_identifier}}' + scope: variable.other.dollar.only.js punctuation.dollar.js pop: true - - match: module{{identifier_break}} - scope: support.constant.node.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-module - - include: object-property - - include: else-pop - - include: else-pop - - match: require{{identifier_break}} - scope: support.function.node.js + - match: '{{dollar_identifier}}' + scope: variable.other.dollar.js + captures: + 1: punctuation.dollar.js pop: true - - tagged-template: - - include: literal-string-template-custom-comments - - include: literal-string-template-custom-tags - - include: styled-components - - - match: '{{identifier_name}}(?=\s*`)' - scope: variable.function.tagged-template.js + - match: '{{constant_identifier}}' + scope: variable.other.constant.js pop: true - - detect-parenthesized-arrow: - - match: (?=:) + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js pop: true - branch_point: flow-arrow-function-return-type - branch: - - flow-detect-arrow-function-return-type - - immediately-pop-2 + - include: literal-private-variable - - match: (?==>) - fail: parenthesized-arrow-function - - match: (?=\S) - pop: 2 + ternary-operator: + - match: \?(?=[^.]|\.[0-9]) + scope: keyword.operator.ternary.js + set: + - ternary-operator-expect-colon + - expression-no-comma - block: - - match: \{ - scope: punctuation.section.block.begin.js + import-export-alias: + - match: as{{identifier_break}} + scope: keyword.control.import-export.js set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js + - match: default{{identifier_break}} + scope: keyword.control.import-export.js pop: true - - include: statements + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + pop: true + - include: else-pop + - include: else-pop - flow-type-annotation-optional: - - match: \?(?=:) - scope: storage.modifier.optional.js - - include: flow-type-annotation + variable-binding-top: + - match: (?={{binding_pattern_lookahead}}) + set: + - initializer + - variable-binding-pattern + - include: else-pop - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.js - - include: immediately-pop + computed-property-name: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - match: (?=\S) + push: expression - class-meta: - - meta_include_prototype: false - - meta_scope: meta.class.js - - include: immediately-pop + support-property-ecma-symbol: + - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} + scope: support.constant.builtin.js + pop: true + - match: (?:for|keyFor){{identifier_break}} + scope: support.function.builtin.js + pop: true literal-variable: - include: special-identifier @@ -2670,445 +2696,441 @@ contexts: - include: literal-variable-base - flow-type-import-type: - - match: type{{identifier_break}} - scope: keyword.declaration.js - - - match: typeof{{identifier_break}} - scope: keyword.operator.js + constructor-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.constructor.js + - include: immediately-pop - flow-type-begin: - - include: flow-type-existential - - include: flow-type-literal - - include: flow-type-special - - include: flow-type-primitive - - include: flow-type-utility - - include: flow-type-typeof - - include: flow-type-class - - include: flow-type-function - - include: flow-type-tuple - - include: flow-type-object + support-property-ecma-bigint: + - match: (?:asUintN|asIntN){{identifier_break}} + scope: support.function.builtin.js + pop: true + for-condition: + - match: \( + scope: punctuation.section.group.js + set: + - for-condition-end + - for-condition-contents - include: else-pop - function-declaration: - - match: '' - set: - - function-meta - - function-declaration-expect-body - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - function-declaration-expect-name - - function-declaration-expect-generator-star - - function-declaration-expect-function-keyword - - function-declaration-expect-async + jsx-expect-tag-end: + - meta_content_scope: meta.tag.js + - match: '>' + scope: meta.tag.js punctuation.definition.tag.end.js + pop: true + - include: else-pop - restricted-production: + try-meta: - meta_include_prototype: false - - match: '{{line_ending_ahead}}' - pop: true - - match: '' - set: expression-statement + - meta_scope: meta.try.js + - include: immediately-pop - string-content: - - match: \\\n - scope: constant.character.escape.newline.js - - match: \\(?:x\h\h|u\h\h\h\h|.) - scope: constant.character.escape.js + support-property-ecma-typedarray: + - match: (?:BYTES_PER_ELEMENT){{identifier_break}} + scope: support.constant.builtin.js + pop: true - for-condition-end: - - meta_scope: meta.group.js + function-declaration-expect-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.function.js + pop: true + - include: else-pop - - match: \) - scope: punctuation.section.group.js + support-property-ecma-promise: + - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} + scope: support.function.builtin.js pop: true - variable-binding-list: - - include: comma-separator - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer - - variable-binding-pattern - - include: else-pop + flow-type-import-type: + - match: type{{identifier_break}} + scope: keyword.declaration.js - jsx-interpolation: - - match: (?={/\*) - branch_point: jsx-interpolation-comment - branch: - - jsx-interpolation-comment - - jsx-interpolation-plain - - match: (?={) - push: jsx-interpolation-plain + - match: typeof{{identifier_break}} + scope: keyword.operator.js - function-parameter-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' - pop: true - - include: literal-string - - include: computed-property-name - - include: function-parameter-binding-name - - include: else-pop + left-expression-end: + - include: expression-break - import-expression-end: - - match: (?=\() - set: function-call-arguments - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - match: meta{{identifier_break}} - scope: variable.language.import.js - pop: true - - include: object-property - - include: else-pop - literal-string-template-custom-comments: [] - expect-case-colon: - - match: ':' - scope: punctuation.separator.js - pop: true - - include: else-pop + - match: (?=`) + push: literal-string-template - flow-type-primitive: - - match: boolean{{identifier_break}} - scope: support.type.primitive.boolean.js - pop: true + - match: (?=(?:{{dot_accessor}})?\() + push: function-call-arguments - - match: number{{identifier_break}} - scope: support.type.primitive.number.js - pop: true + - include: property-access - - match: string{{identifier_break}} - scope: support.type.primitive.string.js - pop: true + - include: else-pop - - match: null{{identifier_break}} - scope: support.type.primitive.null.js + flow-type-special: + - match: any{{identifier_break}} + scope: support.type.any.js pop: true - - match: void{{identifier_break}} - scope: support.type.primitive.void.js + - match: mixed{{identifier_break}} + scope: support.type.mixed.js pop: true - flow-type-class: - - match: '{{non_reserved_identifier}}' - scope: variable.other.class.js + support-property-node-process: + - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} + scope: support.constant.node.js + pop: true + - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} + scope: support.function.node.js pop: true - initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: expression-no-comma - - include: else-pop - - do-while-condition: - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: parenthesized-expression - - include: else-pop + switch-block-contents: + - meta_scope: meta.block.js - support-property-ecma-string: - - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} - scope: support.function.builtin.js + - match: \} + scope: punctuation.section.block.end.js pop: true - function-parameter-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: function-parameter-binding-pattern - - include: else-pop - - literal-string-template-custom-lookahead: [] - flow-type-list: - - include: comma-separator - - match: (?=\S) - push: flow-type + - match: case{{identifier_break}} + scope: keyword.control.conditional.case.js + push: + - expect-case-colon + - expression - jsdoc-block-tag: - - match: '{{jsdoc_block_tag}}' - scope: entity.other.attribute-name.documentation.js - pop: 1 - - match: (?=\S)|$ - pop: 1 + - match: default{{identifier_break}} + scope: keyword.control.conditional.default.js + push: + - expect-case-colon - inherited-class-expression-begin: - - include: inherited-class-name - - include: expression-begin + - include: statements - arrow-function-expect-parameters: - - match: (?={{identifier_start}}) + class-field: + - match: '' set: - - clear_scopes: 1 - - meta_scope: meta.function.parameters.js - - match: '{{identifier_name}}' - scope: variable.parameter.function.js - pop: true - - include: function-declaration-parameters + - initializer + - flow-type-annotation + - class-field-check + - field-name + + flow-type-object-value: + - match: (\?)?(:) + captures: + 1: storage.modifier.optional.js + 2: punctuation.separator.key-value.js + set: flow-type - include: else-pop - support-property-ecma-typedarray: - - match: (?:BYTES_PER_ELEMENT){{identifier_break}} - scope: support.constant.builtin.js - pop: true + do-while-meta: + - meta_include_prototype: false + - meta_scope: meta.do-while.js + - include: immediately-pop - literal-string-template: - - match: '`' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content + await-expression: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js - function-declaration-expect-async: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js + prototype: + - include: comments + + flow-type-primitive: + - match: boolean{{identifier_break}} + scope: support.type.primitive.boolean.js pop: true - - include: else-pop - immediately-pop: - - match: '' + - match: number{{identifier_break}} + scope: support.type.primitive.number.js pop: true - literal-private-variable: - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js + - match: string{{identifier_break}} + scope: support.type.primitive.string.js pop: true - support-property-ecma-reflect: - - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} - scope: support.function.builtin.js + - match: null{{identifier_break}} + scope: support.type.primitive.null.js pop: true - support-property-ecma-proxy: - - match: revocable{{identifier_break}} - scope: support.function.builtin.js + - match: void{{identifier_break}} + scope: support.type.primitive.void.js pop: true - flow-type-module-meta: - - meta_scope: meta.module.js + switch-meta: + - meta_include_prototype: false + - meta_scope: meta.switch.js - include: immediately-pop - flow-type-operators: - - match: \|(?!\}) - scope: keyword.operator.type.union.js - push: flow-type-begin - - match: \& - scope: keyword.operator.type.intersection.js - push: flow-type-begin - - match: => - scope: keyword.declaration.function.arrow.js - push: flow-type-begin - - match: \? - scope: storage.modifier.maybe.js - push: flow-type-begin - - match: \. - scope: punctuation.separator.accessor.js - push: flow-type-begin - - - match: \[\] - scope: storage.modifier.array.js - - match: '%checks{{identifier_break}}' - scope: storage.modifier.checks.js - - support-property-ecma-date: - - match: (?:now|parse|UTC){{identifier_break}} - scope: support.function.builtin.js - pop: true - - expression-list: - - include: expression-break - - include: comma-separator - - match: (?=\S) - push: expression-no-comma + flow-type-export-type: + - match: type{{identifier_break}}(?=\s*\{) + scope: keyword.declaration.js + set: export-item + - include: flow-type-alias - class-element-modifier: - - match: '{{modifier}}' - scope: storage.modifier.js + function-declaration-parameters: + - match: \( + scope: punctuation.section.group.begin.js set: - - match: (?={{class_element_name}}|\*) + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js + - match: \) + scope: punctuation.section.group.end.js pop: true - - match: (?=\S) - fail: class-element-modifier - - function-declaration-expect-body: - - include: function-block - - include: else-pop + - include: function-parameter-binding-list - flow-type-module-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: flow-type-module-contents - - include: else-pop + object-property: + - include: support-property - computed-property-name: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) set: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - match: (?=\S) - push: expression + - function-name-meta + - object-property-base - flow-type-utility: - - match: |- - (?x) (?: - Class|Function| - \$(?: - Keys|Values|ReadOnly|Exact|Diff|Rest|PropertyType|ElementType| - ObjMap|TupleMap|Call|Supertype|Subtype - ) - ){{identifier_break}} - scope: support.type.utility.js - pop: true + - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: call-method-name - support-property: - - include: support-property-ecma + - include: object-property-base + - include: else-pop - async-arrow-function: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow-or-fail-async - - arrow-function-expect-parameters + flow-type-meta: + - meta_scope: meta.flow-type.js + - include: immediately-pop - literal-variable-base: - - match: '{{dollar_only_identifier}}' - scope: variable.other.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: variable.other.dollar.js + flow-type-pragma: + - match: (//)\s*(?=@) + scope: comment.line.double-slash.pragma.js captures: - 1: punctuation.dollar.js - pop: true - - match: '{{constant_identifier}}' - scope: variable.other.constant.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true - - include: literal-private-variable - - flow-type-generic-parameters: - - match: < - scope: punctuation.section.generic.begin.js - set: - - meta_scope: meta.generic.declaration.js - - match: '>' - scope: punctuation.section.generic.end.js + 1: punctuation.definition.comment.js + push: + - meta_include_prototype: false + - match: (@)(flow) + captures: + 1: punctuation.definition.pragma.js + 2: support.function.pragma.js pop: true - - include: comma-separator - - match: \+ - scope: storage.modifier.variance.js - - match: '{{non_reserved_identifier}}' - scope: variable.parameter.type.js - push: - - - match: '=' - scope: keyword.operator.assignment.js - set: flow-type - - include: else-pop - - flow-type-annotation - - include: else-pop + - include: else-pop + + variable-binding-name: + - match: (?={{non_reserved_identifier}}) + set: + - - meta_scope: meta.binding.name.js + - include: immediately-pop + - literal-variable - support-property-ecma-atomics: - - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} - scope: support.function.builtin.js - pop: true + support-property: + - include: support-property-ecma - for-oldstyle-rest: - - match: (?=\)) + restricted-production: + - meta_include_prototype: false + - match: '{{line_ending_ahead}}' pop: true - - match: ; - scope: punctuation.separator.expression.js - - match: (?=\S) - push: expression + - match: '' + set: expression-statement + + jsx-interpolation-plain: + - match: '{' + scope: punctuation.definition.interpolation.begin.js + set: + - - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.jsx + - match: '}' + scope: punctuation.definition.interpolation.end.js + pop: true + - expression flow-detect-arrow-function-return-type: - match: '' push: - flow-detect-arrow-after-return-type - - flow-type-annotation + - flow-arrow-function-return-type-annotation - left-expression-end: - - include: expression-break + styled-components: + - match: (?=(?:styled|css|createGlobalStyle|injectGlobal|keyframes){{identifier_break}}) + set: + - styled-component-end + - styled-component-begin + decorator-expression-begin: + - include: decorator-name + - include: expression-begin - - match: (?=`) - push: literal-string-template + flow-type-tuple: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: flow-type-list - - match: (?=(?:{{dot_accessor}})?\() - push: function-call-arguments + yield-expression: + - match: yield{{identifier_break}} + scope: keyword.control.flow.yield.js + set: + - match: $ + pop: true + - match: \* + scope: keyword.generator.asterisk.js + set: expression-begin + - match: (?=\S) + set: expression-begin + constructor-body-expect-class-end: - include: property-access - - include: else-pop - constructor-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.constructor.js - - include: immediately-pop + flow-type-module-contents: + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: main - flow-type-literal: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js + special-identifier: + # These are ordinary identifiers, not reserved words + - match: arguments{{identifier_break}} + scope: variable.language.arguments.js pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js + - match: globalThis{{identifier_break}} + scope: variable.language.global.js pop: true - - match: (?=\d) - set: - - - match: '{{identifier_part}}+' - scope: invalid.illegal.js - - include: immediately-pop - - literal-number - - match: (?=['"]) - set: literal-string - - call-method-name: - - include: support-property - - match: '{{identifier_name}}' - scope: variable.function.js + - match: undefined{{identifier_break}} + scope: constant.language.undefined.js pop: true - - match: (#){{identifier_name}} - scope: variable.function.js - captures: - 1: punctuation.definition.js + - match: NaN{{identifier_break}} + scope: constant.language.nan.js + pop: true + - match: Infinity{{identifier_break}} + scope: constant.language.infinity.js pop: true - - include: else-pop - switch-meta: - - meta_include_prototype: false - - meta_scope: meta.switch.js - - include: immediately-pop + comments: + - include: flow-type-pragma - support-variable-console: - # https://console.spec.whatwg.org/ - - match: console{{identifier_break}} - scope: support.type.object.console.js + - match: /\*\*(?!/) + scope: punctuation.definition.comment.begin.js + push: + - jsdoc-comment + - jsdoc-block-tag + - match: /\* + scope: punctuation.definition.comment.begin.js + push: + - meta_include_prototype: false + - meta_scope: comment.block.js + - match: \*/ + scope: punctuation.definition.comment.end.js + pop: true + - match: // + scope: punctuation.definition.comment.js + push: + - meta_include_prototype: false + - meta_scope: comment.line.double-slash.js + - match: \n + pop: true + + class-element-modifier: + - match: '{{modifier}}' + scope: storage.modifier.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: builtin-console-properties - - include: else-pop + - match: (?={{class_element_name}}|\*) + pop: true + - match: (?=\S) + fail: class-element-modifier + + class-meta: + - meta_include_prototype: false + - meta_scope: meta.class.js + - include: immediately-pop +scope: source.js +variables: + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) + arrow_func_lookahead: |- + (?x)(?: + \s*(async\s*)? + (?: + {{non_reserved_identifier}} + |\( (?: [^()]|\([^()]*\) )* \) + ) + (?: + \s*: + \s*{{non_reserved_identifier}} + )? + \s*=> + ) + jsdoc_block_tag: \@[^\n\t\f\v *@]+ + binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) + line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) + block_comment_contents: (?:(?:[^*]|\*(?!/))*) + oct_digit: '[0-7_]' + bin_digit: '[01_]' + property_name: >- + (?x: + {{identifier_name}} + | [0-9]+ + | '(?:[^\\']|\\.)*' + | "(?:[^\\"]|\\.)*" + | \[ .* \] + ) + jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' + class_element_name: |- + (?x: + \+? + (?: + \*? + {{property_name}} + | \#{{non_reserved_identifier}} + ) + ) + block_comment: (?:/\*{{block_comment_contents}}\*/) + dec_integer: (?:0|[1-9]{{dec_digit}}*) + dot_accessor: (?:\??\.) + nothing: (?x:(?:\s+|{{block_comment}})*) + jsx_identifier_part: (?:{{identifier_part}}|-) + identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) + modifier: (?:static{{identifier_break}}) + line_continuation_lookahead: >- + (?x:(?= + (?! \+\+ | -- ) + (?= + != | + [-+*/%><=&|^\[(;,.:?] | + (?:in|instanceof){{identifier_break}} + ) + )) + either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) + function_call_lookahead: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + method_lookahead: |- + (?x)(?= + (?: get|set|async ){{identifier_break}}(?!\s*:) + | \* + | {{property_name}} \s* (?:\(|<) + ) + dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' + identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) + left_expression_end_lookahead: (?!\s*[.\[\(]) + func_lookahead: |- + (?x: + (?:async{{identifier_break}}{{nothing}})? + function{{identifier_break}} + ) + dollar_only_identifier: (?:\${{identifier_break}}) + hex_digit: '[\h_]' + dec_digit: '[0-9_]' + constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) + jsx_identifier_break: (?!{{jsx_identifier_part}}) + identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) + identifier_break: (?!{{identifier_part}}) + function_assignment_lookahead: |- + (?x:(?= + \s* = \s* + {{either_func_lookahead}} + )) + identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + reserved_word: |- + (?x: + break|case|catch|class|const|continue|debugger|default|delete|do|else| + export|extends|finally|for|function|if|import|in|instanceof|new|return| + super|switch|this|throw|try|typeof|var|void|while|with|yield| + enum| + null|true|false + ){{identifier_break}} file_extensions: - js - jsx - es6 - babel +first_line_match: ^#!\s*/.*\b(node|js)\b name: JavaScript (Babel) diff --git a/tests/syntax_test_flow.js b/tests/syntax_test_flow.js index 6161164..f0d82f6 100644 --- a/tests/syntax_test_flow.js +++ b/tests/syntax_test_flow.js @@ -414,8 +414,5 @@ class MyClass { // ^^^^^^^^ variable.other.readwrite // ^^ keyword.control.import-export - const C = (props: any): React.Node => {} -// ^^^^^ variable.other.class -// ^ punctuation.separator.accessor -// ^^^^ variable.other.class + const C = (props: any): React.Node => {}; // ^^ keyword.declaration.function