diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax index 709e6fe..de56788 100644 --- a/JavaScript (Babel).sublime-syntax +++ b/JavaScript (Babel).sublime-syntax @@ -1,316 +1,209 @@ %YAML 1.2 --- contexts: - variable-binding-object-key: - - match: '{{identifier}}(?=\s*:)' + else-pop: + - match: (?=\S) pop: true - - include: literal-string - - include: computed-property-name - - include: variable-binding-name - - include: else-pop - class-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: class-body-contents + 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 + flow-type-end: + - include: flow-type-operators + - match: (?=<) + push: flow-type-generic-arguments - include: else-pop - function-declaration-identifiers: - - match: (?={{identifier}}\s*\.) - push: - - expect-dot-accessor - - function-declaration-identifiers-expect-class - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js + support-property-ecma-bigint: + - match: (?:asUintN|asIntN){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: (?=#?{{identifier}}) - set: - - function-name-meta - - literal-variable-base - function-parameter-binding-list: - - match: ',' - scope: punctuation.separator.parameter.function.js - - include: function-parameter-binding-spread - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer - - function-parameter-binding-pattern + call-path: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: object-property - 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: constant.numeric.float.decimal.js - captures: - 1: punctuation.separator.decimal.js - 2: punctuation.separator.decimal.js - pop: true + variable-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.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 - # integers - - match: 0{{dec_digit}}+{{identifier_break}} - scope: constant.numeric.integer.octal.js invalid.deprecated.numeric.octal.js - pop: true + import-meta: + - meta_include_prototype: false + - meta_scope: meta.import.js + - include: immediately-pop - - match: (0[Xx]){{hex_digit}}*(n)?{{identifier_break}} - scope: constant.numeric.integer.hexadecimal.js - captures: - 1: punctuation.definition.numeric.base.js - 2: storage.type.numeric.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: (0[Oo]){{oct_digit}}*(n)?{{identifier_break}} - scope: constant.numeric.integer.octal.js - captures: - 1: punctuation.definition.numeric.base.js - 2: storage.type.numeric.js + flow-type-literal: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js pop: true - - - match: (0[Bb]){{bin_digit}}*(n)?{{identifier_break}} - scope: constant.numeric.integer.binary.js - captures: - 1: punctuation.definition.numeric.base.js - 2: storage.type.numeric.js + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js pop: true + - match: (?=\d) + set: + - - match: '{{identifier_part}}+' + scope: invalid.illegal.js + - include: immediately-pop + - literal-number + - match: (?=['"]) + set: literal-string - - match: '{{dec_integer}}(n|(?!\.)){{identifier_break}}' - scope: constant.numeric.integer.decimal.js - captures: - 1: storage.type.numeric.js + flow-type-class: + - match: '{{identifier}}' + scope: variable.other.class.js pop: true - # illegal numbers - - match: 0[Xx]{{identifier_part}}+ - scope: invalid.illegal.numeric.hexadecimal.js - pop: true + expression-list: + - include: expression-break + - include: comma-separator + - match: (?=\S) + push: expression-no-comma - - match: 0[Bb]{{identifier_part}}+ - scope: invalid.illegal.numeric.binary.js + call-function-name: + - match: '{{dollar_only_identifier}}' + scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js pop: true - - - match: 0{{identifier_part}}+ - scope: invalid.illegal.numeric.octal.js + - match: '{{identifier}}' + scope: variable.function.js pop: true + - include: else-pop - - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' - scope: invalid.illegal.numeric.decimal.js - pop: true + conditional: + - match: switch{{identifier_break}} + scope: keyword.control.conditional.switch.js + set: + - switch-meta + - switch-block + - expect-parenthesized-expression - flow-type-object-indexer-type: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list + - match: do{{identifier_break}} + scope: keyword.control.loop.do-while.js + set: + - do-while-meta + - do-while-condition + - block-scope - for-condition-contents: - # This could be either type of for loop. - - match: (?:const|let|var){{identifier_break}} - scope: storage.type.js + - match: for{{identifier_break}} + scope: keyword.control.loop.for.js set: - - - include: for-of-rest - - match: (?=\S) - set: - - for-oldstyle-rest - - variable-binding-list - - initializer - - variable-binding-pattern + - for-meta + - block-scope + - for-condition + - for-await - - match: (?=\S) + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js set: - - - include: for-of-rest - - match: (?=\S) - set: for-oldstyle-rest - - expression-end-no-in - - expression-begin + - while-meta + - block-scope + - expect-parenthesized-expression - string-content: - - match: \\\n - scope: constant.character.escape.newline.js - - match: \\(?:x\h\h|u\h\h\h\h|.) - scope: constant.character.escape.js + - match: with{{identifier_break}} + scope: keyword.control.import.with.js + set: + - with-meta + - block-scope + - expect-parenthesized-expression - block: - - match: \{ - scope: punctuation.section.block.begin.js + - match: if{{identifier_break}} + scope: keyword.control.conditional.if.js set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements + - conditional-meta + - block-scope + - expect-parenthesized-expression - variable-binding-pattern: - - match: '' + - match: else\s+if{{identifier_break}} + scope: keyword.control.conditional.elseif.js set: - - - include: flow-type-annotation - - - include: variable-binding-name - - include: variable-binding-array-destructuring - - include: variable-binding-object-destructuring - - include: else-pop + - conditional-meta + - block-scope + - expect-parenthesized-expression - expect-label: - - meta_include_prototype: false - - match: (?={{nothing}}{{identifier}}) + - match: else{{identifier_break}} + scope: keyword.control.conditional.else.js set: - - match: '{{non_reserved_identifier}}' - scope: variable.label.js - pop: true - - match: '{{identifier}}' - scope: invalid.illegal.identifier.js variable.label.js - pop: true - - include: else-pop - - include: immediately-pop + - conditional-meta + - block-scope - flow-type-declare: - - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) - scope: storage.type.js + - match: try{{identifier_break}} + scope: keyword.control.exception.try.js set: - - match: opaque{{identifier_break}} - scope: storage.modifier.js - pop: true - - match: module{{identifier_break}} - scope: storage.type.js - set: - - flow-type-module-meta - - flow-type-module-body - - flow-type-module-name - - match: export{{identifier_break}} - scope: storage.type.js - set: flow-type-declare-export - - include: else-pop - - prototype: - - include: comments - - flow-type-declare-export: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: flow-type - - match: (?=\S) - pop: true - - fallthrough: - # If an arrow function has the ( and ) on different lines, we won't have matched - - match: => - scope: storage.type.function.arrow.js - push: - - function-meta - - arrow-function-expect-body - - decorator-expression-begin: - - include: decorator-name - - include: expression-begin + - try-meta + - block-scope - 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 + - match: finally{{identifier_break}} + scope: keyword.control.exception.finally.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 + - finally-meta + - block-scope - method-name: - - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js entity.name.function.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier}}' - scope: entity.name.function.js - pop: true - - match: "'" - scope: punctuation.definition.string.begin.js + - match: catch{{identifier_break}} + scope: keyword.control.exception.catch.js 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 + - catch-meta + - block-scope + - expect-parenthesized-expression + + expect-label: + - meta_include_prototype: false + - match: (?={{nothing}}{{identifier}}) 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 + - match: '{{non_reserved_identifier}}' + scope: variable.label.js pop: true - - match: \n - scope: invalid.illegal.newline.js + - match: '{{identifier}}' + scope: invalid.illegal.identifier.js variable.label.js pop: true - - include: string-content - - - match: (?=\[) - push: computed-property-name + - include: else-pop + - include: immediately-pop - - include: else-pop + flow-type-object-indexer-type: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: flow-type-list - import-expression-end: - - match: (?=\() - set: function-call-arguments - - match: \. - scope: punctuation.accessor.js - set: - - match: meta{{identifier_break}} - scope: variable.language.import.js - pop: true - - include: object-property - - include: else-pop - 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 + 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: comma-separator - - match: \+ - scope: storage.modifier.variance.js - - match: '{{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-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: variable-binding-pattern + call-function-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.js - include: else-pop flow-type-typeof: @@ -320,85 +213,105 @@ contexts: - left-expression-end - expression-begin - method-declaration-expect-prefix: - - match: \* - scope: keyword.generator.asterisk.js - - match: (?:get|set){{identifier_break}}(?!\s*\() - scope: storage.type.accessor.js - - include: else-pop + variable-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: variable-binding-pattern - 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: storage.type.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 + 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: \[\] - scope: storage.modifier.array.js - - match: '%checks{{identifier_break}}' - scope: storage.modifier.checks.js + function-parameter-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: function-parameter-binding-pattern - field-name: + function-declaration-identifiers-expect-class: + - match: prototype{{identifier_break}} + scope: support.constant.prototype.js + pop: true + - include: language-identifiers + - match: '{{dollar_only_identifier}}' + scope: support.class.dollar.only.js punctuation.dollar.js + pop: true - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js variable.other.readwrite.js + scope: support.class.dollar.js captures: 1: punctuation.dollar.js pop: true - match: '{{identifier}}' - scope: variable.other.readwrite.js + scope: support.class.js pop: true - - match: "'" - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - meta_content_scope: variable.other.readwrite.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: variable.other.readwrite.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: (#)({{identifier}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js - - - match: (?=\[) - push: computed-property-name - - include: else-pop - function-declaration: - - match: '' - set: - - function-meta - - function-declaration-expect-body + function-assignment: + - match: |- + (?x)(?= + (?:{{identifier}} \s* \. \s*)* + {{identifier}} + \s* = \s* + {{either_func_lookahead}} + ) + set: + - function-initializer + - function-declaration-identifiers + + flow-type-list: + - include: comma-separator + - match: (?=\S) + push: flow-type + + call-method-name: + - include: support-property + - match: '{{identifier}}' + scope: variable.function.js + pop: true + - include: else-pop + + decorator-meta: + - meta_include_prototype: false + - meta_scope: meta.annotation.js + - include: immediately-pop + + expression-begin: + - include: jsx-tag + + - 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 + + - include: class + - include: constants + - include: function-assignment + - include: either-function-declaration + - include: object-literal + + - include: parenthesized-expression + - include: array-literal + + - include: literal-call + - include: literal-variable + + - include: else-pop + + function-declaration: + - match: '' + set: + - function-meta + - function-declaration-expect-body - function-declaration-meta - flow-type-annotation - function-declaration-expect-parameters @@ -408,102 +321,330 @@ contexts: - function-declaration-expect-function-keyword - function-declaration-expect-async - function-declaration-expect-body: - - include: function-block - - include: else-pop + jsx-body: + - meta_include_prototype: false - support-property-ecma-arraybuffer: - - match: isView{{identifier_break}} - scope: support.function.builtin.js + - match: < + scope: punctuation.definition.tag.begin.js + set: + - meta_scope: meta.tag.js + + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-expect-tag-end + - jsx-tag-name + + - match: (?=\S) + set: + - jsx-body + - jsx-tag-attributes + - jsx-tag-name + + - include: jsx-html-escapes + - include: jsx-interpolation + variable-binding-object-key: + - match: '{{identifier}}(?=\s*:)' pop: true + - include: literal-string + - include: computed-property-name + - include: variable-binding-name + - include: else-pop - function-call-arguments: - - match: (\.\?)?(\() - captures: - 1: punctuation.accessor.js - 2: punctuation.section.group.begin.js + flow-type-alias-initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: + - flow-type-meta + - flow-type + - include: else-pop + flow-type-function: + - match: \( + scope: punctuation.section.grouping.begin.js set: - meta_scope: meta.group.js - match: \) - scope: punctuation.section.group.end.js + scope: punctuation.section.grouping.end.js pop: true - - include: expression-list + - include: flow-type-list - arrow-function-expect-arrow: - - match: => - scope: storage.type.function.arrow.js - pop: true - - include: else-pop + function-initializer: + - meta_scope: meta.function.declaration.js + - match: '=' + scope: keyword.operator.assignment.js + set: + - meta_content_scope: meta.function.declaration.js + - include: expression-no-comma - flow-type-module-name: - - include: literal-string - - match: '{{identifier}}' - scope: entity.name.module.js - pop: true - include: else-pop - function-declaration-expect-parameters: - - include: function-declaration-parameters + 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 - label: - - match: ({{identifier}})\s*(:) - captures: - 1: entity.name.label.js - 2: punctuation.separator.js - - expression-list: - - include: expression-break + flow-type-object-contents: - include: comma-separator - - match: (?=\S) - push: expression-no-comma + - match: ; + scope: punctuation.separator.semicolon.js + - match: '{{method_lookahead}}' + push: method-declaration + - match: \+ + scope: storage.modifier.variance.js + - match: '{{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 - support-variable-dom: - - match: XMLHttpRequest{{identifier_break}} - scope: support.class.dom.js + 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: constant.numeric.float.decimal.js + captures: + 1: punctuation.separator.decimal.js + 2: punctuation.separator.decimal.js pop: true - - match: (?:document|window|navigator){{identifier_break}} - scope: support.type.object.dom.js + + # integers + - match: 0{{dec_digit}}+{{identifier_break}} + scope: constant.numeric.integer.octal.js invalid.deprecated.numeric.octal.js pop: true - - match: (?:clearTimeout|setTimeout){{identifier_break}} - scope: support.function.dom.js + + - match: (0[Xx]){{hex_digit}}*(n)?{{identifier_break}} + scope: constant.numeric.integer.hexadecimal.js + captures: + 1: punctuation.definition.numeric.base.js + 2: storage.type.numeric.js pop: true - object-literal-expect-colon: - - match: ':' - scope: punctuation.separator.key-value.js - - include: else-pop + - match: (0[Oo]){{oct_digit}}*(n)?{{identifier_break}} + scope: constant.numeric.integer.octal.js + captures: + 1: punctuation.definition.numeric.base.js + 2: storage.type.numeric.js + pop: true - literal-variable-base: - - match: '{{dollar_only_identifier}}' - scope: variable.other.dollar.only.js punctuation.dollar.js + - match: (0[Bb]){{bin_digit}}*(n)?{{identifier_break}} + scope: constant.numeric.integer.binary.js + captures: + 1: punctuation.definition.numeric.base.js + 2: storage.type.numeric.js pop: true - - match: '{{dollar_identifier}}' - scope: variable.other.dollar.js + + - match: '{{dec_integer}}(n|(?!\.)){{identifier_break}}' + scope: constant.numeric.integer.decimal.js captures: - 1: punctuation.dollar.js + 1: storage.type.numeric.js pop: true - - match: '{{constant_identifier}}' - scope: variable.other.constant.js + + # illegal numbers + - match: 0[Xx]{{identifier_part}}+ + scope: invalid.illegal.numeric.hexadecimal.js pop: true - - match: '{{identifier}}' - scope: variable.other.readwrite.js + + - match: 0[Bb]{{identifier_part}}+ + scope: invalid.illegal.numeric.binary.js pop: true - - match: (#)({{identifier}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js + + - match: 0{{identifier_part}}+ + scope: invalid.illegal.numeric.octal.js pop: true - expect-case-colon: - - match: ':' - scope: punctuation.separator.js + - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' + scope: invalid.illegal.numeric.decimal.js pop: true - - include: else-pop - class-field: - - match: \+ - scope: storage.modifier.variance.js + flow-type-annotation-optional: + - match: \?(?=:) + scope: storage.modifier.optional.js + - include: flow-type-annotation + + support-property: + - include: support-property-ecma + + function-declaration-expect-body: + - include: function-block + - include: else-pop + + function-call-arguments: + - match: (\.\?)?(\() + 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 + + main: + - include: comments-top-level + + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + # Don't pop or embedding could break. + + - include: statements + + flow-type-annotation: + - match: ':' + scope: punctuation.separator.type.js + set: + - flow-type-meta + - flow-type + - match: (?!\s*(?:$|:|//|/\*)) + pop: true + + inherited-class-expression-end: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: inherited-class-name + - include: object-property + + - include: left-expression-end + + catch-meta: + - meta_include_prototype: false + - meta_scope: meta.catch.js + - include: immediately-pop + + class-extends: + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - flow-type-generic-arguments + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop + + import-string-or-items: + - include: literal-string + - match: (?=\S) + set: + - import-export-from + - import-list + - import-export-alias + - import-item + + function-declaration-identifiers: + - match: (?={{identifier}}\s*\.) + push: + - expect-dot-accessor + - function-declaration-identifiers-expect-class + - match: prototype{{identifier_break}} + scope: support.constant.prototype.js + pop: true + - match: (?=#?{{identifier}}) + set: + - function-name-meta + - literal-variable-base + + flow-type-alias: + - match: (?=type{{identifier_break}}) + set: + - - match: (?={{identifier}}) + set: + - - meta_scope: meta.declaration.type.js + - match: '' + pop: true + - flow-type-alias-initializer + - flow-type-generic-parameters + - - match: '{{identifier}}' + scope: entity.name.type.js + pop: true + - - include: else-pop + + - match: (?=\S) + set: [expression-statement, expression-end] + - - match: type{{identifier_break}}(?=\s*(?:$|{{identifier}})) + scope: storage.type.js + set: + - meta_scope: meta.declaration.type.js + - include: else-pop + - include: expression-begin + + expect-semicolon: + - match: \; + scope: punctuation.terminator.statement.js + pop: true + - include: else-pop + + 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 + + variable-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: variable-binding-pattern + - include: else-pop + + 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 + + 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: '"' + scope: punctuation.definition.string.begin.js + set: + - meta_include_prototype: false + - meta_scope: string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js + pop: true + - include: jsx-html-escapes + + - include: else-pop + + statements: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + pop: true + + - match: (?=\S) + push: statement + + class-field: + - match: \+ + scope: storage.modifier.variance.js - match: '{{method_lookahead}}' set: method-declaration @@ -535,57 +676,21 @@ contexts: - 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 - - function-name-meta: - - meta_include_prototype: false - - meta_scope: entity.name.function.js - - include: immediately-pop - - support-property-ecma-string: - - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} - scope: support.function.builtin.js - pop: true - - support-property-ecma-promise: - - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} - scope: support.function.builtin.js - pop: true + import-brace: + - include: flow-type-import-type - support-property-ecma-proxy: - - match: revocable{{identifier_break}} - scope: support.function.builtin.js + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js pop: true - - jsx-tag-attributes: - - meta_content_scope: meta.tag.js - - - match: '>' - scope: punctuation.definition.tag.end.js - set: jsx-body - - - match: / - scope: punctuation.definition.tag.end.js - set: jsx-expect-tag-end - - - include: jsx-interpolation - - - match: '{{jsx_identifier}}' - scope: entity.other.attribute-name.js - - - match: '=' - scope: punctuation.separator.key-value.js - push: jsx-attribute-value - - await-expression: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js + - match: '{{identifier}}' + scope: variable.other.readwrite.js + push: import-export-alias + - match: \* + scope: constant.other.js + push: import-export-alias + - include: else-pop function-declaration-expect-generator-star: - match: \* @@ -593,608 +698,481 @@ contexts: pop: true - include: else-pop - variable-binding-name: - - match: (?={{non_reserved_identifier}}) - set: - - meta_scope: meta.binding.name.js - - include: literal-variable + import-item: + - include: flow-type-import-type - function-declaration-expect-function-keyword: - - match: function{{identifier_break}} - scope: storage.type.function.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: else-pop - with-meta: - - meta_include_prototype: false - - meta_scope: meta.with.js - - include: immediately-pop - - 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 + inherited-class-expression-begin: + - include: inherited-class-name + - include: expression-begin - import-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - import-item - - include: else-pop + 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 - class-meta: + tagged-template: + - match: '{{identifier}}(?=\s*`)' + scope: variable.function.tagged-template.js + pop: true + + for-meta: - meta_include_prototype: false - - meta_scope: meta.class.js + - meta_scope: meta.for.js - include: immediately-pop - flow-type-object-value: - - match: (\?)?(:) - captures: - 1: storage.modifier.optional.js - 2: punctuation.separator.key-value.js - set: flow-type - - include: else-pop + support: + - include: support-variable-ecma + - include: support-variable-console + - include: support-variable-dom + - include: support-variable-node - 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 + function-or-class-declaration: + - match: (?=class{{identifier_break}}) + set: class + + - match: (?={{func_lookahead}}) + set: function-declaration + + literal-variable-base: + - match: '{{dollar_only_identifier}}' + scope: variable.other.dollar.only.js punctuation.dollar.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 + - match: '{{dollar_identifier}}' + scope: variable.other.dollar.js + captures: + 1: punctuation.dollar.js pop: true - - expect-semicolon: - - match: \; - scope: punctuation.terminator.statement.js + - match: '{{constant_identifier}}' + scope: variable.other.constant.js pop: true - - include: else-pop - - 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 + - match: '{{identifier}}' + scope: variable.other.readwrite.js pop: true - - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} - scope: support.function.builtin.js + - match: (#)({{identifier}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js pop: true - finally-meta: + expression: - meta_include_prototype: false - - meta_scope: meta.finally.js - - include: immediately-pop + - match: '' + set: [expression-end, expression-begin] - function-declaration-meta: - - meta_include_prototype: false - - meta_scope: meta.function.declaration.js - - clear_scopes: 1 - - include: immediately-pop + comments: + - include: flow-type-pragma + + - match: /\*\*(?!/) + scope: punctuation.definition.comment.begin.js + push: + - meta_include_prototype: false + - meta_scope: comment.block.documentation.js + - match: \*/ + scope: punctuation.definition.comment.end.js + pop: true + - match: ^\s*(\*)(?!/) + captures: + 1: punctuation.definition.comment.js + - 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-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: class-body-contents - do-while-condition: - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: parenthesized-expression - include: else-pop - support-variable-node: - - match: global{{identifier_break}} - scope: support.type.object.node.js - pop: true + initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: expression-no-comma + - include: else-pop - - match: Buffer{{identifier_break}} - scope: support.class.node.js - pop: true + flow-type-export-type: + - match: type{{identifier_break}}(?=\s*\{) + scope: storage.type.js + set: export-item + - include: flow-type-alias - - 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 + method-declaration-expect-prefix: + - match: \* + scope: keyword.generator.asterisk.js + - match: (?:get|set){{identifier_break}}(?!\s*\() + scope: storage.type.accessor.js + - include: else-pop - # Module-level variables - - match: (?:__dirname|__filename|exports){{identifier_break}} + object-literal-meta-key: + - meta_scope: meta.mapping.key.js + - 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: 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 - constructor-body-expect-class-end: - - include: property-access + class-field-rest: + - match: ',' + scope: punctuation.separator.js + push: + - initializer + - field-name - include: else-pop - literal-call: - - match: (?={{identifier}}\s*(?:\.\?)?\() - set: - - call-function-meta - - function-call-arguments - - literal-variable - - - match: (?={{identifier}}\s*(?:\.\s*{{identifier}}\s*)+(?:\.\?)?\() - set: - - call-method-meta - - function-call-arguments - - call-path - - literal-variable - - support-property-ecma-bigint: - - match: (?:asUintN|asIntN){{identifier_break}} - scope: support.function.builtin.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 - decorator-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: decorator-name - - include: object-property - - - include: left-expression-end - - expression-no-comma: - - meta_include_prototype: false + function-parameter-binding-pattern: - match: '' - set: [expression-end-no-comma, expression-begin] + 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 - import-brace: - - include: flow-type-import-type + comments-top-level: + - match: ^(#!).*$\n? + scope: comment.line.shebang.js + captures: + 1: punctuation.definition.comment.js + + object-literal-contents: + - meta_scope: meta.mapping.js - - meta_scope: meta.block.js - - include: comma-separator - match: \} scope: punctuation.section.block.end.js pop: true - - match: '{{identifier}}' - scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias - - include: else-pop - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation + - match: \.\.\. + scope: keyword.operator.spread.js + push: expression-no-comma - - 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: '"' - scope: punctuation.definition.string.begin.js - set: - - 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)(?= + {{property_name}}\s*: + (?: {{either_func_lookahead}} ) + ) + push: + - either-function-declaration + - function-declaration-meta-no-clear + - object-literal-expect-colon + - object-literal-meta-key + - method-name - - include: else-pop + - match: '{{method_lookahead}}' + push: method-declaration - constructor-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.constructor.js - - include: immediately-pop + - match: '{{identifier}}(?=\s*(?:[},]|$|//|/\*))' + scope: variable.other.readwrite.js - function-parameter-binding-name: - - match: '{{non_reserved_identifier}}' - scope: meta.binding.name.js variable.parameter.function.js - - match: '{{identifier}}' - scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js + - match: (?=\[) + push: + - object-literal-meta-key + - computed-property-name - for-meta: - - meta_include_prototype: false - - meta_scope: meta.for.js - - include: immediately-pop + - match: (?=\"|') + push: + - object-literal-meta-key + - literal-string - 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: (?=[-+]?(?:\.[0-9]|0[bxo]|\d)) + push: + - object-literal-meta-key + - literal-number - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.js - - include: immediately-pop + # - include: bare-property-name + - match: (?={{identifier}}) + push: + - object-literal-meta-key + - bare-property-name - flow-type-generic-arguments: - - match: < - scope: punctuation.section.generic.begin.js + - include: comma-separator + - match: ':' + scope: punctuation.separator.key-value.js + push: expression-no-comma + + # In case we're inside a destructured arrow function parameter that we + # misidentified as an object literal. + - match: '=' + scope: keyword.operator.assignment.js + push: expression-no-comma + + literal-call: + - match: (?={{identifier}}\s*(?:\.\?)?\() set: - - meta_scope: meta.generic.js - - match: '>' - scope: punctuation.section.generic.end.js - pop: true - - include: flow-type-list - - include: else-pop + - call-function-meta + - function-call-arguments + - literal-variable - flow-type-function: - - match: \( - scope: punctuation.section.grouping.begin.js + - match: (?={{identifier}}\s*(?:\.\s*{{identifier}}\s*)+(?:\.\?)?\() set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.grouping.end.js + - call-method-meta + - function-call-arguments + - call-path + - literal-variable + + import-meta-expression: + - match: import{{identifier_break}} + scope: keyword.import.js + set: import-expression-end + + yield-expression: + - match: yield{{identifier_break}} + scope: keyword.control.flow.yield.js + set: + - match: $ pop: true - - include: flow-type-list + - match: \* + scope: keyword.generator.asterisk.js + set: expression-begin + - match: (?=\S) + set: expression-begin - comments: - - include: flow-type-pragma + immediately-pop: + - match: '' + pop: true - - match: /\*\*(?!/) - scope: punctuation.definition.comment.begin.js - push: - - meta_include_prototype: false - - meta_scope: comment.block.documentation.js - - match: \*/ - scope: punctuation.definition.comment.end.js + constructor-body-expect-class-begin: + - match: (?={{identifier}}\s*\() + set: + - include: support + - match: '{{dollar_only_identifier}}' + scope: variable.type.dollar.only.js punctuation.dollar.js pop: true - - match: ^\s*(\*)(?!/) + - match: '{{dollar_identifier}}' + scope: variable.type.dollar.js captures: - 1: punctuation.definition.comment.js - - match: /\* - scope: punctuation.definition.comment.begin.js - push: - - meta_include_prototype: false - - meta_scope: comment.block.js - - match: \*/ - scope: punctuation.definition.comment.end.js + 1: punctuation.dollar.js pop: true - - match: // - scope: punctuation.definition.comment.js - push: - - meta_include_prototype: false - - meta_scope: comment.line.double-slash.js - - match: \n + - match: '{{identifier}}' + scope: variable.type.js pop: true + - include: else-pop - 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: - - - match: '{{identifier_part}}+' - scope: invalid.illegal.js - - include: immediately-pop - - literal-number - - match: (?=['"]) - set: literal-string - - else-pop: - - match: (?=\S) - pop: true - - call-path: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: object-property - - include: else-pop + - include: expression-begin - call-method-meta: + function-declaration-meta: - meta_include_prototype: false - - meta_scope: meta.function-call.method.js - - include: else-pop - - function-parameter-binding-pattern: - - 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 + - meta_scope: meta.function.declaration.js + - clear_scopes: 1 + - include: immediately-pop - for-oldstyle-rest: - - match: (?=\)) + export-brace: + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js pop: true - - match: ; - scope: punctuation.separator.expression.js - - match: (?=\S) - push: expression - - export-item: - - match: \{ - scope: punctuation.section.block.begin.js - set: export-brace - - match: '{{non_reserved_identifier}}' + - match: '{{identifier}}' scope: variable.other.readwrite.js - pop: true + push: import-export-alias - match: \* scope: constant.other.js - pop: true + push: import-export-alias - include: else-pop - postfix-operators: - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - object-literal: - - match: \{ - scope: punctuation.section.block.begin.js - set: object-literal-contents + while-meta: + - meta_include_prototype: false + - meta_scope: meta.while.js + - include: immediately-pop - variable-binding-list: - - include: comma-separator - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer + 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 - - include: else-pop - support-variable-ecma: - - match: Array{{identifier_break}} - scope: support.class.builtin.js + - match: (?=\S) set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-array - - include: object-property - - include: else-pop - - include: else-pop + - - include: for-of-rest + - match: (?=\S) + set: for-oldstyle-rest + - expression-end-no-in + - expression-begin - - match: ArrayBuffer{{identifier_break}} - scope: support.class.builtin.js + constructor: + - match: new{{identifier_break}} + scope: keyword.operator.word.new.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js + - match: (?=\s*\.) + set: new-target + - match: (?=\s*\S) set: - - include: support-property-ecma-arraybuffer - - include: object-property - - include: else-pop - - include: else-pop + - constructor-meta + - constructor-body-expect-arguments + - constructor-body-expect-class-end + - constructor-body-expect-class-begin - - match: Atomics{{identifier_break}} - scope: support.constant.builtin.js + variable-binding-pattern: + - match: '' set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-atomics - - include: object-property + - - include: flow-type-annotation + - - include: variable-binding-name + - include: variable-binding-array-destructuring + - include: variable-binding-object-destructuring - include: else-pop - - include: else-pop - - match: BigInt{{identifier_break}} - scope: support.class.builtin.js + ternary-operator: + - match: \? + scope: keyword.operator.ternary.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-bigint - - include: object-property - - include: else-pop - - include: else-pop + - ternary-operator-expect-colon + - expression-no-comma - - match: Date{{identifier_break}} - scope: support.class.builtin.js + import-export-alias: + - match: as{{identifier_break}} + scope: keyword.control.import-export.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-date - - include: object-property - - include: else-pop + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + pop: true + - match: '{{identifier}}' + scope: variable.other.readwrite.js + pop: true - include: else-pop + - include: else-pop - - 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 + fallthrough: + # If an arrow function has the ( and ) on different lines, we won't have matched + - match: => + scope: storage.type.function.arrow.js + push: + - function-meta + - arrow-function-expect-body - - 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 + function-name-meta: + - meta_include_prototype: false + - meta_scope: entity.name.function.js + - include: immediately-pop - - match: Number{{identifier_break}} - scope: support.class.builtin.js + field-name: + - match: '{{dollar_identifier}}' + scope: meta.mapping.key.dollar.js variable.other.readwrite.js + captures: + 1: punctuation.dollar.js + pop: true + - match: '{{identifier}}' + scope: variable.other.readwrite.js + pop: true + - match: "'" + scope: punctuation.definition.string.begin.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-number - - include: object-property - - include: else-pop - - include: else-pop - - - match: Object{{identifier_break}} - scope: support.class.builtin.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - meta_content_scope: variable.other.readwrite.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: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-object - - include: object-property - - include: else-pop - - include: else-pop + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - meta_content_scope: variable.other.readwrite.js + - match: \" + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + - match: (#)({{identifier}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js - - 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 + - match: (?=\[) + push: computed-property-name - - 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 + - include: else-pop - - 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 + support-property-ecma-promise: + - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} + scope: support.function.builtin.js + pop: true - - 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 + 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 - - match: Symbol{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-symbol - - include: object-property - - 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}}' + scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js - - 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 - - # 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 - - - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} - scope: support.function.js - pop: true - - 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 - - comma-separator: - - match: ',' - scope: punctuation.separator.comma.js - - jsx-meta: - - meta_scope: meta.jsx.js + class-meta: + - meta_include_prototype: false + - meta_scope: meta.class.js - include: immediately-pop - arrow-function-expect-parameters: - - match: '{{identifier}}' - scope: variable.parameter.function.js + support-property-ecma-array: + - match: (?:from|isArray|of){{identifier_break}} + scope: support.function.builtin.js pop: true - - include: function-declaration-parameters - - include: else-pop - - variable-declaration: - - match: (?:const|let|var){{identifier_break}} - scope: storage.type.js - set: - - expect-semicolon - - variable-binding-list-top - - variable-binding-top - statements: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js + support-property-ecma-json: + - match: (?:parse|stringify){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: (?=\S) - push: statement - - 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}}|\[|'|") - push: - - initializer - - variable-binding-object-alias - - object-literal-meta-key - - variable-binding-object-key - - include: comma-separator - expression-statement: - match: (?=\S) set: @@ -1202,26 +1180,12 @@ contexts: - expression-statement-end - expression-begin - support-property-ecma-date: - - match: (?:now|parse|UTC){{identifier_break}} - scope: support.function.builtin.js - pop: true - - variable-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.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 + expression-end: + - include: postfix-operators + - include: binary-operators + - include: ternary-operator - import-meta-expression: - - match: import{{identifier_break}} - scope: keyword.import.js - set: import-expression-end + - include: left-expression-end class: - match: class{{identifier_break}} @@ -1232,730 +1196,636 @@ contexts: - class-extends - class-name - expression-end-no-in: - - match: (?=in{{identifier_break}}) + prototype: + - include: comments + + jsx-meta: + - meta_scope: meta.jsx.js + - include: immediately-pop + + expect-dot-accessor: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js pop: true - - include: expression-end + - include: else-pop - switch-block: + object-literal: - match: \{ scope: punctuation.section.block.begin.js - set: switch-block-contents - - include: else-pop - - decorator: - - match: '@' - scope: punctuation.definition.annotation.js - push: - - decorator-meta - - decorator-expression-end - - decorator-expression-begin + set: object-literal-contents - call-method-name: - - include: support-property - - match: '{{identifier}}' - scope: variable.function.js - pop: true - - include: else-pop + function-meta: + - meta_include_prototype: false + - meta_scope: meta.function.js + - include: immediately-pop - statement: - - include: flow-type-declare - - include: flow-type-alias + regexp-complete: + - match: / + scope: punctuation.definition.string.begin.js + set: regexp - - match: \; - scope: punctuation.terminator.statement.empty.js + expression-end-no-comma: + - match: (?=,) pop: true + - include: expression-end - - include: import-export - - include: conditional - - include: block - - include: label - - include: variable-declaration + jsx-interpolation: + - match: '{' + scope: punctuation.definition.interpolation.begin.js + push: + - - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.jsx + - match: '}' + scope: punctuation.definition.interpolation.end.js + pop: true + - expression - - match: break{{identifier_break}} - scope: keyword.control.flow.break.js - set: - - expect-semicolon - - expect-label + expression-no-comma: + - meta_include_prototype: false + - match: '' + set: [expression-end-no-comma, expression-begin] - - match: continue{{identifier_break}} - scope: keyword.control.flow.continue.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}}' + scope: entity.name.function.js + pop: true + - match: "'" + scope: punctuation.definition.string.begin.js set: - - expect-semicolon - - expect-label - - - match: debugger{{identifier_break}} - scope: keyword.control.flow.debugger.js - set: expect-semicolon + - 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 - - match: return{{identifier_break}} - scope: keyword.control.flow.return.js - set: restricted-production + - match: (?=\[) + push: computed-property-name - - match: throw{{identifier_break}} - scope: keyword.control.flow.throw.js - set: restricted-production + - include: else-pop - - include: function-or-class-declaration + with-meta: + - meta_include_prototype: false + - meta_scope: meta.with.js + - include: immediately-pop - - include: decorator + flow-type-module-meta: + - meta_scope: meta.module.js + - include: immediately-pop - - include: expression-statement + conditional-meta: + - meta_include_prototype: false + - meta_scope: meta.conditional.js + - include: immediately-pop - export-brace: - - meta_scope: meta.block.js - - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js - pop: true - - match: '{{identifier}}' - scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias - - include: else-pop + 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.logical.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: |- + (?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) + <= | # relational left-to-right both + >= | # relational left-to-right both + < | # relational left-to-right both + > # relational left-to-right both + scope: keyword.operator.relational.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 - for-of-rest: - - match: (?:of|in){{identifier_break}} - scope: keyword.operator.word.js - set: expression + 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: storage.type.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 - function-initializer: - - meta_scope: meta.function.declaration.js - - match: '=' - scope: keyword.operator.assignment.js - set: - - meta_content_scope: meta.function.declaration.js - - include: expression-no-comma + - match: \[\] + scope: storage.modifier.array.js + - match: '%checks{{identifier_break}}' + scope: storage.modifier.checks.js + do-while-condition: + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: parenthesized-expression - include: else-pop - import-item: - - include: flow-type-import-type + decorator-name: + - match: '{{identifier}}{{left_expression_end_lookahead}}' + scope: variable.annotation.js + pop: true + variable-binding-object-destructuring: - 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: else-pop - - inherited-class-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: inherited-class-name - - include: object-property + set: + - meta_scope: meta.binding.destructuring.mapping.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: variable-binding-spread + - match: (?={{identifier}}|\[|'|") + push: + - initializer + - variable-binding-object-alias + - object-literal-meta-key + - variable-binding-object-key + - include: comma-separator - - include: left-expression-end + await-expression: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js - function-declaration-expect-async: - - match: async{{identifier_break}} - scope: storage.type.js + 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 - bare-property-name: - - match: '{{identifier}}' - scope: string.unquoted.js + for-await: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js pop: true - either-function-declaration: - - match: (?={{func_lookahead}}) - set: function-declaration - - match: (?={{arrow_func_lookahead}}) - set: arrow-function-declaration - - flow-type-alias: - - match: (?=type{{identifier_break}}) - set: - - - match: (?={{identifier}}) - set: - - - meta_scope: meta.declaration.type.js - - match: '' - pop: true - - flow-type-alias-initializer - - flow-type-generic-parameters - - - match: '{{identifier}}' - scope: entity.name.type.js - pop: true - - - include: else-pop - - - match: (?=\S) - set: [expression-statement, expression-end] - - - match: type{{identifier_break}}(?=\s*(?:$|{{identifier}})) - scope: storage.type.js - set: - - meta_scope: meta.declaration.type.js - - include: else-pop - - include: expression-begin + - include: else-pop - flow-type-annotation: - - match: ':' - scope: punctuation.separator.type.js - set: - - flow-type-meta - - flow-type - - match: (?!\s*(?:$|:|//|/\*)) - pop: true + postfix-operators: + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js - function-declaration-identifiers-expect-class: - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js - pop: true - - include: language-identifiers - - match: '{{dollar_only_identifier}}' - scope: support.class.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: support.class.dollar.js + flow-type-object-indexer-label: + - match: ({{identifier}})\s*(:) captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier}}' - scope: support.class.js + 1: meta.object-literal.key.js + 2: punctuation.separator.key-value.js pop: true - include: else-pop - object-literal-contents: - - meta_scope: meta.mapping.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true - - - match: \.\.\. - scope: keyword.operator.spread.js - push: expression-no-comma - - - match: >- - (?x)(?= - {{property_name}}\s*: - (?: {{either_func_lookahead}} ) - ) - push: - - either-function-declaration - - function-declaration-meta-no-clear - - object-literal-expect-colon - - object-literal-meta-key - - method-name - - - match: '{{method_lookahead}}' - push: method-declaration - - - match: '{{identifier}}(?=\s*(?:[},]|$|//|/\*))' - scope: variable.other.readwrite.js - - - match: (?=\[) - push: - - object-literal-meta-key - - computed-property-name - - - match: (?=\"|') - push: - - object-literal-meta-key - - literal-string - - - match: (?=[-+]?(?:\.[0-9]|0[bxo]|\d)) - push: - - object-literal-meta-key - - literal-number - - # - include: bare-property-name - - match: (?={{identifier}}) - push: - - object-literal-meta-key - - bare-property-name - - - include: comma-separator - - match: ':' - scope: punctuation.separator.key-value.js - push: expression-no-comma - - # In case we're inside a destructured arrow function parameter that we - # misidentified as an object literal. - - match: '=' - scope: keyword.operator.assignment.js - push: expression-no-comma - - field-initializer-or-method-declaration: - - match: (?=\() - set: - - function-meta - - function-declaration-expect-body - - function-declaration-meta - - function-declaration-expect-parameters - - match: (?=\S) - set: - - class-field-rest - - initializer - - catch-meta: - - meta_include_prototype: false - - meta_scope: meta.catch.js - - include: immediately-pop - - flow-type-import-type: - - match: type{{identifier_break}} - scope: storage.type.js - - - match: typeof{{identifier_break}} - scope: keyword.operator.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 - - constants: - - 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 - support-property-ecma-typedarray: - match: (?:BYTES_PER_ELEMENT){{identifier_break}} scope: support.constant.builtin.js pop: true - literal-variable: - - include: language-identifiers - - include: support - - - match: '{{constant_identifier}}(?=\s*[\[.])' - scope: support.class.js - pop: true - - - match: (?={{identifier}}\s*(?:\.\?)?\() - set: call-function-name - - - include: literal-variable-base - - 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 - - block-scope - - - match: for{{identifier_break}} - scope: keyword.control.loop.for.js - set: - - for-meta - - block-scope - - for-condition - - for-await - - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: - - while-meta - - block-scope - - expect-parenthesized-expression - - - match: with{{identifier_break}} - scope: keyword.control.import.with.js - set: - - with-meta - - block-scope - - expect-parenthesized-expression - - - match: if{{identifier_break}} - scope: keyword.control.conditional.if.js - set: - - conditional-meta - - block-scope - - expect-parenthesized-expression - - - match: else\s+if{{identifier_break}} - scope: keyword.control.conditional.elseif.js - set: - - conditional-meta - - block-scope - - expect-parenthesized-expression - - - match: else{{identifier_break}} - scope: keyword.control.conditional.else.js - set: - - conditional-meta - - block-scope - - - match: try{{identifier_break}} - scope: keyword.control.exception.try.js - set: - - try-meta - - block-scope - - - match: finally{{identifier_break}} - scope: keyword.control.exception.finally.js - set: - - finally-meta - - block-scope - - - match: catch{{identifier_break}} - scope: keyword.control.exception.catch.js - set: - - catch-meta - - block-scope - - expect-parenthesized-expression + constructor-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.constructor.js + - include: immediately-pop - regexp-complete: - - match: / - scope: punctuation.definition.string.begin.js - set: regexp + for-of-rest: + - match: (?:of|in){{identifier_break}} + scope: keyword.operator.word.js + set: expression - flow-type-module-body: + export-item: - match: \{ scope: punctuation.section.block.begin.js - set: flow-type-module-contents + set: export-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: true + - match: \* + scope: constant.other.js + pop: true - include: else-pop - flow-type-class: - - match: '{{identifier}}' - scope: variable.other.class.js - pop: true + function-parameter-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: function-parameter-binding-list - support-property: - - include: support-property-ecma + constructor-body-expect-class-end: + - include: property-access + - include: else-pop - flow-type-object-indexer-label: - - match: ({{identifier}})\s*(:) - captures: - 1: meta.object-literal.key.js - 2: punctuation.separator.key-value.js - pop: true + import-list: + - match: ',' + scope: punctuation.separator.comma.js + push: + - import-export-alias + - import-item - include: else-pop - function-parameter-binding-object-key: - - match: '{{identifier}}(?=\s*:)' + flow-type-module-contents: + - match: \} + scope: punctuation.section.block.end.js pop: true - - include: literal-string - - include: computed-property-name - - include: function-parameter-binding-name - - include: else-pop + - include: main - constructor: - - match: new{{identifier_break}} - scope: keyword.operator.word.new.js + block: + - match: \{ + scope: punctuation.section.block.begin.js set: - - match: (?=\s*\.) - set: new-target - - match: (?=\s*\S) - set: - - constructor-meta - - constructor-body-expect-arguments - - constructor-body-expect-class-end - - constructor-body-expect-class-begin + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements - jsx-tag-attributes-top: - - meta_scope: meta.tag.js - - match: / - scope: punctuation.definition.tag.begin.js + for-condition: + - match: \( + scope: punctuation.section.group.js set: - - - meta_scope: invalid.illegal.unmatched-tag.js - - include: immediately-pop - - jsx-expect-tag-end - - jsx-tag-name + - for-condition-end + - for-condition-contents + - include: else-pop - - match: (?=\S) - set: - - jsx-tag-attributes - - jsx-tag-name + either-function-declaration: + - match: (?={{func_lookahead}}) + set: function-declaration + - match: (?={{arrow_func_lookahead}}) + set: arrow-function-declaration - support-property-ecma: - - match: constructor{{identifier_break}} - scope: variable.language.constructor.js + language-identifiers: + - match: arguments{{identifier_break}} + scope: variable.language.arguments.js pop: true - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js + - match: super{{identifier_break}} + scope: variable.language.super.js pop: true - - - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} - scope: support.function.js + - match: this{{identifier_break}} + scope: variable.language.this.js + pop: true + - match: globalThis{{identifier_break}} + scope: variable.language.global.js pop: true - # Annex B - - match: __proto__{{identifier_break}} - scope: invalid.deprecated.js variable.language.prototype.js + # These three are ordinary variables, not literals! + - match: undefined{{identifier_break}} + scope: constant.language.undefined.js pop: true - - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} - scope: invalid.deprecated.js support.function.js + - match: NaN{{identifier_break}} + scope: constant.language.nan.js + pop: true + - match: Infinity{{identifier_break}} + scope: constant.language.infinity.js pop: true - call-function-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.js - - include: else-pop + class-body-contents: + - meta_scope: meta.block.js - import-export: - - match: import{{identifier_break}}(?!{{nothing}}[.(]) - scope: keyword.control.import-export.js - set: - - meta_scope: meta.import.js - - match: (?=[.(]) # Recovery for import expressions - set: - - expression-statement-end - - import-expression-end - - match: (?=\S) - set: - - import-meta - - expect-semicolon - - import-string-or-items + - match: \} + scope: punctuation.section.block.end.js + pop: true - - match: export{{identifier_break}} - scope: keyword.control.import-export.js - set: - - export-meta - - export-extended + - match: \; + scope: punctuation.terminator.statement.js - class-field-rest: - - match: ',' - scope: punctuation.separator.js + - include: decorator + + - match: constructor{{identifier_break}} + scope: entity.name.function.constructor.js push: - - initializer - - field-name - - include: else-pop + - function-meta + - function-declaration-expect-body + - function-declaration-meta + - function-declaration-expect-parameters - flow-type-list: - - include: comma-separator - - match: (?=\S) - push: flow-type + - match: static{{identifier_break}} + scope: storage.modifier.js + push: class-field - ternary-operator: - - match: \? - scope: keyword.operator.ternary.js + - match: (?={{class_element_name}}) + push: class-field + + arrow-function-expect-body: + - include: function-block + - match: (?=\S) set: - - ternary-operator-expect-colon + - block-meta - expression-no-comma - 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 - - expression-end: - - include: postfix-operators - - include: binary-operators - - include: ternary-operator - - - include: left-expression-end - - block-scope: - - include: block + import-expression-end: + - match: (?=\() + set: function-call-arguments + - match: \. + scope: punctuation.accessor.js + set: + - match: meta{{identifier_break}} + scope: variable.language.import.js + pop: true + - include: object-property + - include: else-pop + flow-type-module-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: flow-type-module-contents - include: else-pop - tagged-template: - - match: '{{identifier}}(?=\s*`)' - scope: variable.function.tagged-template.js + flow-type-module-name: + - include: literal-string + - match: '{{identifier}}' + scope: entity.name.module.js pop: true + - include: else-pop - flow-type-object: - - match: \{\| - scope: punctuation.section.block.begin.js + support-variable-ecma: + - match: Array{{identifier_break}} + scope: support.class.builtin.js set: - - meta_scope: meta.type.object.exact.js - - match: \|\} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-array + - include: object-property + - include: else-pop + - include: else-pop - - match: \{ - scope: punctuation.section.block.begin.js + - match: ArrayBuffer{{identifier_break}} + scope: support.class.builtin.js set: - - meta_scope: meta.type.object.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-arraybuffer + - include: object-property + - include: else-pop + - include: else-pop - jsx-body: - - meta_include_prototype: false + - 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: < - scope: punctuation.definition.tag.begin.js + - match: BigInt{{identifier_break}} + scope: support.class.builtin.js set: - - meta_scope: meta.tag.js - - - match: / - scope: punctuation.definition.tag.begin.js + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - jsx-expect-tag-end - - jsx-tag-name + - include: support-property-ecma-bigint + - include: object-property + - include: else-pop + - include: else-pop - - match: (?=\S) + - match: Date{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - jsx-body - - jsx-tag-attributes - - jsx-tag-name + - include: support-property-ecma-date + - include: object-property + - include: else-pop + - include: else-pop - - include: jsx-html-escapes - - include: jsx-interpolation - new-target: - - match: \. - scope: punctuation.accessor.dot.js + - match: JSON{{identifier_break}} + scope: support.constant.builtin.js set: - - match: target{{identifier_break}} - scope: variable.language.target.js - pop: true + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-json + - include: object-property + - include: else-pop - include: else-pop - - include: else-pop - - import-export-alias: - - match: as{{identifier_break}} - scope: keyword.control.import-export.js + - match: Math{{identifier_break}} + scope: support.constant.builtin.js set: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - pop: true - - match: '{{identifier}}' - scope: variable.other.readwrite.js - pop: true + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-math + - include: object-property + - include: else-pop - include: else-pop - - include: else-pop - - block-meta: - - meta_include_prototype: false - - meta_scope: meta.block.js - - include: immediately-pop - - conditional-meta: - - meta_include_prototype: false - - meta_scope: meta.conditional.js - - include: immediately-pop - - expect-dot-accessor: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - pop: true - - include: else-pop - - import-export-from: - - match: from{{identifier_break}} - scope: keyword.control.import-export.js - set: literal-string - - include: else-pop - constructor-body-expect-class-begin: - - match: (?={{identifier}}\s*\() + - match: Number{{identifier_break}} + scope: support.class.builtin.js 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}}' - scope: variable.type.js - pop: true + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-number + - include: object-property + - include: else-pop - include: else-pop - - include: expression-begin + - 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 - property-access: - - match: (\.\?)?(\[) - 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 + - 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 - - match: \.(?:\?)? - scope: punctuation.accessor.js - push: - - match: (?={{identifier}}\s*(?:\.\?)?\() + - match: Proxy{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - call-method-meta - - function-call-arguments - - call-path - - object-property - - include: object-property + - include: support-property-ecma-proxy + - include: object-property + - include: else-pop + - include: else-pop - jsx-tag: - - match: < - scope: punctuation.definition.tag.begin.js + - match: Reflect{{identifier_break}} + scope: support.constant.builtin.js set: - - jsx-meta - - jsx-tag-attributes-top + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-reflect + - include: object-property + - include: else-pop + - include: else-pop - support: - - include: support-variable-ecma - - include: support-variable-console - - include: support-variable-dom - - include: support-variable-node + - 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 - for-condition: - - match: \( - scope: punctuation.section.group.js + - match: Symbol{{identifier_break}} + scope: support.class.builtin.js set: - - for-condition-end - - for-condition-contents - - include: else-pop + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-symbol + - include: object-property + - include: else-pop + - include: else-pop - regexp: - - meta_include_prototype: false - - meta_scope: meta.string.js string.regexp.js - - match: / - scope: punctuation.definition.string.end.js + - 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: - - 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 + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-typedarray + - include: object-property + - include: else-pop + - include: else-pop - flow-type-export-type: - - match: type{{identifier_break}}(?=\s*\{) - scope: storage.type.js - set: export-item - - include: flow-type-alias + # 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 + + - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + scope: support.function.js + pop: true + + 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 - restricted-production: - - meta_include_prototype: false - - match: '{{line_ending_ahead}}' + 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 - - match: '' - set: expression-statement - class-extends: - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js + flow-type-tuple: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - flow-type-generic-arguments - - inherited-class-expression-end - - inherited-class-expression-begin + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: flow-type-list + + block-scope: + - include: block - include: else-pop parenthesized-expression: @@ -1971,503 +1841,469 @@ contexts: - match: (?=\S) push: expression - method-declaration: - - match: '' + object-property: + - match: |- + (?x)(?= + {{identifier}} + \s* = \s* + {{either_func_lookahead}} + ) set: - - function-meta - - function-declaration-expect-body - - function-declaration-meta - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - method-name - - method-declaration-expect-prefix - - function-declaration-expect-async - - class-body-contents: - - meta_scope: meta.block.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true - - - 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-meta - - function-declaration-expect-parameters + - function-initializer + - function-name-meta + - object-property-base - - match: static{{identifier_break}} - scope: storage.modifier.js - push: class-field + - include: support-property - - match: (?={{class_element_name}}) - push: class-field + - match: (?={{identifier}}\s*(?:\.\?)?\() + set: call-method-name - flow-type-end: - - include: flow-type-operators - - match: (?=<) - push: flow-type-generic-arguments + - include: object-property-base - include: else-pop - arrow-function-declaration: - - meta_include_prototype: false - - match: '' - set: - - function-meta - - arrow-function-expect-body - - function-declaration-meta - - arrow-function-expect-arrow - - arrow-function-expect-parameters - - function-declaration-expect-async - - flow-type-special: - - match: any{{identifier_break}} - scope: support.type.any.js + flow-type-declare-export: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + set: flow-type + - match: (?=\S) pop: true - - match: mixed{{identifier_break}} - scope: support.type.mixed.js - pop: true + call-method-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.method.js + - include: else-pop - flow-type-tuple: - - match: \[ - scope: punctuation.section.brackets.begin.js + flow-type-declare: + - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) + scope: storage.type.js set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list - - 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 + - match: opaque{{identifier_break}} + scope: storage.modifier.js pop: true + - match: module{{identifier_break}} + scope: storage.type.js + set: + - flow-type-module-meta + - flow-type-module-body + - flow-type-module-name + - match: export{{identifier_break}} + scope: storage.type.js + set: flow-type-declare-export - include: else-pop - jsx-tag-name: - - match: '' + new-target: + - match: \. + scope: punctuation.accessor.dot.js set: - - - clear_scopes: 1 - - meta_scope: meta.tag.name.js - - include: immediately-pop - - jsx-tag-name-component - - immediately-pop: - - match: '' - 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.logical.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: |- - (?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) - <= | # relational left-to-right both - >= | # relational left-to-right both - < | # relational left-to-right both - > # relational left-to-right both - scope: keyword.operator.relational.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 - - jsx-html-escapes: - - match: (&)#?[[:alnum:]]+(;) - scope: constant.character.escape.js - captures: - 1: punctuation.definition.entity.js - 2: punctuation.definition.entity.js + - match: target{{identifier_break}} + scope: variable.language.target.js + pop: true + - include: else-pop - jsx-interpolation: - - match: '{' - scope: punctuation.definition.interpolation.begin.js - push: - - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded.jsx - - match: '}' - scope: punctuation.definition.interpolation.end.js - pop: true - - expression + - include: else-pop - support-variable-console: - # https://console.spec.whatwg.org/ - - match: console{{identifier_break}} - scope: support.type.object.console.js + 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: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: builtin-console-properties - - include: else-pop + - 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 - flow-type-alias-initializer: - - match: '=' - scope: keyword.operator.assignment.js + variable-binding-top: + - include: function-assignment + - match: (?={{binding_pattern_lookahead}}) set: - - flow-type-meta - - flow-type + - initializer + - variable-binding-pattern - include: else-pop - flow-type-primitive: - - match: boolean{{identifier_break}} - scope: support.type.primitive.boolean.js + + computed-property-name: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - match: (?=\S) + push: expression + + for-condition-end: + - meta_scope: meta.group.js + + - match: \) + scope: punctuation.section.group.js pop: true - - match: number{{identifier_break}} - scope: support.type.primitive.number.js + function-declaration-expect-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.function.js pop: true + - include: else-pop - - match: string{{identifier_break}} - scope: support.type.primitive.string.js + support-property-ecma-arraybuffer: + - match: isView{{identifier_break}} + scope: support.function.builtin.js pop: true - - match: null{{identifier_break}} - scope: support.type.primitive.null.js + function-parameter-binding-object-key: + - match: '{{identifier}}(?=\s*:)' pop: true + - include: literal-string + - include: computed-property-name + - include: function-parameter-binding-name + - include: else-pop - - match: void{{identifier_break}} - scope: support.type.primitive.void.js + constants: + - 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 - flow-type-module-meta: - - meta_scope: meta.module.js - - include: immediately-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 + - include: expression-list - flow-type-annotation-optional: - - match: \?(?=:) - scope: storage.modifier.optional.js - - include: flow-type-annotation + switch-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: switch-block-contents + - include: else-pop - decorator-name: - - match: '{{identifier}}{{left_expression_end_lookahead}}' - scope: variable.annotation.js + literal-variable: + - include: language-identifiers + - include: support + + - match: '{{constant_identifier}}(?=\s*[\[.])' + scope: support.class.js pop: true - function-parameter-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: function-parameter-binding-pattern + - match: (?={{identifier}}\s*(?:\.\?)?\() + set: call-function-name - object-literal-meta-key: - - meta_scope: meta.mapping.key.js - - include: else-pop + - include: literal-variable-base - 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 + support-variable-node: + - match: global{{identifier_break}} + scope: support.type.object.node.js pop: true - - match: '{{identifier}}' - scope: meta.property.object.js + + - match: Buffer{{identifier_break}} + scope: support.class.node.js pop: true - - match: '{{identifier_part}}+{{identifier_break}}' - scope: invalid.illegal.illegal-identifier.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: (#)({{identifier}}) - captures: - 1: punctuation.definition.variable.js - 2: meta.property.object.js + - 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 - inherited-class-expression-begin: - - include: inherited-class-name - - include: expression-begin - - function-meta: - - meta_include_prototype: false - - meta_scope: meta.function.js - - include: immediately-pop + 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 - main: - - include: comments-top-level + - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} + scope: support.function.js + pop: true - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - # Don't pop or embedding could break. + # 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 - - include: statements + statement: + - include: flow-type-declare + - include: flow-type-alias - function-declaration-expect-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.function.js + - match: \; + scope: punctuation.terminator.statement.empty.js pop: true - - include: else-pop - export-meta: - - meta_include_prototype: false - - meta_scope: meta.export.js - - include: immediately-pop + - include: import-export + - include: conditional + - include: block + - include: label + - include: variable-declaration - function-block: - - match: \{ - scope: punctuation.section.block.begin.js + - match: break{{identifier_break}} + scope: keyword.control.flow.break.js set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements - - flow-type-meta: - - meta_scope: meta.flow-type.js - - include: immediately-pop - - do-while-meta: - - meta_include_prototype: false - - meta_scope: meta.do-while.js - - include: immediately-pop + - expect-semicolon + - expect-label - support-property-ecma-array: - - match: (?:from|isArray|of){{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: continue{{identifier_break}} + scope: keyword.control.flow.continue.js + set: + - expect-semicolon + - expect-label - expression-begin: - - include: jsx-tag + - match: debugger{{identifier_break}} + scope: keyword.control.flow.debugger.js + set: expect-semicolon - - include: expression-break + - match: return{{identifier_break}} + scope: keyword.control.flow.return.js + set: restricted-production - - include: yield-expression - - include: await-expression + - match: throw{{identifier_break}} + scope: keyword.control.flow.throw.js + set: restricted-production - - 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 + - include: function-or-class-declaration - - include: class - - include: constants - - include: function-assignment - - include: either-function-declaration - - include: object-literal + - include: decorator - - include: parenthesized-expression - - include: array-literal + - include: expression-statement - - include: literal-call - - include: literal-variable + function-parameter-binding-object-destructuring: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - 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}}|\[|'|") + push: + - initializer + - function-parameter-binding-object-alias + - object-literal-meta-key + - function-parameter-binding-object-key - - include: else-pop + for-oldstyle-rest: + - match: (?=\)) + pop: true + - match: ; + scope: punctuation.separator.expression.js + - match: (?=\S) + push: expression - export-list: + comma-separator: - match: ',' scope: punctuation.separator.comma.js - push: - - import-export-alias - - export-item - - include: else-pop - - export-extended: - - include: flow-type-export-type - - - include: variable-declaration - - include: function-or-class-declaration - - match: default{{identifier_break}} - scope: keyword.control.import-export.js + bare-property-name: + - match: '{{identifier}}' + scope: string.unquoted.js + pop: true + arrow-function-declaration: + - meta_include_prototype: false + - match: '' set: - - include: function-or-class-declaration - - match: (?=\S) - set: expression-statement + - function-meta + - arrow-function-expect-body + - function-declaration-meta + - arrow-function-expect-arrow + - arrow-function-expect-parameters + - function-declaration-expect-async - - match: (?=\S) - set: - - expect-semicolon - - import-export-from - - export-list - - import-export-alias - - export-item + decorator: + - match: '@' + scope: punctuation.definition.annotation.js + push: + - decorator-meta + - decorator-expression-end + - decorator-expression-begin - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js + support-property-ecma-proxy: + - match: revocable{{identifier_break}} + scope: support.function.builtin.js pop: true - - include: else-pop - import-string-or-items: - - include: literal-string - - match: (?=\S) - set: - - import-export-from - - import-list - - import-export-alias - - import-item + function-declaration-expect-parameters: + - include: function-declaration-parameters + - include: else-pop - function-assignment: - - match: |- - (?x)(?= - (?:{{identifier}} \s* \. \s*)* - {{identifier}} - \s* = \s* - {{either_func_lookahead}} - ) + flow-type: + - match: '' set: - - function-initializer - - function-declaration-identifiers + - flow-type-end + - flow-type-begin - 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 + switch-meta: + - meta_include_prototype: false + - meta_scope: meta.switch.js + - include: immediately-pop - class-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.class.js - set: flow-type-generic-parameters - - include: else-pop + flow-type-special: + - match: any{{identifier_break}} + scope: support.type.any.js + pop: true - expression-break: - - match: (?=[;})\]]) + - match: mixed{{identifier_break}} + scope: support.type.mixed.js pop: true - variable-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: variable-binding-pattern + restricted-production: + - meta_include_prototype: false + - match: '{{line_ending_ahead}}' + pop: true + - match: '' + set: expression-statement - for-condition-end: - - meta_scope: meta.group.js + import-export: + - match: import{{identifier_break}}(?!{{nothing}}[.(]) + scope: keyword.control.import-export.js + set: + - meta_scope: meta.import.js + - match: (?=[.(]) # Recovery for import expressions + set: + - expression-statement-end + - import-expression-end + - match: (?=\S) + set: + - import-meta + - expect-semicolon + - import-string-or-items - - match: \) - scope: punctuation.section.group.js - pop: true + - match: export{{identifier_break}} + scope: keyword.control.import-export.js + set: + - export-meta + - export-extended - constructor-body-expect-arguments: - - include: function-call-arguments - - include: else-pop + variable-binding-name: + - match: (?={{non_reserved_identifier}}) + set: + - meta_scope: meta.binding.name.js + - include: literal-variable flow-type-existential: - match: \* scope: constant.language.type.existential.js pop: true - while-meta: - - meta_include_prototype: false - - meta_scope: meta.while.js - - include: immediately-pop + decorator-expression-begin: + - include: decorator-name + - include: expression-begin - flow-type: - - match: '' + 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: - - flow-type-end - - flow-type-begin + - - meta_scope: invalid.illegal.unmatched-tag.js + - include: immediately-pop + - jsx-expect-tag-end + - jsx-tag-name - comments-top-level: - - match: ^(#!).*$\n? - scope: comment.line.shebang.js - captures: - 1: punctuation.definition.comment.js + - match: (?=\S) + set: + - jsx-tag-attributes + - jsx-tag-name + + 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 - switch-meta: - - meta_include_prototype: false - - meta_scope: meta.switch.js + flow-type-meta: + - meta_scope: meta.flow-type.js - include: immediately-pop - 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 + ternary-operator-expect-colon: + - match: ':' + scope: keyword.operator.ternary.js + set: expression-no-comma + - include: else-pop - for-await: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js + 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 - - include: else-pop - function-parameter-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: function-parameter-binding-pattern - - include: else-pop + variable-declaration: + - match: (?:const|let|var){{identifier_break}} + scope: storage.type.js + set: + - expect-semicolon + - variable-binding-list-top + - variable-binding-top expression-statement-end: - match: '{{line_ending_ahead}}' @@ -2477,106 +2313,241 @@ contexts: - include: else-pop - include: expression-end - function-or-class-declaration: - - match: (?=class{{identifier_break}}) - set: class + flow-type-object-value: + - match: (\?)?(:) + captures: + 1: storage.modifier.optional.js + 2: punctuation.separator.key-value.js + set: flow-type + - include: else-pop - - match: (?={{func_lookahead}}) - set: function-declaration + 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}}' + scope: meta.property.object.js + pop: true + - match: '{{identifier_part}}+{{identifier_break}}' + scope: invalid.illegal.illegal-identifier.js + pop: true + - match: (#)({{identifier}}) + captures: + 1: punctuation.definition.variable.js + 2: meta.property.object.js + pop: true - ternary-operator-expect-colon: + function-parameter-binding-object-alias: - match: ':' - scope: keyword.operator.ternary.js - set: expression-no-comma + scope: punctuation.separator.key-value.js + set: function-parameter-binding-pattern - include: else-pop - arrow-function-expect-body: - - include: function-block - - match: (?=\S) - set: - - block-meta - - expression-no-comma + label: + - match: ({{identifier}})\s*(:) + captures: + 1: entity.name.label.js + 2: punctuation.separator.js - jsx-tag-name-component: - - match: '{{jsx_identifier}}' - scope: entity.name.tag.js + regexp: + - meta_include_prototype: false + - meta_scope: meta.string.js string.regexp.js + - match: / + scope: punctuation.definition.string.end.js set: - - match: '[:.]' - scope: punctuation.accessor.js - set: jsx-tag-name - - include: else-pop - - include: else-pop + - 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 - inherited-class-name: - - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' - scope: entity.other.inherited-class.js - pop: true + object-literal-expect-colon: + - match: ':' + scope: punctuation.separator.key-value.js + - include: else-pop - object-property: - - match: |- - (?x)(?= - {{identifier}} - \s* = \s* - {{either_func_lookahead}} - ) + jsx-tag: + - match: < + scope: punctuation.definition.tag.begin.js set: - - function-initializer - - function-name-meta - - object-property-base - - - include: support-property + - jsx-meta + - jsx-tag-attributes-top - - match: (?={{identifier}}\s*(?:\.\?)?\() - set: call-method-name + do-while-meta: + - meta_include_prototype: false + - meta_scope: meta.do-while.js + - include: immediately-pop - - include: object-property-base + constructor-body-expect-arguments: + - include: function-call-arguments - include: else-pop - support-property-ecma-atomics: - - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} - scope: support.function.builtin.js + function-declaration-expect-async: + - match: async{{identifier_break}} + scope: storage.type.js pop: true + - include: else-pop - function-declaration-meta-no-clear: + block-meta: - meta_include_prototype: false - - meta_scope: meta.function.declaration.js + - meta_scope: meta.block.js - include: immediately-pop - switch-block-contents: - - meta_scope: meta.block.js + expect-parenthesized-expression: + - include: parenthesized-expression + - include: else-pop - - 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: case{{identifier_break}} - scope: keyword.control.conditional.case.js + expression-end-no-in: + - match: (?=in{{identifier_break}}) + pop: true + - include: expression-end + + 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 + + - 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 + + 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 + + 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 + + - include: else-pop + + export-list: + - match: ',' + scope: punctuation.separator.comma.js push: - - expect-case-colon - - expression + - import-export-alias + - export-item + - include: else-pop - - match: default{{identifier_break}} - scope: keyword.control.conditional.default.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 + + support-property-ecma-string: + - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} + scope: support.function.builtin.js + pop: true + + variable-binding-list: + - include: comma-separator + - match: (?={{binding_pattern_lookahead}}) push: - - expect-case-colon + - initializer + - variable-binding-pattern + - include: else-pop + + export-meta: + - meta_include_prototype: false + - meta_scope: meta.export.js + - include: immediately-pop - - include: statements + arrow-function-expect-arrow: + - match: => + scope: storage.type.function.arrow.js + pop: true + - include: else-pop - computed-property-name: - - match: \[ - scope: punctuation.section.brackets.begin.js + support-property-ecma-date: + - match: (?:now|parse|UTC){{identifier_break}} + scope: support.function.builtin.js + pop: true + + flow-type-generic-parameters: + - match: < + scope: punctuation.section.generic.begin.js set: - - match: \] - scope: punctuation.section.brackets.end.js + - meta_scope: meta.generic.declaration.js + - match: '>' + scope: punctuation.section.generic.end.js pop: true - - match: (?=\S) - push: expression + - include: comma-separator + - match: \+ + scope: storage.modifier.variance.js + - match: '{{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 - flow-type-module-contents: - - match: \} - scope: punctuation.section.block.end.js + arrow-function-expect-parameters: + - match: '{{identifier}}' + scope: variable.parameter.function.js pop: true - - include: main + - include: function-declaration-parameters + - include: else-pop + + function-parameter-binding-list: + - match: ',' + scope: punctuation.separator.parameter.function.js + - include: function-parameter-binding-spread + - match: (?={{binding_pattern_lookahead}}) + push: + - initializer + - function-parameter-binding-pattern + - include: else-pop left-expression-end: - include: expression-break @@ -2593,11 +2564,6 @@ contexts: - include: else-pop - expression: - - meta_include_prototype: false - - match: '' - set: [expression-end, expression-begin] - function-declaration-parameters: - match: \( scope: punctuation.section.group.begin.js @@ -2607,64 +2573,74 @@ contexts: pop: true - include: function-parameter-binding-list - 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 - + class-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.class.js + set: flow-type-generic-parameters - include: else-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 + import-export-from: + - match: from{{identifier_break}} + scope: keyword.control.import-export.js + set: literal-string + - include: else-pop - variable-binding-top: - - include: function-assignment - - match: (?={{binding_pattern_lookahead}}) - set: - - initializer - - variable-binding-pattern + function-declaration-expect-function-keyword: + - match: function{{identifier_break}} + scope: storage.type.function.js + pop: true - include: else-pop - support-property-ecma-json: - - match: (?:parse|stringify){{identifier_break}} - scope: support.function.builtin.js + expect-case-colon: + - match: ':' + scope: punctuation.separator.js pop: true + - include: else-pop - expression-end-no-comma: - - match: (?=,) + switch-block-contents: + - meta_scope: meta.block.js + + - match: \} + scope: punctuation.section.block.end.js pop: true - - include: expression-end - try-meta: - - meta_include_prototype: false - - meta_scope: meta.try.js - - include: immediately-pop + - match: case{{identifier_break}} + scope: keyword.control.conditional.case.js + push: + - expect-case-colon + - expression + + - match: default{{identifier_break}} + scope: keyword.control.conditional.default.js + push: + - expect-case-colon + + - include: statements + + field-initializer-or-method-declaration: + - match: (?=\() + set: + - function-meta + - function-declaration-expect-body + - function-declaration-meta + - function-declaration-expect-parameters + - match: (?=\S) + set: + - class-field-rest + - initializer + + method-declaration: + - match: '' + set: + - function-meta + - function-declaration-expect-body + - function-declaration-meta + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - method-name + - method-declaration-expect-prefix + - function-declaration-expect-async prefix-operators: - match: '~' @@ -2682,136 +2658,201 @@ contexts: - match: (?:delete|typeof|void){{identifier_break}} scope: keyword.operator.js - language-identifiers: - - match: arguments{{identifier_break}} - scope: variable.language.arguments.js + finally-meta: + - meta_include_prototype: false + - meta_scope: meta.finally.js + - include: immediately-pop + + try-meta: + - meta_include_prototype: false + - meta_scope: meta.try.js + - include: immediately-pop + + expression-break: + - match: (?=[;})\]]) pop: true - - match: super{{identifier_break}} - scope: variable.language.super.js + + flow-type-import-type: + - match: type{{identifier_break}} + scope: storage.type.js + + - match: typeof{{identifier_break}} + scope: keyword.operator.js + + function-declaration-meta-no-clear: + - meta_include_prototype: false + - meta_scope: meta.function.declaration.js + - include: immediately-pop + + flow-type-primitive: + - match: boolean{{identifier_break}} + scope: support.type.primitive.boolean.js pop: true - - match: this{{identifier_break}} - scope: variable.language.this.js + + - match: number{{identifier_break}} + scope: support.type.primitive.number.js pop: true - - match: globalThis{{identifier_break}} - scope: variable.language.global.js + + - match: string{{identifier_break}} + scope: support.type.primitive.string.js + pop: true + + - match: null{{identifier_break}} + scope: support.type.primitive.null.js + pop: true + + - match: void{{identifier_break}} + scope: support.type.primitive.void.js pop: true - # These three are ordinary variables, not literals! - - match: undefined{{identifier_break}} - scope: constant.language.undefined.js - pop: true - - match: NaN{{identifier_break}} - scope: constant.language.nan.js - pop: true - - match: Infinity{{identifier_break}} - scope: constant.language.infinity.js - pop: true + property-access: + - match: (\.\?)?(\[) + 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 + + - match: \.(?:\?)? + scope: punctuation.accessor.js + push: + - match: (?={{identifier}}\s*(?:\.\?)?\() + set: + - call-method-meta + - function-call-arguments + - call-path + - object-property + - include: object-property + + jsx-tag-attributes: + - meta_content_scope: meta.tag.js + + - match: '>' + scope: punctuation.definition.tag.end.js + set: jsx-body + + - match: / + scope: punctuation.definition.tag.end.js + set: jsx-expect-tag-end + + - include: jsx-interpolation - array-literal: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: expression-list + - match: '{{jsx_identifier}}' + scope: entity.other.attribute-name.js - initializer: - match: '=' - scope: keyword.operator.assignment.js - set: expression-no-comma - - include: else-pop + scope: punctuation.separator.key-value.js + push: jsx-attribute-value - 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 + jsx-html-escapes: + - match: (&)#?[[:alnum:]]+(;) + scope: constant.character.escape.js + captures: + 1: punctuation.definition.entity.js + 2: punctuation.definition.entity.js - 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: '{{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 + export-extended: + - include: flow-type-export-type - decorator-meta: - - meta_include_prototype: false - - meta_scope: meta.annotation.js - - include: immediately-pop + - include: variable-declaration + - include: function-or-class-declaration - function-parameter-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: default{{identifier_break}} + scope: keyword.control.import-export.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: function-parameter-binding-list + - include: function-or-class-declaration + - match: (?=\S) + set: expression-statement - expect-parenthesized-expression: - - include: parenthesized-expression - - include: else-pop + - match: (?=\S) + set: + - expect-semicolon + - import-export-from + - export-list + - import-export-alias + - export-item - function-parameter-binding-object-destructuring: - - match: \{ - scope: punctuation.section.block.begin.js + jsx-tag-name: + - match: '' set: - - 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}}|\[|'|") - push: - - initializer - - function-parameter-binding-object-alias - - object-literal-meta-key - - function-parameter-binding-object-key + - - clear_scopes: 1 + - meta_scope: meta.tag.name.js + - include: immediately-pop + - jsx-tag-name-component - call-function-name: - - match: '{{dollar_only_identifier}}' - scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{identifier}}' - scope: variable.function.js + inherited-class-name: + - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' + scope: entity.other.inherited-class.js pop: true - - include: else-pop -first_line_match: ^#!\s*/.*\b(node|js)\b + decorator-expression-end: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: decorator-name + - include: object-property + + - include: left-expression-end + +name: JavaScript (Babel) file_extensions: - js - jsx - - babel - es6 + - babel +first_line_match: ^#!\s*/.*\b(node|js)\b variables: - line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) - identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) + arrow_func_lookahead: |- + (?x)(?: + \s*(async\s*)? + (?: + {{identifier}} + |\( (?: [^()]|\([^()]*\) )* \) + ) + (?: + \s*: + \s*{{identifier}} + )? + \s*=> + ) + dec_exponent: (?:[Ee](?:[-+]|(?![-+])){{dec_digit}}*) + identifier: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + block_comment_contents: (?:(?:[^*]|\*(?!/))*) + either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) + func_lookahead: |- + (?x: + \s* + (?:async{{identifier_break}}{{nothing}})? + function{{identifier_break}} + ) + property_name: >- + (?x: + {{identifier}} + | '(?:[^\\']|\\.)*' + | "(?:[^\\"]|\\.)*" + | \[ .* \] + ) + dec_integer: (?:0|[1-9]{{dec_digit}}*) dollar_only_identifier: (?:\${{identifier_break}}) + line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) + block_comment: (?:/\*{{block_comment_contents}}\*/) + method_lookahead: |- + (?x)(?= + (?: get|set|async ){{identifier_break}}(?!\s*:) + | \* + | {{property_name}} \s* (?:\(|<) + ) + jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' + dec_digit: '[0-9_]' + jsx_identifier_part: (?:{{identifier_part}}|-) + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier}}) hex_digit: '[\h_]' - either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - oct_digit: '[0-7_]' line_continuation_lookahead: >- (?x:(?= \s* @@ -2822,13 +2863,6 @@ variables: (?:in|instanceof){{identifier_break}} ) )) - bin_digit: '[01_]' - dot_accessor: |- - (?x: # Match . and .?, but not .?( or .?[ - \. - (?! \? [\[(] ) - \?? - ) reserved_word: |- (?x: break|case|catch|class|const|continue|debugger|default|delete|do|else| @@ -2837,33 +2871,16 @@ variables: enum| null|true|false ){{identifier_break}} - block_comment: (?:/\*{{block_comment_contents}}\*/) - identifier: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier}}) - jsx_identifier_break: (?!{{jsx_identifier_part}}) - constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) - arrow_func_lookahead: |- - (?x)(?: - \s*(async\s*)? - (?: - {{identifier}} - |\( (?: [^()]|\([^()]*\) )* \) - ) - (?: - \s*: - \s*{{identifier}} - )? - \s*=> + binding_pattern_lookahead: (?:{{identifier}}|\[|\{) + dot_accessor: |- + (?x: # Match . and .?, but not .?( or .?[ + \. + (?! \? [\[(] ) + \?? ) - jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' - jsx_identifier_part: (?:{{identifier_part}}|-) + jsx_identifier_break: (?!{{jsx_identifier_part}}) 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*[.\[\(]) - identifier_break: (?!{{identifier_part}}) - nothing: (?x:(?:\s+|{{block_comment}})*) - block_comment_contents: (?:(?:[^*]|\*(?!/))*) - dec_digit: '[0-9_]' - binding_pattern_lookahead: (?:{{identifier}}|\[|\{) + constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) class_element_name: |- (?x: \+? @@ -2873,28 +2890,11 @@ variables: | \#{{identifier}} ) ) - identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) - dec_integer: (?:0|[1-9]{{dec_digit}}*) dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) - property_name: >- - (?x: - {{identifier}} - | '(?:[^\\']|\\.)*' - | "(?:[^\\"]|\\.)*" - | \[ .* \] - ) - func_lookahead: |- - (?x: - \s* - (?:async{{identifier_break}}{{nothing}})? - function{{identifier_break}} - ) - dec_exponent: (?:[Ee](?:[-+]|(?![-+])){{dec_digit}}*) - method_lookahead: |- - (?x)(?= - (?: get|set|async ){{identifier_break}}(?!\s*:) - | \* - | {{property_name}} \s* (?:\(|<) - ) -scope: source.js.babel -name: JavaScript (Babel) + nothing: (?x:(?:\s+|{{block_comment}})*) + bin_digit: '[01_]' + oct_digit: '[0-7_]' + left_expression_end_lookahead: (?!\s*[.\[\(]) + identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + identifier_break: (?!{{identifier_part}}) +scope: source.js diff --git a/build/build.py b/build/build.py index 401ebd3..c1f63c6 100644 --- a/build/build.py +++ b/build/build.py @@ -5,6 +5,19 @@ __all__ = ['BuildBabelPackageCommand'] +BABEL_CONFIGURATION = { + 'name': 'JavaScript (Babel)', + 'scope': 'source.js', + 'file_extensions': [ 'js', 'jsx', 'es6', 'babel' ], + 'flow_types': True, + 'jsx': True, + 'string_object_keys': True, + # 'custom_template_tags': { + # 'styled_components': True, + # }, +} + + class BuildBabelPackageCommand(sublime_plugin.ApplicationCommand): def run(self): from sublime_lib import ResourcePath @@ -15,13 +28,21 @@ def run(self): syntax_path = ResourcePath('Packages/babel-sublime/JavaScript (Babel).sublime-syntax') test_directory = package_path / 'tests' - print(test_directory, syntax_path) rmtree(str(test_directory), ignore_errors=True) test_directory.mkdir() + print("Building syntax…") + sublime.active_window().run_command('build_js_custom_syntax', { + 'name': 'Babel', + 'configuration': BABEL_CONFIGURATION, + 'destination_path': str(syntax_path.file_path()), + }) + + print("Building tests…") sublime.run_command('build_js_custom_tests', { 'syntax_path': str(syntax_path), 'suites': ['base', 'flow', 'jsx', 'string_object_keys'], 'destination_directory': str(test_directory), }) + print('Done.')