diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax
index ccefc2b..443c433 100644
--- a/JavaScript (Babel).sublime-syntax
+++ b/JavaScript (Babel).sublime-syntax
@@ -1,193 +1,226 @@
%YAML 1.2
---
+scope: source.js
+variables:
+ line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$)
+ dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}})
+ identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}})
+ function_call_lookahead: >-
+ (?x:(?=
+ {{identifier_name}}
+ \s*
+ (?:
+ <
+ .*
+ >
+ \s*
+ )?
+ (?:{{dot_accessor}})?
+ \(
+ ))
+ block_comment_contents: (?:(?:[^*]|\*(?!/))*)
+ jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}'
+ method_lookahead: |-
+ (?x)(?=
+ (?: get|set|async ){{identifier_break}}(?!\s*:)
+ | \*
+ | {{property_name}} \s* (?:\(|<)
+ )
+ dot_accessor: (?:\??\.)
+ oct_digit: '[0-7_]'
+ modifier: (?:static{{identifier_break}})
+ jsdoc_block_tag: \@[^\n\t\f\v *@]+
+ constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}})
+ jsx_identifier_part: (?:{{identifier_part}}|-)
+ dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*'
+ reserved_word: |-
+ (?x:
+ break|case|catch|class|const|continue|debugger|default|delete|do|else|
+ export|extends|finally|for|function|if|import|in|instanceof|new|return|
+ super|switch|this|throw|try|typeof|var|void|while|with|yield|
+ enum|
+ null|true|false
+ ){{identifier_break}}
+ func_lookahead: |-
+ (?x:
+ (?:async{{identifier_break}}{{nothing}})?
+ function{{identifier_break}}
+ )
+ either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}})
+ arrow_func_lookahead: |-
+ (?x)(?:
+ \s*(async\s*)?
+ (?:
+ {{non_reserved_identifier}}
+ |\( (?: [^()]|\([^()]*\) )* \)
+ )
+ (?:
+ \s*:
+ \s*{{non_reserved_identifier}}
+ )?
+ \s*=>
+ )
+ function_assignment_lookahead: |-
+ (?x:(?=
+ \s* = \s*
+ {{either_func_lookahead}}
+ ))
+ dec_integer: (?:0|[1-9]{{dec_digit}}*)
+ identifier_escape: (?:\\u(?:\h{4}|\{\h+\}))
+ non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}})
+ hex_digit: '[\h_]'
+ identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}})
+ identifier_break: (?!{{identifier_part}})
+ property_name: >-
+ (?x:
+ {{identifier_name}}
+ | [0-9]+
+ | '(?:[^\\']|\\.)*'
+ | "(?:[^\\"]|\\.)*"
+ | \[ .* \]
+ )
+ bin_digit: '[01_]'
+ dec_digit: '[0-9_]'
+ block_comment: (?:/\*{{block_comment_contents}}\*/)
+ identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}})
+ dollar_only_identifier: (?:\${{identifier_break}})
+ line_continuation_lookahead: >-
+ (?x:(?=
+ (?! \+\+ | -- )
+ (?=
+ != |
+ [-+*/%><=&|^\[(;,.:?] |
+ (?:in|instanceof){{identifier_break}}
+ )
+ ))
+ possible_arrow_function_begin: (?:\(|{{identifier_start}}|<)
+ binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{)
+ left_expression_end_lookahead: (?!\s*[.\[\(])
+ jsx_identifier_break: (?!{{jsx_identifier_part}})
+ nothing: (?x:(?:\s|{{block_comment}})*)
+ class_element_name: |-
+ (?x:
+ \+?
+ (?:
+ \*?
+ {{property_name}}
+ | \#{{non_reserved_identifier}}
+ )
+ )
file_extensions:
- js
- jsx
- es6
- babel
name: JavaScript (Babel)
-version: 2
contexts:
- flow-arrow-function-return-type-annotation:
- - match: ':'
- scope: punctuation.separator.type.js
- set:
- - flow-type-meta
- - flow-type-end-no-arrow
- - flow-type-begin
- - match: (?!\s*(?:$|:|//|/\*))
- pop: true
-
- await-expression:
- - match: await{{identifier_break}}
- scope: keyword.control.flow.await.js
+ inherited-class-expression-begin:
+ - include: inherited-class-name
+ - include: expression-begin
- block-comment-body:
+ function-meta:
- meta_include_prototype: false
- - meta_scope: comment.block.js
- - include: block-comment-end
-
- variable-binding-object-key:
- - match: '{{identifier_name}}(?=\s*:)'
- scope: string.unquoted.js
- pop: true
- - match: '{{identifier_name}}(?=\s*:)'
- pop: true
- - include: literal-string
- - include: computed-property-name
- - include: variable-binding-name
- - include: else-pop
+ - meta_scope: meta.function.js
+ - include: immediately-pop
- function-declaration-expect-function-keyword:
- - match: function{{identifier_break}}
- scope: keyword.declaration.function.js
- pop: true
- - include: else-pop
+ branch-possible-arrow-function:
+ - match: (?=<)
+ set: jsx-tag
- support-property-node-module:
- - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}}
- scope: support.constant.node.js
- pop: true
- - match: require{{identifier_break}}
- scope: support.function.node.js
- pop: true
+ - match: (?=\()
+ set:
+ - detect-arrow
+ - flow-detect-arrow-function-return-type
+ - parenthesized-expression
- import-expression-end:
+ - meta_include_prototype: false
- match: (?=\()
- set: function-call-arguments
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
set:
- - match: meta{{identifier_break}}
- scope: variable.language.import.js
- pop: true
- - include: object-property
- - include: else-pop
- export-list:
- - match: ','
- scope: punctuation.separator.comma.js
- push:
- - import-export-alias
- - export-item
- - include: else-pop
+ - detect-arrow
+ - parenthesized-expression
+ - match: (?={{identifier_start}})
+ set:
+ - detect-arrow
+ - literal-variable
+
+ variable-binding-name:
+ - match: (?={{non_reserved_identifier}})
+ set:
+ - - meta_scope: meta.binding.name.js
+ - include: immediately-pop
+ - literal-variable
+
+ function-name-meta:
+ - meta_include_prototype: false
+ - meta_scope: entity.name.function.js
+ - include: immediately-pop
line-comment-triple-slash-body:
- meta_include_prototype: false
- meta_scope: comment.line.triple-slash.js
- include: line-comment-end
- flow-type-generic-arguments:
- - match: <
- scope: punctuation.definition.generic.begin.js
- set:
- - meta_scope: meta.generic.js
- - match: '>'
- scope: punctuation.definition.generic.end.js
- pop: true
- - include: flow-type-list
+ flow-function-type-arguments-or-less-than:
+ - match: (?=<(?![<=]))
+ branch_point: flow-function-type-arguments
+ branch:
+ - flow-function-type-arguments
+ - flow-less-than
- function-parameter-binding-object-key:
- - match: '{{identifier_name}}(?=\s*:)'
- pop: true
- - include: literal-string
- - include: computed-property-name
- - include: function-parameter-binding-name
+ method-declaration-expect-asterisk:
+ - match: \*
+ scope: keyword.generator.asterisk.js
- include: else-pop
- regular-function:
- - match: (?={{func_lookahead}})
- set: function-declaration
-
- function-name-meta:
+ jsx-tag-name:
- meta_include_prototype: false
- - meta_scope: entity.name.function.js
- - include: immediately-pop
+ - match: ''
+ set:
+ - jsx-tag-name-meta
+ - jsx-tag-name-end
+ - jsx-tag-name-component-possibly-native
- 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
+ flow-type-primitive:
+ - match: boolean{{identifier_break}}
+ scope: support.type.primitive.boolean.js
pop: true
- flow-type-class:
- - match: '{{non_reserved_identifier}}'
- scope: variable.other.class.js
+ - match: number{{identifier_break}}
+ scope: support.type.primitive.number.js
pop: true
- class-meta:
- - meta_include_prototype: false
- - meta_scope: meta.class.js
- - include: immediately-pop
-
- field-name:
- - match: '{{dollar_identifier}}'
- scope: meta.mapping.key.dollar.js variable.other.readwrite.js
- captures:
- 1: punctuation.dollar.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
+
+ object-property-name:
- match: '{{identifier_name}}'
- scope: variable.other.readwrite.js
+ scope: string.unquoted.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_name}})
- captures:
- 1: punctuation.definition.variable.js
- 2: variable.other.readwrite.js
- match: (?=\[)
- push: computed-property-name
+ set: computed-property-name
+
+ - include: literal-string
+ - include: literal-number
+
+ - match: '{{identifier_name}}'
+ pop: true
- include: else-pop
- regexp:
+ decorator-meta:
- meta_include_prototype: false
- - meta_scope: meta.string.js string.regexp.js
- - match: /
- scope: punctuation.definition.string.end.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
+ - meta_scope: meta.annotation.js
+ - include: immediately-pop
flow-type-module-body:
- match: \{
@@ -195,209 +228,101 @@ contexts:
set: flow-type-module-contents
- include: else-pop
- jsx-tag:
- - match: <
- scope: punctuation.definition.tag.begin.js
- set:
- - jsx-meta
- - jsx-tag-attributes-top
-
- flow-type-typeof:
- - match: typeof{{identifier_break}}
- scope: keyword.operator.js
- set:
- - left-expression-end
- - expression-begin
-
- variable-binding-spread:
- - match: \.\.\.
- scope: keyword.operator.spread.js
- push: variable-binding-pattern
-
- block-scope:
- - include: block
+ do-while-condition:
+ - match: while{{identifier_break}}
+ scope: keyword.control.loop.while.js
+ set: parenthesized-expression
- include: else-pop
- postfix-operators:
- - match: --
- scope: keyword.operator.arithmetic.js
- - match: \+\+
- scope: keyword.operator.arithmetic.js
+ class-name:
+ - match: '{{non_reserved_identifier}}'
+ scope: entity.name.class.js
+ set: flow-type-generic-parameters
+ - include: else-pop
- function-parameter-binding-array-destructuring:
- - match: \[
- scope: punctuation.section.brackets.begin.js
+ variable-binding-object-destructuring:
+ - match: \{
+ scope: punctuation.section.block.begin.js
set:
- - meta_scope: meta.binding.destructuring.sequence.js
- - match: \]
- scope: punctuation.section.brackets.end.js
+ - meta_scope: meta.binding.destructuring.mapping.js
+ - match: \}
+ scope: punctuation.section.block.end.js
pop: true
- - include: function-parameter-binding-list
-
- import-export-from:
- - match: from{{identifier_break}}
- scope: keyword.control.import-export.js
- set: literal-string
- - include: else-pop
+ - include: variable-binding-spread
+ - match: (?={{identifier_start}}|\[|'|")
+ push:
+ - initializer
+ - variable-binding-object-alias
+ - object-literal-meta-key
+ - variable-binding-object-key
+ - include: comma-separator
- property-access:
- - match: ({{dot_accessor}})?(\[)
- captures:
- 1: punctuation.accessor.js
- 2: punctuation.section.brackets.begin.js
- push:
- - meta_scope: meta.brackets.js
- - match: \]
- scope: punctuation.section.brackets.end.js
- pop: true
- - match: (?=\S)
- push: expression
+ class:
+ - match: class{{identifier_break}}
+ scope: keyword.declaration.class.js
+ set:
+ - class-meta
+ - class-body
+ - class-extends
+ - class-name
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- push:
- - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\()
- set:
- - call-method-meta
- - function-call-arguments
- - call-path
- - object-property
- - include: object-property
+ jsx-meta-unmatched-tag:
+ - meta_include_prototype: false
+ - meta_scope: invalid.illegal.unmatched-tag.js
+ - include: immediately-pop
- function-declaration-parameters:
- - match: \(
- scope: punctuation.section.group.begin.js
- set:
- - clear_scopes: 1
- - meta_scope: meta.function.parameters.js
- - match: \)
- scope: punctuation.section.group.end.js
- pop: true
- - include: function-parameter-binding-list
+ try-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.try.js
+ - include: immediately-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
+ object-literal-element:
+ - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))'
+ scope: variable.other.readwrite.js
pop: true
- - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}}
- scope: support.function.builtin.js
+ - match: (?=\S)
pop: true
+ branch_point: object-literal-property
+ branch:
+ - object-literal-property
+ - method-declaration
- script:
- - match: \)|\}|\]
- scope: invalid.illegal.stray-bracket-end.js
- # Don't pop or embedding could break.
+ support-variable-ecma:
+ - match: Array{{identifier_break}}
+ scope: support.class.builtin.js
+ set:
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ set:
+ - include: support-property-ecma-array
+ - include: object-property
+ - include: else-pop
+ - include: else-pop
- - include: statements
+ - match: ArrayBuffer{{identifier_break}}
+ scope: support.class.builtin.js
+ set:
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ set:
+ - include: support-property-ecma-arraybuffer
+ - include: object-property
+ - include: else-pop
+ - include: else-pop
- literal-string:
- - match: "'"
- scope: punctuation.definition.string.begin.js
+ - match: Atomics{{identifier_break}}
+ scope: support.constant.builtin.js
set:
- - meta_include_prototype: false
- - meta_scope: meta.string.js string.quoted.single.js
- - match: \'
- scope: punctuation.definition.string.end.js
- pop: true
- - match: \n
- scope: invalid.illegal.newline.js
- pop: true
- - include: string-content
- - match: '"'
- scope: punctuation.definition.string.begin.js
- set:
- - meta_include_prototype: false
- - meta_scope: meta.string.js string.quoted.double.js
- - match: \"
- scope: punctuation.definition.string.end.js
- pop: true
- - match: \n
- scope: invalid.illegal.newline.js
- pop: true
- - include: string-content
-
- flow-type-end:
- - include: flow-type-operators
- - include: flow-type-generic-arguments
- - include: else-pop
-
- function-meta:
- - meta_include_prototype: false
- - meta_scope: meta.function.js
- - include: immediately-pop
-
- flow-type-alias-initializer:
- - match: '='
- scope: keyword.operator.assignment.js
- set:
- - flow-type-meta
- - flow-type
- - include: else-pop
- object-literal-property-check:
- - match: (?=\()
- fail: object-literal-property
- - include: else-pop
-
- flow-type-alias:
- - match: (?=type{{identifier_break}})
- set:
- - - match: (?={{non_reserved_identifier}})
- set:
- - - meta_scope: meta.declaration.type.js
- - match: ''
- pop: true
- - flow-type-alias-initializer
- - flow-type-generic-parameters
- - - match: '{{non_reserved_identifier}}'
- scope: entity.name.type.js
- pop: true
- - - include: else-pop
-
- - match: (?=\S)
- set: [expression-statement, expression-end]
- - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}}))
- scope: keyword.declaration.js
- set:
- - meta_scope: meta.declaration.type.js
- - include: else-pop
- - include: expression-begin
-
- support-variable-ecma:
- - match: Array{{identifier_break}}
- scope: support.class.builtin.js
- set:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- set:
- - include: support-property-ecma-array
- - include: object-property
- - include: else-pop
- - include: else-pop
-
- - match: ArrayBuffer{{identifier_break}}
- scope: support.class.builtin.js
- set:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- set:
- - include: support-property-ecma-arraybuffer
- - include: object-property
- - include: else-pop
- - include: else-pop
-
- - match: 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: BigInt{{identifier_break}}
- scope: support.class.builtin.js
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ set:
+ - include: support-property-ecma-atomics
+ - include: object-property
+ - include: else-pop
+ - include: else-pop
+
+ - match: BigInt{{identifier_break}}
+ scope: support.class.builtin.js
set:
- match: '{{dot_accessor}}'
scope: punctuation.accessor.js
@@ -550,102 +475,15 @@ contexts:
scope: support.function.js
pop: true
- do-while-meta:
- - meta_include_prototype: false
- - meta_scope: meta.do-while.js
- - include: immediately-pop
-
- expect-parenthesized-expression:
- - include: parenthesized-expression
+ variable-binding-object-alias:
+ - match: ':'
+ scope: punctuation.separator.key-value.js
+ set: variable-binding-pattern
- include: else-pop
- literal-number:
- # floats
- - match: |-
- (?x:
- # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1
- {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} )
- # .1, .1e1, .1e-1
- | (\.) {{dec_digit}}+ (?:{{dec_exponent}})?
- ){{identifier_break}}
- scope: meta.number.float.decimal.js constant.numeric.value.js
- captures:
- 1: punctuation.separator.decimal.js
- 2: punctuation.separator.decimal.js
- pop: true
-
- # integers
- - match: (0)({{dec_digit}}+){{identifier_break}}
- scope: meta.number.integer.octal.js
- captures:
- 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js
- 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js
- pop: true
-
- - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}}
- scope: meta.number.integer.hexadecimal.js
- captures:
- 1: constant.numeric.base.js
- 2: constant.numeric.value.js
- 3: constant.numeric.suffix.js
- pop: true
-
- - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}}
- scope: meta.number.integer.octal.js
- captures:
- 1: constant.numeric.base.js
- 2: constant.numeric.value.js
- 3: constant.numeric.suffix.js
- pop: true
-
- - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}}
- scope: meta.number.integer.binary.js
- captures:
- 1: constant.numeric.base.js
- 2: constant.numeric.value.js
- 3: constant.numeric.suffix.js
- pop: true
-
- - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}}
- scope: meta.number.integer.decimal.js
- captures:
- 1: constant.numeric.value.js
- 2: constant.numeric.suffix.js
- pop: true
-
- # illegal numbers
- - match: 0[Xx]{{identifier_part}}+
- scope: invalid.illegal.numeric.hexadecimal.js
- pop: true
-
- - match: 0[Bb]{{identifier_part}}+
- scope: invalid.illegal.numeric.binary.js
- pop: true
-
- - match: 0{{identifier_part}}+
- scope: invalid.illegal.numeric.octal.js
- pop: true
-
- - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?'
- scope: invalid.illegal.numeric.decimal.js
- pop: true
-
- literal-variable-base:
- - match: '{{dollar_only_identifier}}'
- scope: variable.other.dollar.only.js punctuation.dollar.js
- pop: true
- - match: '{{dollar_identifier}}'
- scope: variable.other.dollar.js
- captures:
- 1: punctuation.dollar.js
- pop: true
- - match: '{{constant_identifier}}'
- scope: variable.other.constant.js
- pop: true
- - match: '{{identifier_name}}'
- scope: variable.other.readwrite.js
- pop: true
- - include: literal-private-variable
+ block-scope:
+ - include: block
+ - include: else-pop
flow-function-type-arguments:
- match: \<(?!<)
@@ -666,394 +504,359 @@ contexts:
fail: flow-function-type-arguments
- flow-type
- flow-type-generic-parameters:
- - match: <
- scope: punctuation.definition.generic.begin.js
+ method-declaration:
+ - meta_include_prototype: false
+ - match: ''
set:
- - meta_scope: meta.generic.declaration.js
- - match: '>'
- scope: punctuation.definition.generic.end.js
- pop: true
- - include: comma-separator
- - match: \+
- scope: storage.modifier.variance.js
- - match: '{{non_reserved_identifier}}'
- scope: variable.parameter.type.js
- push:
- - - match: '='
- scope: keyword.operator.assignment.js
- set: flow-type
- - include: else-pop
- - flow-type-annotation
- - include: else-pop
+ - function-meta
+ - function-declaration-expect-body
+ - flow-type-annotation
+ - function-declaration-expect-parameters
+ - flow-type-generic-parameters
+ - method-name
+ - method-declaration-expect-asterisk
- flow-jsx-tag-check:
- - match: (?=[:,])
- fail: arrow-function
- - include: else-pop
- expression-end-no-comma:
- - match: (?=,)
- pop: true
- - include: expression-end
+ flow-type-typeof:
+ - match: typeof{{identifier_break}}
+ scope: keyword.operator.js
+ set:
+ - left-expression-end
+ - expression-begin
- immediately-pop:
- - match: ''
- pop: true
+ export-statement:
+ - match: export{{identifier_break}}
+ scope: keyword.control.import-export.js
+ set:
+ - export-meta
+ - export-extended
- conditional-meta:
+ class-meta:
- meta_include_prototype: false
- - meta_scope: meta.conditional.js
+ - meta_scope: meta.class.js
- include: immediately-pop
- with-meta:
- - meta_include_prototype: false
- - meta_scope: meta.with.js
- - include: immediately-pop
+ flow-type-module-name:
+ - include: literal-string
+ - match: '{{non_reserved_identifier}}'
+ scope: entity.name.module.js
+ pop: true
+ - include: else-pop
- object-property-base:
- - match: '{{dollar_only_identifier}}'
- scope: meta.property.object.dollar.only.js punctuation.dollar.js
- pop: true
- - match: '{{dollar_identifier}}'
- scope: meta.property.object.dollar.js
- captures:
- 1: punctuation.dollar.js
- pop: true
- - match: '{{identifier_name}}'
- scope: meta.property.object.js
- pop: true
- - match: '{{identifier_part}}+{{identifier_break}}'
- scope: invalid.illegal.illegal-identifier.js
- pop: true
- - match: (#)({{identifier_name}})
- captures:
- 1: punctuation.definition.variable.js
- 2: meta.property.object.js
+ function-declaration-expect-async:
+ - match: async{{identifier_break}}
+ scope: keyword.declaration.async.js
pop: true
+ - include: else-pop
- function-declaration-expect-name:
- - match: '{{non_reserved_identifier}}'
- scope: entity.name.function.js
+ jsx-tag-name-component:
+ - match: '{{jsx_identifier}}'
+ scope: entity.name.tag.js
pop: true
- include: else-pop
- constructor:
- - match: new{{identifier_break}}
- scope: keyword.operator.word.new.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
+ flow-jsx-tag-check:
+ - match: (?=[:,])
+ fail: arrow-function
+ - include: else-pop
+ expect-parenthesized-expression:
+ - include: parenthesized-expression
+ - include: else-pop
- block-comment-end:
- - match: \*+/
- scope: punctuation.definition.comment.end.js
+ switch-block-contents:
+ - meta_scope: meta.block.js
+
+ - match: \}
+ scope: punctuation.section.block.end.js
pop: true
- literal-call:
- - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\()
- set:
- - call-function-meta
- - function-call-arguments
- - literal-variable
+ - match: case{{identifier_break}}
+ scope: keyword.control.conditional.case.js
+ push:
+ - expect-case-colon
+ - expression
- - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\()
- set:
- - call-method-meta
- - function-call-arguments
- - call-path
- - literal-variable
+ - match: default{{identifier_break}}
+ scope: keyword.control.conditional.default.js
+ push:
+ - expect-case-colon
- shebang-body:
- - meta_include_prototype: false
- - meta_scope: comment.line.shebang.js
- # Note: Keep sync with first_line_match!
- - match: \b(node|js)\b
- scope: constant.language.shebang.js
- - match: \n
- pop: 1
+ - include: statements
- statement:
- - include: flow-type-declare
- - include: flow-type-alias
+ line-comment-double-slash-body:
+ - meta_include_prototype: false
+ - meta_scope: comment.line.double-slash.js
+ - include: line-comment-end
- - match: \;
- scope: punctuation.terminator.statement.empty.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: declaration
- - include: import-statement-or-import-meta
- - include: export-statement
- - include: conditional
- - include: block
- - include: label
-
- - match: break{{identifier_break}}
- scope: keyword.control.flow.break.js
+ variable-declaration:
+ - match: (?:const|let|var){{identifier_break}}
+ scope: keyword.declaration.js
set:
- expect-semicolon
- - expect-label
+ - variable-binding-list-top
+ - variable-binding-top
- - match: continue{{identifier_break}}
- scope: keyword.control.flow.continue.js
+ flow-type-alias-initializer:
+ - match: '='
+ scope: keyword.operator.assignment.js
set:
- - expect-semicolon
- - expect-label
-
- - match: debugger{{identifier_break}}
- scope: keyword.control.flow.debugger.js
- set: expect-semicolon
+ - flow-type-meta
+ - flow-type
+ - include: else-pop
+ styled-component-end:
+ - match: \.
+ scope: punctuation.accessor.dot.js
+ push: styled-component-begin
- - match: return{{identifier_break}}
- scope: keyword.control.flow.return.js
- set: restricted-production
+ - match: (?=`)
+ set:
+ - match: '`'
+ scope: string.quoted.other.js punctuation.definition.string.begin.js
+ push:
+ - - meta_include_prototype: false
+ - meta_scope: meta.string.js string.quoted.other.js
+ - match: '`'
+ scope: punctuation.definition.string.end.js
+ pop: true
+ - include: immediately-pop
+ - - meta_include_prototype: false
+ - clear_scopes: 1
+ - include: immediately-pop
+ - - meta_include_prototype: false
+ - match: ''
+ set: scope:source.js.css
+ with_prototype:
+ - match: (?=`)
+ pop: true
+ - match: \$\{
+ scope: punctuation.section.interpolation.begin.js
+ push:
+ - clear_scopes: 1
+ - meta_scope: meta.interpolation.js
+ - meta_content_scope: source.js.embedded.expression
+ - match: \}
+ scope: punctuation.section.interpolation.end.js
+ pop: true
+ - match: (?=\S)
+ push: expression
+ - include: string-content
+ - include: else-pop
+ - include: expression-end
- - match: throw{{identifier_break}}
- scope: keyword.control.flow.throw.js
- set: restricted-production
+ for-oldstyle-rest:
+ - match: (?=\))
+ pop: true
+ - match: ;
+ scope: punctuation.separator.expression.js
+ - match: (?=\S)
+ push: expression
- - include: decorator
+ special-identifier:
+ # These are ordinary identifiers, not reserved words
+ - match: arguments{{identifier_break}}
+ scope: variable.language.arguments.js
+ pop: true
+ - match: globalThis{{identifier_break}}
+ scope: variable.language.global.js
+ pop: true
+ - 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
- - include: expression-statement
+ comma-separator:
+ - match: ','
+ scope: punctuation.separator.comma.js
- arrow-function-expect-parameters:
- - match: (?={{identifier_start}})
+ regexp:
+ - meta_include_prototype: false
+ - meta_scope: meta.string.js string.regexp.js
+ - match: /
+ scope: punctuation.definition.string.end.js
set:
- - clear_scopes: 1
- - meta_scope: meta.function.parameters.js
- - match: '{{identifier_name}}'
- scope: variable.parameter.function.js
+ - 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: function-declaration-parameters
- - include: else-pop
+ - include: scope:source.regexp.js
- styled-component-begin:
- - match: '{{non_reserved_identifier}}(?=\s*\()'
- scope: variable.function.js
- pop: true
+ expression:
+ - meta_include_prototype: false
+ - match: ''
+ set: [expression-end, expression-begin]
- - match: '{{non_reserved_identifier}}(?=\s*`)'
- scope: variable.function.tagged-template.js
+ function-declaration-expect-generator-star:
+ - match: \*
+ scope: keyword.declaration.generator.js
pop: true
+ - include: else-pop
- - match: '{{non_reserved_identifier}}'
- scope: variable.other.readwrite.js
- pop: true
+ jsx-html-escapes:
+ - match: (&)#?[[:alnum:]]+(;)
+ scope: constant.character.escape.js
+ captures:
+ 1: punctuation.definition.entity.js
+ 2: punctuation.definition.entity.js
+ variable-binding-top:
+ - match: (?={{binding_pattern_lookahead}})
+ set:
+ - initializer
+ - variable-binding-pattern
- include: else-pop
- jsx-tag-attributes:
- - meta_scope: meta.tag.attributes.js
- - match: '>'
- scope: punctuation.definition.tag.end.js
- set: jsx-body
-
- - match: /
- scope: punctuation.definition.tag.end.js
- set: jsx-expect-tag-end
-
- - include: jsx-interpolation
-
- - match: '{{jsx_identifier}}'
- scope: entity.other.attribute-name.js
-
- - match: '='
- scope: punctuation.separator.key-value.js
- push: jsx-attribute-value
-
- for-meta:
+ jsx-tag-name-meta:
+ - clear_scopes: 1
- meta_include_prototype: false
- - meta_scope: meta.for.js
+ - meta_scope: meta.tag.name.js
- include: immediately-pop
- 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_start}}|\[|'|")
- push:
- - initializer
- - function-parameter-binding-object-alias
- - object-literal-meta-key
- - function-parameter-binding-object-key
-
- import-meta-expression:
- - match: import{{identifier_break}}
- scope: keyword.import.js
- set: import-expression-end
-
- line-comment-other-body:
- - meta_include_prototype: false
- - meta_scope: comment.line.other.js
- - include: line-comment-end
-
- for-condition-contents:
- # This could be either type of for loop.
- - match: (?:const|let|var){{identifier_break}}
- scope: keyword.declaration.js
- set:
- - - include: for-of-rest
- - match: (?=\S)
- set:
- - for-oldstyle-rest
- - variable-binding-list
- - initializer
- - variable-binding-pattern
+ support-property-ecma-promise:
+ - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
- - match: (?=\S)
+ variable-binding-list-top:
+ - match: '{{line_ending_ahead}}'
set:
- - - include: for-of-rest
- - match: (?=\S)
- set: for-oldstyle-rest
- - expression-end-no-in
- - expression-begin
-
- inherited-class-expression-end:
- - include: flow-type-generic-arguments
-
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- push:
- - include: inherited-class-name
- - include: object-property
-
- - include: left-expression-end
-
- function-parameter-binding-spread:
- - match: \.\.\.
- scope: keyword.operator.spread.js
- push: function-parameter
-
- comma-separator:
+ - match: '{{line_continuation_lookahead}}'
+ set: variable-binding-top
+ - include: else-pop
- match: ','
scope: punctuation.separator.comma.js
+ push: variable-binding-top
+ - include: else-pop
- support-property-ecma-array:
- - match: (?:from|isArray|of){{identifier_break}}
- scope: support.function.builtin.js
- pop: true
-
- 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|clearInterval|setTimeout|setInterval){{identifier_break}}
- scope: support.function.dom.js
- pop: true
-
- flow-type-primitive:
- - match: boolean{{identifier_break}}
- scope: support.type.primitive.boolean.js
+ support-property-ecma-number:
+ - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}}
+ scope: support.constant.builtin.js
pop: true
-
- - match: number{{identifier_break}}
- scope: support.type.primitive.number.js
+ - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}}
+ scope: support.function.builtin.js
pop: true
- - match: string{{identifier_break}}
- scope: support.type.primitive.string.js
- pop: true
+ arrow-function-expect-parameters:
+ - match: (?={{identifier_start}})
+ set:
+ - clear_scopes: 1
+ - meta_scope: meta.function.parameters.js
+ - match: '{{identifier_name}}'
+ scope: variable.parameter.function.js
+ pop: true
+ - include: function-declaration-parameters
+ - include: else-pop
- - match: null{{identifier_break}}
- scope: support.type.primitive.null.js
- pop: true
+ for-of-rest:
+ - match: (?:of|in){{identifier_break}}
+ scope: keyword.operator.word.js
+ set: expression
- - match: void{{identifier_break}}
- scope: support.type.primitive.void.js
- pop: true
+ conditional-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.conditional.js
+ - include: immediately-pop
- class-element-modifiers:
- - match: ''
- pop: true
- branch_point: class-element-modifier
+ styled-components:
+ - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}})
+ set:
+ - styled-component-end
+ - styled-component-begin
+ - match: (?=keyframes{{identifier_break}})
+ set:
+ - styled-component-keyframes-end
+ - styled-component-begin
+ import-statement-or-import-meta:
+ - match: (?=import{{identifier_break}})
+ branch_point: import-statement
branch:
- - class-element-modifier
- - class-element
-
- 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
-
- expression-break:
- - match: (?=[;})\]])
- pop: true
+ - import-statement
+ - expression-statement
- method-declaration:
+ export-meta:
- meta_include_prototype: false
+ - meta_scope: meta.export.js
+ - include: immediately-pop
+
+ object-literal-property:
- match: ''
set:
- - function-meta
- - function-declaration-expect-body
- - flow-type-annotation
- - function-declaration-expect-parameters
- - flow-type-generic-parameters
- - method-name
- - method-declaration-expect-asterisk
-
- initializer:
- - match: '='
- scope: keyword.operator.assignment.js
- set: expression-no-comma
- - include: else-pop
+ - object-literal-property-check
+ - object-literal-meta-key
+ - object-property-name
- flow-type-module-meta:
- - meta_scope: meta.module.js
- - include: immediately-pop
+ declaration:
+ - include: variable-declaration
+ - include: class
+ - include: regular-function
- string-content:
- - match: \\\n
- scope: constant.character.escape.newline.js
- - match: \\(?:x\h\h|u\h\h\h\h|.)
- scope: constant.character.escape.js
+ left-expression-end:
+ - include: expression-break
- class-element:
- - match: ''
- pop: true
- branch_point: class-field
- branch:
- - class-field
- - method-declaration
+ - match: (?=`)
+ push: literal-string-template
- literal-variable:
- - include: special-identifier
- - include: support
+ - match: (?=(?:{{dot_accessor}})?\()
+ push: function-call-arguments
- - match: (?={{identifier_name}}{{function_assignment_lookahead}})
- set:
- - function-name-meta
- - literal-variable-base
+ - include: property-access
- - match: '{{identifier_name}}(?={{nothing}}`)'
- scope: variable.function.tagged-template.js
- pop: true
+ - include: else-pop
- - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))'
- scope: support.class.js
- pop: true
+ jsx-body:
+ - meta_include_prototype: false
- - match: '{{function_call_lookahead}}'
- set: call-function-name
+ - match: <
+ scope: punctuation.definition.tag.begin.js
+ set:
+ - meta_scope: meta.tag.js
- - include: literal-variable-base
+ - match: /
+ scope: punctuation.definition.tag.begin.js
+ set:
+ - jsx-expect-tag-end
+ - jsx-tag-name
- styled-component-keyframes-end:
- - match: (?=`)
+ - match: (?=\S)
+ set:
+ - jsx-body
+ - jsx-tag-attributes
+ - jsx-tag-name
+
+ - include: jsx-html-escapes
+ - include: jsx-interpolation
+ 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
+
+ prototype:
+ - include: comments
+
+ styled-component-keyframes-end:
+ - match: (?=`)
push:
- match: '`'
scope: string.quoted.other.js punctuation.definition.string.begin.js
@@ -1088,240 +891,326 @@ contexts:
- include: else-pop
- include: else-pop
- jsx-attribute-value:
- - include: jsx-tag
- - include: jsx-interpolation
+ block-comment-end:
+ - match: \*+/
+ scope: punctuation.definition.comment.end.js
+ pop: true
- - 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
+ support-property:
+ - include: support-property-ecma
+ call-function-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.function-call.js
- include: else-pop
- array-literal:
- - match: \[
- scope: punctuation.section.brackets.begin.js
- set:
- - meta_scope: meta.sequence.js
- - match: \]
- scope: punctuation.section.brackets.end.js
- pop: true
- - include: expression-list
+ support-property-ecma-string:
+ - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
- for-await:
- - match: await{{identifier_break}}
- scope: keyword.control.flow.await.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
- - include: else-pop
- constructor-body-expect-class-begin:
- - match: (?={{non_reserved_identifier}}\s*\()
+ class-element-modifiers:
+ - match: ''
+ pop: true
+ branch_point: class-element-modifier
+ branch:
+ - class-element-modifier
+ - class-element
+
+ flow-type-generic-arguments:
+ - match: <
+ scope: punctuation.definition.generic.begin.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_name}}'
- scope: variable.type.js
+ - meta_scope: meta.generic.js
+ - match: '>'
+ scope: punctuation.definition.generic.end.js
pop: true
- - include: else-pop
+ - include: flow-type-list
- - include: expression-begin
+ support-variable-node:
+ - match: global{{identifier_break}}
+ scope: support.type.object.node.js
+ pop: true
- support-variable-console:
- # https://console.spec.whatwg.org/
- - match: console{{identifier_break}}
- scope: support.type.object.console.js
+ - match: Buffer{{identifier_break}}
+ scope: support.class.node.js
+ pop: true
+
+ - match: process{{identifier_break}}
+ scope: support.constant.node.js
set:
- match: '{{dot_accessor}}'
scope: punctuation.accessor.js
- set: builtin-console-properties
+ set:
+ - include: support-property-node-process
+ - include: object-property
+ - include: else-pop
- include: else-pop
- flow-type:
- - match: ''
- set:
- - flow-type-end
- - flow-type-begin
-
- variable-binding-pattern:
- - match: ''
+ # Module-level variables
+ - match: (?:__dirname|__filename|exports){{identifier_break}}
+ scope: support.constant.node.js
+ pop: true
+ - match: module{{identifier_break}}
+ scope: support.constant.node.js
set:
- - - include: flow-type-annotation
- - - include: variable-binding-name
- - include: variable-binding-array-destructuring
- - include: variable-binding-object-destructuring
+ - 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
- finally-meta:
- - meta_include_prototype: false
- - meta_scope: meta.finally.js
- - include: immediately-pop
-
- class-name:
- - match: '{{non_reserved_identifier}}'
- scope: entity.name.class.js
- set: flow-type-generic-parameters
- - 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
- flow-type-import-type:
- - match: type{{identifier_break}}
- scope: keyword.declaration.js
+ flow-type-object-indexer-type:
+ - match: \]
+ scope: punctuation.section.brackets.end.js
+ pop: true
+ - include: flow-type-list
- - match: typeof{{identifier_break}}
- scope: keyword.operator.js
+ import-item:
+ - include: flow-type-import-type
- 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
+ set: import-brace
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.other.readwrite.js
+ pop: true
+ - match: \*
+ scope: constant.other.js
+ pop: true
+ - include: else-pop
- computed-property-name:
- - match: \[
- scope: punctuation.section.brackets.begin.js
+ parenthesized-expression:
+ - match: \(
+ scope: punctuation.section.group.begin.js
set:
- - match: \]
- scope: punctuation.section.brackets.end.js
+ - meta_scope: meta.group.js
+ - match: \)
+ scope: punctuation.section.group.end.js
pop: true
+ - match: (?=:)
+ push: flow-type-annotation
- match: (?=\S)
push: expression
- decorator-expression-end:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- push:
- - include: decorator-name
- - include: object-property
-
- - include: left-expression-end
-
- decorator-expression-begin:
- - include: decorator-name
- - include: expression-begin
-
- class:
- - match: class{{identifier_break}}
- scope: keyword.declaration.class.js
- set:
- - class-meta
- - class-body
- - class-extends
- - class-name
-
- literal-string-template-custom-lookahead: []
- function-parameter:
- - match: ''
+ method-name:
+ - match: '{{dollar_identifier}}'
+ scope: meta.mapping.key.dollar.js entity.name.function.js
+ captures:
+ 1: punctuation.dollar.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: entity.name.function.js
+ pop: true
+ - match: (#){{identifier_name}}
+ scope: entity.name.function.js
+ captures:
+ 1: punctuation.definition.js
+ pop: true
+ - match: "'"
+ scope: punctuation.definition.string.begin.js
set:
- - initializer
- - function-parameter-binding-pattern
+ - 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
- block-meta:
- - meta_include_prototype: false
- - meta_scope: meta.block.js
- - include: immediately-pop
+ - match: (?=\[)
+ push: computed-property-name
- switch-block:
- - match: \{
- scope: punctuation.section.block.begin.js
- set: switch-block-contents
- include: else-pop
- jsx-html-escapes:
- - match: (&)#?[[:alnum:]]+(;)
- scope: constant.character.escape.js
- captures:
- 1: punctuation.definition.entity.js
- 2: punctuation.definition.entity.js
+ flow-type-alias:
+ - match: (?=type{{identifier_break}})
+ set:
+ - - match: (?={{non_reserved_identifier}})
+ set:
+ - - meta_scope: meta.declaration.type.js
+ - match: ''
+ pop: true
+ - flow-type-alias-initializer
+ - flow-type-generic-parameters
+ - - match: '{{non_reserved_identifier}}'
+ scope: entity.name.type.js
+ pop: true
+ - - include: else-pop
- line-comment-end:
- - match: (//+)?\n
- captures:
- 1: punctuation.definition.comment.js
- pop: 1
+ - match: (?=\S)
+ set: [expression-statement, expression-end]
+ - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}}))
+ scope: keyword.declaration.js
+ set:
+ - meta_scope: meta.declaration.type.js
+ - include: else-pop
+ - include: expression-begin
- flow-type-list:
- - include: comma-separator
- - match: (?=\S)
- push: flow-type
+ binary-operators:
+ - match: instanceof{{identifier_break}}
+ scope: keyword.operator.js
+ push: expression-begin
+ - match: in{{identifier_break}}
+ scope: keyword.operator.js
+ push: expression-begin
+ - match: =(?![=>])
+ scope: keyword.operator.assignment.js
+ push: expression-begin
+ - match: |-
+ (?x)
+ %= | # assignment right-to-left both
+ &= | # assignment right-to-left both
+ \*= | # assignment right-to-left both
+ \+= | # assignment right-to-left both
+ -= | # assignment right-to-left both
+ /= | # assignment right-to-left both
+ \^= | # assignment right-to-left both
+ \|= | # assignment right-to-left both
+ <<= | # assignment right-to-left both
+ >>= | # assignment right-to-left both
+ >>>= | # assignment right-to-left both
+ &&= |
+ \|\|= |
+ \?\?=
+ scope: keyword.operator.assignment.augmented.js
+ push: expression-begin
+ - match: '&&|\|\||\?\?'
+ scope: keyword.operator.logical.js
+ push: expression-begin
+ - match: |-
+ (?x)
+ << | # bitwise-shift left-to-right both
+ >>> | # bitwise-shift left-to-right both
+ >> | # bitwise-shift left-to-right both
+ & | # bitwise-and left-to-right both
+ \^ | # bitwise-xor left-to-right both
+ \| # bitwise-or left-to-right both
+ scope: keyword.operator.bitwise.js
+ push: expression-begin
+ - match: |-
+ (?x)
+ <= | # comparison left-to-right both
+ >= | # comparison left-to-right both
+ < | # comparison left-to-right both
+ > # comparison left-to-right both
+ scope: keyword.operator.comparison.js
+ push: expression-begin
+ - match: |-
+ (?x)
+ === | # equality left-to-right both
+ !== | # equality left-to-right both
+ == | # equality left-to-right both
+ != # equality left-to-right both
+ scope: keyword.operator.comparison.js
+ push: expression-begin
+ - match: |-
+ (?x)
+ / | # division left-to-right both
+ % | # modulus left-to-right both
+ \* | # multiplication left-to-right both
+ \+ | # addition left-to-right both
+ - # subtraction left-to-right both
+ scope: keyword.operator.arithmetic.js
+ push: expression-begin
+ - match: ','
+ scope: keyword.operator.comma.js # Comma operator, not punctuation.
+ push: expression-begin
- jsx-expect-tag-end:
- - meta_content_scope: meta.tag.js
- - match: '>'
- scope: meta.tag.js punctuation.definition.tag.end.js
+ 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
+
+ new-target:
+ - match: \.
+ scope: punctuation.accessor.dot.js
+ set:
+ - match: target{{identifier_break}}
+ scope: variable.language.target.js
+ pop: true
+ - include: else-pop
+
- include: else-pop
- for-oldstyle-rest:
- - match: (?=\))
+ expect-case-colon:
+ - match: ':'
+ scope: punctuation.separator.js
pop: true
- - match: ;
- scope: punctuation.separator.expression.js
- - match: (?=\S)
- push: expression
-
- variable-binding-list:
- - include: comma-separator
- - match: (?={{binding_pattern_lookahead}})
- push:
- - initializer
- - variable-binding-pattern
- include: else-pop
- export-brace:
+ 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
+
+ static-block-body:
- meta_scope: meta.block.js
- - include: comma-separator
- match: \}
scope: punctuation.section.block.end.js
pop: true
- - match: '{{identifier_name}}'
- scope: variable.other.readwrite.js
- push: import-export-alias
- - match: \*
- scope: constant.other.js
- push: import-export-alias
- - include: else-pop
-
- import-list:
- - match: ','
- scope: punctuation.separator.comma.js
- push:
- - import-export-alias
- - import-item
- - include: else-pop
+ - include: statements
- object-literal-meta-key:
- - meta_scope: meta.mapping.key.js
+ flow-jsx-tag-check-name:
+ - match: (?=(?:(?:{{jsx_identifier_part}})|\.):)
+ fail: arrow-function
- include: else-pop
- class-field-check:
- - match: (?=[(<])
- fail: class-field
- - include: else-pop
+ 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|clearInterval|setTimeout|setInterval){{identifier_break}}
+ scope: support.function.dom.js
+ pop: true
expression-statement-end:
- match: '{{line_ending_ahead}}'
@@ -1331,884 +1220,747 @@ contexts:
- include: else-pop
- include: expression-end
- support-property-ecma-bigint:
- - match: (?:asUintN|asIntN){{identifier_break}}
+ literal-string-template-custom-tags: []
+ block-comment-body:
+ - meta_include_prototype: false
+ - meta_scope: comment.block.js
+ - include: block-comment-end
+
+ else-pop:
+ - match: (?=\S)
+ pop: true
+
+ support-property-ecma-json:
+ - match: (?:parse|stringify){{identifier_break}}
scope: support.function.builtin.js
pop: true
- new-target:
- - match: \.
- scope: punctuation.accessor.dot.js
+ literal-string-template:
+ - include: literal-string-template-custom-comments
+ - include: literal-string-template-custom-tags
+ - include: styled-components
+
+ - match: '`'
+ scope: punctuation.definition.string.begin.js
set:
- - match: target{{identifier_break}}
- scope: variable.language.target.js
+ - meta_include_prototype: false
+ - meta_scope: meta.string.js string.quoted.other.js
+ - match: '`'
+ scope: punctuation.definition.string.end.js
pop: true
- - include: else-pop
-
- - include: else-pop
-
- switch-block-contents:
- - meta_scope: meta.block.js
-
- - match: \}
- scope: punctuation.section.block.end.js
- pop: true
-
- - 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
+ - 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
- flow-type-special:
- - match: any{{identifier_break}}
- scope: support.type.any.js
- pop: true
+ line-comments:
+ - match: /{4,}
+ scope: punctuation.definition.comment.js
+ push: line-comment-other-body
+ - match: /{3}
+ scope: punctuation.definition.comment.js
+ push: line-comment-triple-slash-body
+ - match: /{2}
+ scope: punctuation.definition.comment.js
+ push: line-comment-double-slash-body
- - match: mixed{{identifier_break}}
- scope: support.type.mixed.js
- pop: true
+ flow-type-meta:
+ - meta_scope: meta.flow-type.js
+ - include: immediately-pop
- yield-expression:
- - match: yield{{identifier_break}}
- scope: keyword.control.flow.yield.js
- set:
- - match: $
- pop: true
- - match: \*
- scope: keyword.generator.asterisk.js
- set: expression-begin
- - match: (?=\S)
- set: expression-begin
+ flow-less-than:
+ - match: <
+ scope: keyword.operator.comparison.js
+ set: expression-begin
- special-identifier:
- # These are ordinary identifiers, not reserved words
- - match: arguments{{identifier_break}}
- scope: variable.language.arguments.js
- pop: true
- - match: globalThis{{identifier_break}}
- scope: variable.language.global.js
- pop: true
- - 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
+ custom-templates-default:
+ - include: literal-string-template
- flow-type-object-value:
- - match: (\?)?(:)
- captures:
- 1: storage.modifier.optional.js
- 2: punctuation.separator.key-value.js
- set: flow-type
+ class-field-check:
+ - match: (?=[(<])
+ fail: class-field
- include: else-pop
- function-declaration-expect-body:
+ arrow-function-expect-body:
- include: function-block
+ - match: (?=\S)
+ set:
+ - block-meta
+ - expression-no-comma
+
+ detect-arrow:
+ - match: (?==>)
+ fail: arrow-function
- include: else-pop
- class-body:
- - match: \{
- scope: punctuation.section.block.begin.js
- set: class-body-contents
+ block-comments:
+ # empty block comments
+ - match: /\*\*+/
+ scope: comment.block.empty.js punctuation.definition.comment.js
+ # documentation block comments
+ - match: /\*\*+
+ scope: punctuation.definition.comment.begin.js
+ push:
+ - jsdoc-comment-body
+ - jsdoc-block-tag
+ # normal block comments
+ - match: /\*
+ scope: punctuation.definition.comment.begin.js
+ push: block-comment-body
+ function-declaration-expect-function-keyword:
+ - match: function{{identifier_break}}
+ scope: keyword.declaration.function.js
+ pop: true
- include: else-pop
- jsx-interpolation:
- - match: (?={/\*)
- branch_point: jsx-interpolation-comment
- branch:
- - jsx-interpolation-comment
- - jsx-interpolation-plain
- - match: (?={)
- push: jsx-interpolation-plain
-
- parenthesized-expression:
- - match: \(
- scope: punctuation.section.group.begin.js
+ prefixed-object-literal-method:
+ - match: (?:get|set){{identifier_break}}
+ scope: storage.type.accessor.js
set:
- - meta_scope: meta.group.js
- - match: \)
- scope: punctuation.section.group.end.js
- pop: true
- - match: (?=:)
- push: flow-type-annotation
+ - meta_scope: meta.function.js
+ - match: (?={{class_element_name}})
+ set: method-declaration
- match: (?=\S)
- push: expression
-
- import-export-alias:
- - match: as{{identifier_break}}
- scope: keyword.control.import-export.js
+ fail: prefixed-object-literal-method
+ - match: (?:async){{identifier_break}}
+ scope: keyword.declaration.async.js
set:
- - match: default{{identifier_break}}
- scope: keyword.control.import-export.js
- pop: true
- - match: '{{identifier_name}}'
- scope: variable.other.readwrite.js
- pop: true
- - include: else-pop
- - include: else-pop
+ - meta_scope: meta.function.js
+ - match: (?=\*|{{class_element_name}})
+ set: method-declaration
+ - match: (?=\S)
+ fail: prefixed-object-literal-method
- literal-string-template-custom-comments: []
- flow-type-annotation-optional:
- - match: \?(?=:)
- scope: storage.modifier.optional.js
- - include: flow-type-annotation
+ support:
+ - include: support-variable-ecma
+ - include: support-variable-console
+ - include: support-variable-dom
+ - include: support-variable-node
- flow-type-object:
- - match: \{\|
+ object-literal:
+ - match: \{
scope: punctuation.section.block.begin.js
+ set: object-literal-contents
+
+ variable-binding-pattern:
+ - match: ''
set:
- - meta_scope: meta.type.object.exact.js
- - match: \|\}
- scope: punctuation.section.block.end.js
- pop: true
- - include: flow-type-object-contents
+ - - include: flow-type-annotation
+ - - include: variable-binding-name
+ - include: variable-binding-array-destructuring
+ - include: variable-binding-object-destructuring
+ - include: else-pop
- - match: \{
- scope: punctuation.section.block.begin.js
+ array-literal:
+ - match: \[
+ scope: punctuation.section.brackets.begin.js
set:
- - meta_scope: meta.type.object.js
- - match: \}
- scope: punctuation.section.block.end.js
+ - meta_scope: meta.sequence.js
+ - match: \]
+ scope: punctuation.section.brackets.end.js
pop: true
- - include: flow-type-object-contents
+ - include: expression-list
- function-declaration-expect-async:
- - match: async{{identifier_break}}
- scope: keyword.declaration.async.js
+ 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
- - include: else-pop
- restricted-production:
- - meta_include_prototype: false
- - match: '{{line_ending_ahead}}'
+ - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}}
+ scope: support.function.js
pop: true
- - match: ''
- set: expression-statement
- 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
+ # Annex B
+ - match: __proto__{{identifier_break}}
+ scope: invalid.deprecated.js variable.language.prototype.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: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}}
+ scope: invalid.deprecated.js support.function.js
pop: true
- flow-detect-arrow-function-return-type:
- - match: (?=:)
- pop: true
- branch_point: flow-arrow-function-return-type
- branch:
- - flow-arrow-return-type
- - immediately-pop
- - include: else-pop
+ object-property:
+ - include: support-property
- flow-type-object-contents:
- - include: comma-separator
- - match: ;
- scope: punctuation.separator.semicolon.js
- - match: '{{method_lookahead}}'
- push: method-declaration
- - match: \+
- scope: storage.modifier.variance.js
- - match: '{{non_reserved_identifier}}'
- scope: meta.object-literal.key.js
- push: flow-type-object-value
- - match: \[
- scope: punctuation.section.brackets.begin.js
+ - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}})
+ set:
+ - function-name-meta
+ - object-property-base
+
+ - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\()
+ set: call-method-name
+
+ - match: '{{identifier_name}}(?={{nothing}}`)'
+ scope: variable.function.tagged-template.js
+ pop: true
+
+ - include: object-property-base
+ - include: else-pop
+
+ async-arrow-function:
+ - match: async{{identifier_break}}
+ scope: keyword.declaration.async.js
+ set:
+ - function-meta
+ - arrow-function-expect-body
+ - arrow-function-expect-arrow-or-fail-async
+ - arrow-function-expect-parameters
+
+ jsx-tag-attributes:
+ - meta_scope: meta.tag.attributes.js
+
+ - match: '>'
+ scope: punctuation.definition.tag.end.js
+ set: jsx-body
+
+ - match: /
+ scope: punctuation.definition.tag.end.js
+ set: jsx-expect-tag-end
+
+ - include: jsx-interpolation
+
+ - match: '{{jsx_identifier}}'
+ scope: entity.other.attribute-name.js
+
+ - match: '='
+ scope: punctuation.separator.key-value.js
+ push: jsx-attribute-value
+
+ import-list:
+ - match: ','
+ scope: punctuation.separator.comma.js
push:
- - flow-type-object-value
- - flow-type-object-indexer-type
- - flow-type-object-indexer-label
+ - import-export-alias
+ - import-item
+ - include: else-pop
- flow-type-object-indexer-label:
- - match: ({{non_reserved_identifier}})\s*(:)
+ flow-type-class:
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.other.class.js
+ pop: true
+
+ call-method-name:
+ - include: support-property
+ - match: '{{identifier_name}}'
+ scope: variable.function.js
+ pop: true
+ - match: (#){{identifier_name}}
+ scope: variable.function.js
captures:
- 1: meta.object-literal.key.js
- 2: punctuation.separator.key-value.js
+ 1: punctuation.definition.js
pop: true
- include: else-pop
- jsx-meta:
- - meta_include_prototype: false
- - meta_scope: meta.jsx.js
- - include: immediately-pop
+ support-property-ecma-bigint:
+ - match: (?:asUintN|asIntN){{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
- variable-binding-object-destructuring:
+ block:
- match: \{
scope: punctuation.section.block.begin.js
set:
- - meta_scope: meta.binding.destructuring.mapping.js
+ - meta_scope: meta.block.js
- match: \}
scope: punctuation.section.block.end.js
pop: true
- - include: variable-binding-spread
- - match: (?={{identifier_start}}|\[|'|")
- push:
- - initializer
- - variable-binding-object-alias
- - object-literal-meta-key
- - variable-binding-object-key
- - include: comma-separator
+ - include: statements
- for-of-rest:
- - match: (?:of|in){{identifier_break}}
- scope: keyword.operator.word.js
- set: expression
+ flow-type-import-type:
+ - match: type{{identifier_break}}
+ scope: keyword.declaration.js
- import-check-branch:
- - match: (?=[.(]) # Recovery for import expressions
- fail: import-statement
- - include: else-pop
+ - match: typeof{{identifier_break}}
+ scope: keyword.operator.js
- branch-possible-arrow-function:
- - match: (?=<)
- set: jsx-tag
+ flow-type-object-value:
+ - match: (\?)?(:)
+ captures:
+ 1: storage.modifier.optional.js
+ 2: punctuation.separator.key-value.js
+ set: flow-type
+ - include: else-pop
- - match: (?=\()
- set:
- - detect-arrow
- - flow-detect-arrow-function-return-type
- - parenthesized-expression
+ flow-type-list:
+ - include: comma-separator
+ - match: (?=\S)
+ push: flow-type
+ finally-meta:
- meta_include_prototype: false
- - match: (?=\()
- set:
- - detect-arrow
- - parenthesized-expression
- - match: (?={{identifier_start}})
- set:
- - detect-arrow
- - literal-variable
-
- constructor-body-expect-class-end:
- - include: property-access
- - include: else-pop
+ - meta_scope: meta.finally.js
+ - include: immediately-pop
- flow-type-module-contents:
- - match: \}
- scope: punctuation.section.block.end.js
- pop: true
- - include: main
+ expression-no-comma:
+ - meta_include_prototype: false
+ - match: ''
+ set: [expression-end-no-comma, expression-begin]
+ jsx-tag-hack: []
jsx-tag-name-component-possibly-native:
- match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])'
scope: entity.name.tag.native.js
pop: true
- include: jsx-tag-name-component
- shebang:
- - meta_include_prototype: false
- - match: ^\#!
- scope: punctuation.definition.comment.js
- set: shebang-body
- - match: ^|(?=\S) # Note: Ensure to highlight shebang if the syntax is embedded.
- pop: 1
+ flow-arrow-return-type:
+ - match: ''
+ push:
+ - flow-detect-arrow-after-return-type
+ - flow-arrow-function-return-type-annotation
- variable-binding-object-alias:
- - match: ':'
- scope: punctuation.separator.key-value.js
- set: variable-binding-pattern
+ object-literal-meta-key:
+ - meta_scope: meta.mapping.key.js
- include: else-pop
- jsdoc-block-tag:
- - match: '{{jsdoc_block_tag}}'
- scope: entity.other.attribute-name.documentation.js
- pop: 1
- - match: (?=\S)|$
- pop: 1
+ support-property-ecma-typedarray:
+ - match: (?:BYTES_PER_ELEMENT){{identifier_break}}
+ scope: support.constant.builtin.js
+ pop: true
+
+ class-body:
+ - match: \{
+ scope: punctuation.section.block.begin.js
+ set: class-body-contents
- function-declaration-expect-parameters:
- - include: function-declaration-parameters
- include: else-pop
- flow-type-operators:
- - match: \|(?!\})
- scope: keyword.operator.type.union.js
- push: flow-type-begin
- - match: \&
- scope: keyword.operator.type.intersection.js
- push: flow-type-begin
- - match: =>
- scope: keyword.declaration.function.arrow.js
- push: flow-type-begin
- - match: \?
- scope: storage.modifier.maybe.js
- push: flow-type-begin
- - match: \.
- scope: punctuation.separator.accessor.js
- push: flow-type-begin
+ support-property-ecma-date:
+ - match: (?:now|parse|UTC){{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
- - match: \[\]
- scope: storage.modifier.array.js
- - match: '%checks{{identifier_break}}'
- scope: storage.modifier.checks.js
+ call-method-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.function-call.method.js
+ - include: else-pop
- ternary-operator:
- - match: \?(?=[^.]|\.[0-9])
- scope: keyword.operator.ternary.js
+ flow-type-generic-parameters:
+ - match: <
+ scope: punctuation.definition.generic.begin.js
set:
- - ternary-operator-expect-colon
- - expression-no-comma
-
- function-parameter-binding-object-alias:
- - match: ':'
- scope: punctuation.separator.key-value.js
- set: function-parameter-binding-pattern
+ - meta_scope: meta.generic.declaration.js
+ - match: '>'
+ scope: punctuation.definition.generic.end.js
+ pop: true
+ - include: comma-separator
+ - match: \+
+ scope: storage.modifier.variance.js
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.parameter.type.js
+ push:
+ - - match: '='
+ scope: keyword.operator.assignment.js
+ set: flow-type
+ - include: else-pop
+ - flow-type-annotation
- include: else-pop
- function-parameter-binding-list:
- - match: ','
- scope: punctuation.separator.parameter.function.js
- - include: function-parameter-binding-spread
- - match: (?={{binding_pattern_lookahead}})
- push: function-parameter
- - include: else-pop
+ expression-begin:
+ - include: jsx-tag-hack
- styled-component-end:
- - match: \.
- scope: punctuation.accessor.dot.js
- push: styled-component-begin
+ - include: flow-arrow-function-declaration-with-type-parameters
- match: (?=`)
set:
- - match: '`'
- scope: string.quoted.other.js punctuation.definition.string.begin.js
- push:
- - - meta_include_prototype: false
- - meta_scope: meta.string.js string.quoted.other.js
- - match: '`'
- scope: punctuation.definition.string.end.js
- pop: true
- - include: immediately-pop
- - - meta_include_prototype: false
- - clear_scopes: 1
- - include: immediately-pop
- - - meta_include_prototype: false
- - match: ''
- set: scope:source.js.css
- with_prototype:
- - match: (?=`)
- pop: true
- - match: \$\{
- scope: punctuation.section.interpolation.begin.js
- push:
- - clear_scopes: 1
- - meta_scope: meta.interpolation.js
- - meta_content_scope: source.js.embedded.expression
- - match: \}
- scope: punctuation.section.interpolation.end.js
- pop: true
- - match: (?=\S)
- push: expression
- - include: string-content
- - include: else-pop
- - include: expression-end
-
- label:
- - match: ({{identifier_name}})\s*(:)
- captures:
- 1: entity.name.label.js
- 2: punctuation.separator.js
+ - include: literal-string-template-custom-comments
+ - include: literal-string-template-custom-lookahead
+ - include: custom-templates-default
- binary-operators:
- - match: instanceof{{identifier_break}}
- scope: keyword.operator.js
- push: expression-begin
- - match: in{{identifier_break}}
- scope: keyword.operator.js
- push: expression-begin
- - match: =(?![=>])
- scope: keyword.operator.assignment.js
- push: expression-begin
- - match: |-
- (?x)
- %= | # assignment right-to-left both
- &= | # assignment right-to-left both
- \*= | # assignment right-to-left both
- \+= | # assignment right-to-left both
- -= | # assignment right-to-left both
- /= | # assignment right-to-left both
- \^= | # assignment right-to-left both
- \|= | # assignment right-to-left both
- <<= | # assignment right-to-left both
- >>= | # assignment right-to-left both
- >>>= | # assignment right-to-left both
- &&= |
- \|\|= |
- \?\?=
- scope: keyword.operator.assignment.augmented.js
- push: expression-begin
- - match: '&&|\|\||\?\?'
- scope: keyword.operator.logical.js
- push: expression-begin
- - match: |-
- (?x)
- << | # bitwise-shift left-to-right both
- >>> | # bitwise-shift left-to-right both
- >> | # bitwise-shift left-to-right both
- & | # bitwise-and left-to-right both
- \^ | # bitwise-xor left-to-right both
- \| # bitwise-or left-to-right both
- scope: keyword.operator.bitwise.js
- push: expression-begin
- - match: |-
- (?x)
- <= | # comparison left-to-right both
- >= | # comparison left-to-right both
- < | # comparison left-to-right both
- > # comparison left-to-right both
- scope: keyword.operator.comparison.js
- push: expression-begin
- - match: |-
- (?x)
- === | # equality left-to-right both
- !== | # equality left-to-right both
- == | # equality left-to-right both
- != # equality left-to-right both
- scope: keyword.operator.comparison.js
- push: expression-begin
- - match: |-
- (?x)
- / | # division left-to-right both
- % | # modulus left-to-right both
- \* | # multiplication left-to-right both
- \+ | # addition left-to-right both
- - # subtraction left-to-right both
- scope: keyword.operator.arithmetic.js
- push: expression-begin
- - match: ','
- scope: keyword.operator.comma.js # Comma operator, not punctuation.
- push: expression-begin
+ - include: expression-break
- export-extended:
- - include: flow-type-export-type
+ - include: yield-expression
+ - include: await-expression
- - include: declaration
+ - include: regexp-complete
+ - include: literal-string
+ - include: literal-string-template
+ - include: constructor
+ - include: literal-number
+ - include: prefix-operators
+ - include: import-meta-expression
- - match: default{{identifier_break}}
- scope: keyword.control.import-export.js
- set:
- - include: declaration
- - match: (?=\S)
- set: expression-statement
+ - include: class
+ - include: special-name
- - match: (?=\S)
- set:
- - expect-semicolon
- - import-export-from
- - export-list
- - import-export-alias
- - export-item
+ - include: regular-function
- jsx-tag-name-meta:
- - clear_scopes: 1
- - meta_include_prototype: false
- - meta_scope: meta.tag.name.js
- - include: immediately-pop
+ - match: (?={{reserved_word}})
+ pop: true
- expression-statement:
- - match: (?=\S)
+ - match: (?={{identifier_name}}{{function_assignment_lookahead}})
set:
- - expect-semicolon
- - expression-statement-end
- - expression-begin
+ - function-name-meta
+ - literal-variable
- variable-binding-name:
- - match: (?={{non_reserved_identifier}})
- set:
- - - meta_scope: meta.binding.name.js
- - include: immediately-pop
+ - include: object-literal
+
+ # Newline not allowed between `async` and parameters.
+ - match: (?=async{{identifier_break}}{{nothing}}{{possible_arrow_function_begin}})
+ pop: true
+ branch_point: async-arrow-function
+ branch:
+ - async-arrow-function
- literal-variable
- ternary-operator-expect-colon:
- - match: ':'
- scope: keyword.operator.ternary.js
- set: expression-no-comma
- - include: else-pop
+ - include: literal-call
- jsx-tag-name-component:
- - match: '{{jsx_identifier}}'
- scope: entity.name.tag.js
+ - match: (?={{possible_arrow_function_begin}})
pop: true
- - include: else-pop
+ branch_point: arrow-function
+ branch:
+ - branch-possible-arrow-function
+ - arrow-function-declaration
- class-extends:
- - match: extends{{identifier_break}}
- scope: storage.modifier.extends.js
- set:
- - inherited-class-expression-end
- - inherited-class-expression-begin
- - include: else-pop
+ - include: array-literal
- async-arrow-function:
- - match: async{{identifier_break}}
- scope: keyword.declaration.async.js
- set:
- - function-meta
- - arrow-function-expect-body
- - arrow-function-expect-arrow-or-fail-async
- - arrow-function-expect-parameters
+ - include: literal-private-variable
- expect-case-colon:
- - match: ':'
- scope: punctuation.separator.js
- pop: true
- include: else-pop
- object-literal-property:
- - match: ''
- set:
- - object-literal-property-check
- - object-literal-meta-key
- - object-property-name
-
- line-comment-double-slash-body:
+ jsx-meta:
- meta_include_prototype: false
- - meta_scope: comment.line.double-slash.js
- - include: line-comment-end
-
- prefixed-object-literal-method:
- - match: (?:get|set){{identifier_break}}
- scope: storage.type.accessor.js
- set:
- - meta_scope: meta.function.js
- - match: (?={{class_element_name}})
- set: method-declaration
- - match: (?=\S)
- fail: prefixed-object-literal-method
- - match: (?:async){{identifier_break}}
- scope: keyword.declaration.async.js
- set:
- - meta_scope: meta.function.js
- - match: (?=\*|{{class_element_name}})
- set: method-declaration
- - match: (?=\S)
- fail: prefixed-object-literal-method
+ - meta_scope: meta.jsx.js
+ - include: immediately-pop
- prototype:
- - include: comments
+ literal-number:
+ # floats
+ - match: |-
+ (?x:
+ # 1., 1.1, 1.1e1, 1.1e-1, 1.e1, 1.e-1 | 1e1, 1e-1
+ {{dec_integer}} (?: (\.) {{dec_digit}}* (?:{{dec_exponent}})? | {{dec_exponent}} )
+ # .1, .1e1, .1e-1
+ | (\.) {{dec_digit}}+ (?:{{dec_exponent}})?
+ ){{identifier_break}}
+ scope: meta.number.float.decimal.js constant.numeric.value.js
+ captures:
+ 1: punctuation.separator.decimal.js
+ 2: punctuation.separator.decimal.js
+ pop: true
- jsx-interpolation-plain:
- - match: '{'
- scope: punctuation.definition.interpolation.begin.js
- set:
- - - meta_scope: meta.interpolation.js
- - meta_content_scope: source.js.embedded.jsx
- - match: '}'
- scope: punctuation.definition.interpolation.end.js
- pop: true
- - expression
+ # integers
+ - match: (0)({{dec_digit}}+){{identifier_break}}
+ scope: meta.number.integer.octal.js
+ captures:
+ 1: constant.numeric.base.js invalid.deprecated.numeric.octal.js
+ 2: constant.numeric.value.js invalid.deprecated.numeric.octal.js
+ pop: true
- 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
+ - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}}
+ scope: meta.number.integer.hexadecimal.js
+ captures:
+ 1: constant.numeric.base.js
+ 2: constant.numeric.value.js
+ 3: constant.numeric.suffix.js
+ pop: true
- conditional:
- - match: switch{{identifier_break}}
- scope: keyword.control.conditional.switch.js
- set:
- - switch-meta
- - switch-block
- - expect-parenthesized-expression
+ - match: (0[Oo])({{oct_digit}}*)(n)?{{identifier_break}}
+ scope: meta.number.integer.octal.js
+ captures:
+ 1: constant.numeric.base.js
+ 2: constant.numeric.value.js
+ 3: constant.numeric.suffix.js
+ pop: true
- - match: do{{identifier_break}}
- scope: keyword.control.loop.do-while.js
- set:
- - do-while-meta
- - do-while-condition
- - statement
+ - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}}
+ scope: meta.number.integer.binary.js
+ captures:
+ 1: constant.numeric.base.js
+ 2: constant.numeric.value.js
+ 3: constant.numeric.suffix.js
+ pop: true
- - match: for{{identifier_break}}
- scope: keyword.control.loop.for.js
- set:
- - for-meta
- - block-scope
- - for-condition
- - for-await
+ - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}}
+ scope: meta.number.integer.decimal.js
+ captures:
+ 1: constant.numeric.value.js
+ 2: constant.numeric.suffix.js
+ pop: true
- - match: while{{identifier_break}}
- scope: keyword.control.loop.while.js
- set:
- - while-meta
- - block-scope
- - expect-parenthesized-expression
+ # illegal numbers
+ - match: 0[Xx]{{identifier_part}}+
+ scope: invalid.illegal.numeric.hexadecimal.js
+ pop: true
- - match: with{{identifier_break}}
- scope: keyword.control.import.with.js
- set:
- - with-meta
- - block-scope
- - expect-parenthesized-expression
+ - match: 0[Bb]{{identifier_part}}+
+ scope: invalid.illegal.numeric.binary.js
+ pop: true
- - match: if{{identifier_break}}
- scope: keyword.control.conditional.if.js
- set:
- - conditional-meta
- - statement
- - expect-parenthesized-expression
+ - match: 0{{identifier_part}}+
+ scope: invalid.illegal.numeric.octal.js
+ pop: true
- - match: else\s+if{{identifier_break}}
- scope: keyword.control.conditional.elseif.js
- set:
- - conditional-meta
- - statement
- - expect-parenthesized-expression
+ - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?'
+ scope: invalid.illegal.numeric.decimal.js
+ pop: true
- - match: else{{identifier_break}}
- scope: keyword.control.conditional.else.js
+ import-expression-end:
+ - match: (?=\()
+ set: function-call-arguments
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
set:
- - conditional-meta
- - statement
+ - match: meta{{identifier_break}}
+ scope: variable.language.import.js
+ pop: true
+ - include: object-property
+ - include: else-pop
+ restricted-production:
+ - meta_include_prototype: false
+ - match: '{{line_ending_ahead}}'
+ pop: true
+ - match: ''
+ set: expression-statement
- - match: try{{identifier_break}}
- scope: keyword.control.exception.try.js
- set:
- - try-meta
- - block-scope
+ label:
+ - match: ({{identifier_name}})\s*(:)
+ captures:
+ 1: entity.name.label.js
+ 2: punctuation.separator.js
- - match: finally{{identifier_break}}
- scope: keyword.control.exception.finally.js
- set:
- - finally-meta
- - block-scope
+ support-property-node-module:
+ - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}}
+ scope: support.constant.node.js
+ pop: true
+ - match: require{{identifier_break}}
+ scope: support.function.node.js
+ pop: true
- - match: catch{{identifier_break}}
- scope: keyword.control.exception.catch.js
- set:
- - catch-meta
- - block-scope
- - expect-parenthesized-expression
+ literal-private-variable:
+ - match: (#)({{identifier_name}})
+ captures:
+ 1: punctuation.definition.variable.js
+ 2: variable.other.readwrite.js
+ pop: true
- object-literal:
- - match: \{
- scope: punctuation.section.block.begin.js
- set: object-literal-contents
+ expression-list:
+ - include: expression-break
+ - include: comma-separator
+ - match: (?=\S)
+ push: expression-no-comma
+
+ export-brace:
+ - meta_scope: meta.block.js
+ - include: comma-separator
+ - match: \}
+ scope: punctuation.section.block.end.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.other.readwrite.js
+ push: import-export-alias
+ - match: \*
+ scope: constant.other.js
+ push: import-export-alias
+ - include: else-pop
+
+ do-while-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.do-while.js
+ - include: immediately-pop
+
+ inherited-class-expression-end:
+ - include: flow-type-generic-arguments
+
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ push:
+ - include: inherited-class-name
+ - include: object-property
+
+ - include: left-expression-end
+
+ expect-semicolon:
+ - match: \;
+ scope: punctuation.terminator.statement.js
+ pop: true
+ - include: else-pop
regexp-complete:
- match: /
scope: punctuation.definition.string.begin.js
set: regexp
- support-property-ecma-arraybuffer:
- - match: isView{{identifier_break}}
- scope: support.function.builtin.js
+ flow-type-existential:
+ - match: \*
+ scope: constant.language.type.existential.js
pop: true
- function-parameter-binding-name:
- - match: '{{non_reserved_identifier}}'
- scope: meta.binding.name.js variable.parameter.function.js
- - match: '{{identifier_name}}'
- scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js
+ class-element:
+ - match: ''
+ pop: true
+ branch_point: class-field
+ branch:
+ - class-field
+ - method-declaration
- else-pop:
- - match: (?=\S)
+ expect-label:
+ - meta_include_prototype: false
+ - match: (?={{nothing}}{{identifier_name}})
+ set:
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.label.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: invalid.illegal.identifier.js variable.label.js
+ pop: true
+ - include: else-pop
+ - include: immediately-pop
+
+ immediately-pop-2:
+ - meta_include_prototype: false
+ - match: ''
+ pop: 2
+
+ flow-type-special:
+ - match: any{{identifier_break}}
+ scope: support.type.any.js
pop: true
- decorator-name:
- - match: '{{identifier_name}}{{left_expression_end_lookahead}}'
- scope: variable.annotation.js
+ - match: mixed{{identifier_break}}
+ scope: support.type.mixed.js
pop: true
- 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}}
+ support-property-ecma-array:
+ - match: (?:from|isArray|of){{identifier_break}}
scope: support.function.builtin.js
pop: true
- block-comments:
- # empty block comments
- - match: /\*\*+/
- scope: comment.block.empty.js punctuation.definition.comment.js
- # documentation block comments
- - match: /\*\*+
- scope: punctuation.definition.comment.begin.js
- push:
- - jsdoc-comment-body
- - jsdoc-block-tag
- # normal block comments
- - match: /\*
- scope: punctuation.definition.comment.begin.js
- push: block-comment-body
-
- try-meta:
+ for-meta:
- meta_include_prototype: false
- - meta_scope: meta.try.js
+ - meta_scope: meta.for.js
- include: immediately-pop
- comments:
- - include: line-comments
- - include: block-comments
+ immediately-pop:
+ - match: ''
+ pop: true
- decorator-meta:
+ jsx-tag:
+ - match: <
+ scope: punctuation.definition.tag.begin.js
+ set:
+ - jsx-meta
+ - jsx-tag-attributes-top
+
+ constructor-meta:
- meta_include_prototype: false
- - meta_scope: meta.annotation.js
+ - meta_scope: meta.function-call.constructor.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
-
- - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}}
- scope: support.function.js
- pop: true
+ shebang-body:
+ - meta_include_prototype: false
+ - meta_scope: comment.line.shebang.js
+ # Note: Keep sync with first_line_match!
+ - match: \b(node|js)\b
+ scope: constant.language.shebang.js
+ - match: \n
+ pop: 1
- # Annex B
- - match: __proto__{{identifier_break}}
- scope: invalid.deprecated.js variable.language.prototype.js
+ support-property-ecma-math:
+ - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}}
+ scope: support.constant.builtin.js
pop: true
- - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}}
- scope: invalid.deprecated.js support.function.js
+ - 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
+ await-expression:
+ - match: await{{identifier_break}}
+ scope: keyword.control.flow.await.js
- static-block:
- - match: static{{identifier_break}}
- scope: storage.modifier.js
- set:
- - match: \{
- scope: punctuation.section.block.begin.js
- set: static-block-body
- - match: (?=\S)
- fail: static-block
+ decorator:
+ - match: '@'
+ scope: punctuation.definition.annotation.js
+ push:
+ - decorator-meta
+ - decorator-expression-end
+ - decorator-expression-begin
- literal-string-template:
- - include: literal-string-template-custom-comments
- - include: literal-string-template-custom-tags
- - include: styled-components
+ call-function-name:
+ - match: '{{dollar_only_identifier}}'
+ scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.function.js
+ pop: true
+ - include: else-pop
- - match: '`'
- scope: punctuation.definition.string.begin.js
+ for-condition-contents:
+ # This could be either type of for loop.
+ - match: (?:const|let|var){{identifier_break}}
+ scope: keyword.declaration.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
+ - - include: for-of-rest
- match: (?=\S)
- push: expression
- - include: string-content
+ set:
+ - for-oldstyle-rest
+ - variable-binding-list
+ - initializer
+ - variable-binding-pattern
- flow-type-declare-export:
- - match: default{{identifier_break}}
- scope: keyword.control.import-export.js
- set: flow-type
- match: (?=\S)
- pop: true
-
- expect-label:
- - meta_include_prototype: false
- - match: (?={{nothing}}{{identifier_name}})
set:
- - match: '{{non_reserved_identifier}}'
- scope: variable.label.js
- pop: true
- - match: '{{identifier_name}}'
- scope: invalid.illegal.identifier.js variable.label.js
- pop: true
- - include: else-pop
- - include: immediately-pop
+ - - include: for-of-rest
+ - match: (?=\S)
+ set: for-oldstyle-rest
+ - expression-end-no-in
+ - expression-begin
- jsx-tag-name:
- - meta_include_prototype: false
+ function-parameter-binding-pattern:
- match: ''
set:
- - jsx-tag-name-meta
- - jsx-tag-name-end
- - jsx-tag-name-component-possibly-native
-
- special-name:
- - match: true{{identifier_break}}
- scope: constant.language.boolean.true.js
- pop: true
- - match: false{{identifier_break}}
- scope: constant.language.boolean.false.js
- pop: true
- - match: null{{identifier_break}}
- scope: constant.language.null.js
- pop: true
- - match: super{{identifier_break}}
- scope: variable.language.super.js
- pop: true
- - match: this{{identifier_break}}
- scope: variable.language.this.js
- pop: true
+ - - include: flow-type-annotation-optional
+ - - include: function-parameter-binding-name
+ - include: function-parameter-binding-array-destructuring
+ - include: function-parameter-binding-object-destructuring
+ - include: else-pop
- support-property-ecma-json:
- - match: (?:parse|stringify){{identifier_break}}
+ 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
- flow-detect-arrow-after-return-type:
- - match: (?==>)
- fail: arrow-function
- - match: (?=\S)
- fail: flow-arrow-function-return-type
-
- detect-arrow:
- - match: (?==>)
- fail: arrow-function
+ function-parameter-binding-list:
+ - match: ','
+ scope: punctuation.separator.parameter.function.js
+ - include: function-parameter-binding-spread
+ - match: (?={{binding_pattern_lookahead}})
+ push: function-parameter
- include: else-pop
- prefix-operators:
- - match: '~'
- scope: keyword.operator.bitwise.js
- - match: '!(?!=)'
- scope: keyword.operator.logical.js
- - match: --
- scope: keyword.operator.arithmetic.js
- - match: \+\+
- scope: keyword.operator.arithmetic.js
- - match: \.\.\.
- scope: keyword.operator.spread.js
- - match: \+|\-
- scope: keyword.operator.arithmetic.js
- - match: (?:delete|typeof|void){{identifier_break}}
- scope: keyword.operator.js
-
- catch-meta:
- - meta_include_prototype: false
- - meta_scope: meta.catch.js
- - include: immediately-pop
+ property-access:
+ - match: ({{dot_accessor}})?(\[)
+ captures:
+ 1: punctuation.accessor.js
+ 2: punctuation.section.brackets.begin.js
+ push:
+ - meta_scope: meta.brackets.js
+ - match: \]
+ scope: punctuation.section.brackets.end.js
+ pop: true
+ - match: (?=\S)
+ push: expression
- expression-no-comma:
- - meta_include_prototype: false
- - match: ''
- set: [expression-end-no-comma, expression-begin]
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ push:
+ - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\()
+ set:
+ - call-method-meta
+ - function-call-arguments
+ - call-path
+ - object-property
+ - include: object-property
function-declaration:
- match: ''
@@ -2230,244 +1982,242 @@ contexts:
- inherited-class-expression-begin
- include: else-pop
- support-property-ecma-proxy:
- - match: revocable{{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
-
- constructor-body-expect-arguments:
- - include: function-call-arguments
+ function-declaration-expect-body:
+ - include: function-block
- include: else-pop
- statements:
- - match: \)|\}|\]
- scope: invalid.illegal.stray-bracket-end.js
- pop: true
-
- - match: (?=\S)
- push: statement
-
- flow-type-existential:
- - match: \*
- scope: constant.language.type.existential.js
- pop: true
-
- line-comments:
- - match: /{4,}
- scope: punctuation.definition.comment.js
- push: line-comment-other-body
- - match: /{3}
- scope: punctuation.definition.comment.js
- push: line-comment-triple-slash-body
- - match: /{2}
- scope: punctuation.definition.comment.js
- push: line-comment-double-slash-body
-
- method-name:
- - match: '{{dollar_identifier}}'
- scope: meta.mapping.key.dollar.js entity.name.function.js
- captures:
- 1: punctuation.dollar.js
- pop: true
- - match: '{{identifier_name}}'
- scope: entity.name.function.js
- pop: true
- - match: (#){{identifier_name}}
- scope: entity.name.function.js
- captures:
- 1: punctuation.definition.js
- pop: true
- - match: "'"
- scope: punctuation.definition.string.begin.js
+ flow-type:
+ - match: ''
set:
- - meta_include_prototype: false
- - meta_scope: meta.string.js string.quoted.single.js
- - meta_content_scope: entity.name.function.js
- - match: \'
- scope: punctuation.definition.string.end.js
- pop: true
- - match: \n
- scope: invalid.illegal.newline.js
- pop: true
- - include: string-content
- - match: '"'
- scope: punctuation.definition.string.begin.js
+ - flow-type-end
+ - flow-type-begin
+
+ function-block:
+ - match: \{
+ scope: punctuation.section.block.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
+ - meta_scope: meta.block.js
+ - match: \}
+ scope: punctuation.section.block.end.js
pop: true
- - include: string-content
+ - include: statements
- - match: (?=\[)
- push: computed-property-name
+ conditional:
+ - match: switch{{identifier_break}}
+ scope: keyword.control.conditional.switch.js
+ set:
+ - switch-meta
+ - switch-block
+ - expect-parenthesized-expression
- - include: else-pop
+ - match: do{{identifier_break}}
+ scope: keyword.control.loop.do-while.js
+ set:
+ - do-while-meta
+ - do-while-condition
+ - statement
- 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
+ - match: for{{identifier_break}}
+ scope: keyword.control.loop.for.js
+ set:
+ - for-meta
+ - block-scope
+ - for-condition
+ - for-await
- custom-templates-default:
- - include: literal-string-template
+ - match: while{{identifier_break}}
+ scope: keyword.control.loop.while.js
+ set:
+ - while-meta
+ - block-scope
+ - expect-parenthesized-expression
- flow-type-end-no-arrow:
- - match: (?==>)
- pop: true
- - include: flow-type-end
+ - match: with{{identifier_break}}
+ scope: keyword.control.import.with.js
+ set:
+ - with-meta
+ - block-scope
+ - expect-parenthesized-expression
- expression-list:
- - include: expression-break
- - include: comma-separator
- - match: (?=\S)
- push: expression-no-comma
+ - match: if{{identifier_break}}
+ scope: keyword.control.conditional.if.js
+ set:
+ - conditional-meta
+ - statement
+ - expect-parenthesized-expression
- support-property:
- - include: support-property-ecma
+ - match: else\s+if{{identifier_break}}
+ scope: keyword.control.conditional.elseif.js
+ set:
+ - conditional-meta
+ - statement
+ - expect-parenthesized-expression
- expression:
- - meta_include_prototype: false
- - match: ''
- set: [expression-end, expression-begin]
+ - match: else{{identifier_break}}
+ scope: keyword.control.conditional.else.js
+ set:
+ - conditional-meta
+ - statement
- main:
- - meta_include_prototype: false # don't match comments before shebang
- - match: ''
- push: [script, shebang]
+ - match: try{{identifier_break}}
+ scope: keyword.control.exception.try.js
+ set:
+ - try-meta
+ - block-scope
- import-statement-or-import-meta:
- - match: (?=import{{identifier_break}})
- branch_point: import-statement
- branch:
- - import-statement
- - expression-statement
+ - match: finally{{identifier_break}}
+ scope: keyword.control.exception.finally.js
+ set:
+ - finally-meta
+ - block-scope
- decorator:
- - match: '@'
- scope: punctuation.definition.annotation.js
- push:
- - decorator-meta
- - decorator-expression-end
- - decorator-expression-begin
+ - match: catch{{identifier_break}}
+ scope: keyword.control.exception.catch.js
+ set:
+ - catch-meta
+ - block-scope
+ - expect-parenthesized-expression
- import-meta:
- - meta_include_prototype: false
- - meta_scope: meta.import.js
- - include: immediately-pop
+ jsdoc-block-tag:
+ - match: '{{jsdoc_block_tag}}'
+ scope: entity.other.attribute-name.documentation.js
+ pop: 1
+ - match: (?=\S)|$
+ pop: 1
- method-declaration-expect-asterisk:
- - match: \*
- scope: keyword.generator.asterisk.js
- - include: else-pop
+ flow-type-annotation:
+ - match: ':'
+ scope: punctuation.separator.type.js
+ set:
+ - flow-type-meta
+ - flow-type
+ - match: (?!\s*(?:$|:|//|/\*))
+ pop: true
- export-statement:
- - match: export{{identifier_break}}
- scope: keyword.control.import-export.js
+ flow-type-tuple:
+ - match: \[
+ scope: punctuation.section.brackets.begin.js
set:
- - export-meta
- - export-extended
+ - meta_scope: meta.sequence.js
+ - match: \]
+ scope: punctuation.section.brackets.end.js
+ pop: true
+ - include: flow-type-list
- arrow-function-expect-arrow-or-fail-async:
+ flow-type-object-contents:
+ - include: comma-separator
+ - match: ;
+ scope: punctuation.separator.semicolon.js
+ - match: '{{method_lookahead}}'
+ push: method-declaration
+ - match: \+
+ scope: storage.modifier.variance.js
+ - match: '{{non_reserved_identifier}}'
+ scope: meta.object-literal.key.js
+ push: flow-type-object-value
+ - match: \[
+ scope: punctuation.section.brackets.begin.js
+ push:
+ - flow-type-object-value
+ - flow-type-object-indexer-type
+ - flow-type-object-indexer-label
+
+ arrow-function-expect-arrow:
- match: =>
scope: keyword.declaration.function.arrow.js
pop: true
- - match: (?=\S)
- fail: async-arrow-function
-
- export-item:
- - match: \{
- scope: punctuation.section.block.begin.js
- set: export-brace
- - match: '{{non_reserved_identifier}}'
- scope: variable.other.readwrite.js
- pop: true
- - match: \*
- scope: constant.other.js
- pop: true
- - include: else-pop
-
- do-while-condition:
- - match: while{{identifier_break}}
- scope: keyword.control.loop.while.js
- set: parenthesized-expression
- include: else-pop
- expression-end:
- - include: flow-function-type-arguments-or-less-than
+ class-element-modifier:
+ - match: '{{modifier}}'
+ scope: storage.modifier.js
+ set:
+ - match: (?={{class_element_name}}|\*)
+ pop: true
+ - match: (?=\S)
+ fail: class-element-modifier
- - include: postfix-operators
- - include: binary-operators
- - include: ternary-operator
+ script:
+ - match: \)|\}|\]
+ scope: invalid.illegal.stray-bracket-end.js
+ # Don't pop or embedding could break.
- - include: left-expression-end
+ - include: statements
- arrow-function-declaration:
- - meta_include_prototype: false
- - match: ''
- set:
- - function-meta
- - arrow-function-expect-body
- - arrow-function-expect-arrow
- - flow-arrow-function-return-type-annotation
- - arrow-function-expect-parameters
- - flow-type-generic-parameters
+ line-comment-end:
+ - match: (//+)?\n
+ captures:
+ 1: punctuation.definition.comment.js
+ pop: 1
- support-variable-node:
- - match: global{{identifier_break}}
- scope: support.type.object.node.js
- pop: true
+ flow-detect-arrow-after-return-type:
+ - match: (?==>)
+ fail: arrow-function
+ - match: (?=\S)
+ fail: flow-arrow-function-return-type
- - match: Buffer{{identifier_break}}
- scope: support.class.node.js
+ constructor-body-expect-arguments:
+ - include: function-call-arguments
+ - include: else-pop
+
+ 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
- - match: process{{identifier_break}}
- scope: support.constant.node.js
+ import-statement:
+ - match: import{{identifier_break}}
+ scope: keyword.control.import-export.js
set:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- set:
- - include: support-property-node-process
- - include: object-property
- - include: else-pop
- - include: else-pop
+ - import-meta
+ - expect-semicolon
+ - import-string-or-items
+ - import-check-branch
- # Module-level variables
- - match: (?:__dirname|__filename|exports){{identifier_break}}
- scope: support.constant.node.js
+ export-item:
+ - match: \{
+ scope: punctuation.section.block.begin.js
+ set: export-brace
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.other.readwrite.js
pop: true
- - match: module{{identifier_break}}
- scope: support.constant.node.js
- set:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- set:
- - include: support-property-node-module
- - include: object-property
- - include: else-pop
- - include: else-pop
- - match: require{{identifier_break}}
- scope: support.function.node.js
+ - match: \*
+ scope: constant.other.js
pop: true
+ - include: else-pop
- while-meta:
- - meta_include_prototype: false
- - meta_scope: meta.while.js
- - include: immediately-pop
+ for-condition-end:
+ - meta_scope: meta.group.js
+
+ - match: \)
+ scope: punctuation.section.group.js
+ pop: true
+
+ class-extends:
+ - match: extends{{identifier_break}}
+ scope: storage.modifier.extends.js
+ set:
+ - inherited-class-expression-end
+ - inherited-class-expression-begin
+ - include: else-pop
+
+ ternary-operator-expect-colon:
+ - match: ':'
+ scope: keyword.operator.ternary.js
+ set: expression-no-comma
+ - include: else-pop
+
+ static-block:
+ - match: static{{identifier_break}}
+ scope: storage.modifier.js
+ set:
+ - match: \{
+ scope: punctuation.section.block.begin.js
+ set: static-block-body
+ - match: (?=\S)
+ fail: static-block
import-string-or-items:
- include: literal-string
@@ -2478,205 +2228,90 @@ contexts:
- import-export-alias
- import-item
- flow-type-meta:
- - meta_scope: meta.flow-type.js
- - include: immediately-pop
+ literal-string-template-custom-comments: []
+ prefix-operators:
+ - match: '~'
+ scope: keyword.operator.bitwise.js
+ - match: '!(?!=)'
+ scope: keyword.operator.logical.js
+ - match: --
+ scope: keyword.operator.arithmetic.js
+ - match: \+\+
+ scope: keyword.operator.arithmetic.js
+ - match: \.\.\.
+ scope: keyword.operator.spread.js
+ - match: \+|\-
+ scope: keyword.operator.arithmetic.js
+ - match: (?:delete|typeof|void){{identifier_break}}
+ scope: keyword.operator.js
- immediately-pop-2:
- - meta_include_prototype: false
- - match: ''
- pop: 2
+ flow-type-module-meta:
+ - meta_scope: meta.module.js
+ - include: immediately-pop
- support:
- - include: support-variable-ecma
- - include: support-variable-console
- - include: support-variable-dom
- - include: support-variable-node
+ string-content:
+ - match: \\\n
+ scope: constant.character.escape.newline.js
+ - match: \\(?:x\h\h|u\h\h\h\h|.)
+ scope: constant.character.escape.js
- flow-arrow-return-type:
- - match: ''
- push:
- - flow-detect-arrow-after-return-type
- - flow-arrow-function-return-type-annotation
+ support-property-ecma-arraybuffer:
+ - match: isView{{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
- class-element-modifier:
- - match: '{{modifier}}'
- scope: storage.modifier.js
+ expression-statement:
+ - match: (?=\S)
set:
- - match: (?={{class_element_name}}|\*)
- pop: true
- - match: (?=\S)
- fail: class-element-modifier
+ - expect-semicolon
+ - expression-statement-end
+ - expression-begin
- object-property:
- - include: support-property
+ statements:
+ - match: \)|\}|\]
+ scope: invalid.illegal.stray-bracket-end.js
+ pop: true
- - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}})
- set:
- - function-name-meta
- - object-property-base
+ - match: (?=\S)
+ push: statement
- - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\()
- set: call-method-name
+ catch-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.catch.js
+ - include: immediately-pop
- - match: '{{identifier_name}}(?={{nothing}}`)'
- scope: variable.function.tagged-template.js
+ 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
- - include: object-property-base
- - include: else-pop
+ import-meta-expression:
+ - match: import{{identifier_break}}
+ scope: keyword.import.js
+ set: import-expression-end
- 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
+ expression-end-no-comma:
+ - match: (?=,)
+ pop: true
+ - include: expression-end
- jsx-body:
+ jsdoc-comment-body:
- meta_include_prototype: false
+ - meta_scope: comment.block.documentation.js
+ - include: block-comment-end
+ # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation
+ # line so directly after the '/**' or after the '*' marker on the next lines.
+ - match: ^\s*(\*)(?!/)
+ captures:
+ 1: punctuation.definition.comment.js
+ push: jsdoc-block-tag
- - match: <
- scope: punctuation.definition.tag.begin.js
- set:
- - meta_scope: meta.tag.js
+ object-literal-contents:
+ - meta_scope: meta.mapping.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-top:
- - match: (?={{binding_pattern_lookahead}})
- set:
- - initializer
- - variable-binding-pattern
- - include: else-pop
-
- support-property-ecma-promise:
- - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}}
- scope: support.function.builtin.js
- pop: true
-
- support-property-ecma-reflect:
- - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}}
- scope: support.function.builtin.js
- pop: true
-
- support-property-ecma-typedarray:
- - match: (?:BYTES_PER_ELEMENT){{identifier_break}}
- scope: support.constant.builtin.js
- pop: true
-
- static-block-body:
- - meta_scope: meta.block.js
- - match: \}
- scope: punctuation.section.block.end.js
- pop: true
- - include: statements
-
- object-property-name:
- - match: '{{identifier_name}}'
- scope: string.unquoted.js
- pop: true
-
- - match: (?=\[)
- set: computed-property-name
-
- - include: literal-string
- - include: literal-number
-
- - match: '{{identifier_name}}'
- pop: true
-
- - include: else-pop
-
- expect-semicolon:
- - match: \;
- scope: punctuation.terminator.statement.js
- pop: true
- - include: else-pop
-
- arrow-function-expect-arrow:
- - match: =>
- scope: keyword.declaration.function.arrow.js
- pop: true
- - include: else-pop
-
- 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-expect-parameters
-
- - match: (?=static{{identifier_break}})
- branch_point: static-block
- branch:
- - static-block
- - class-element-modifiers
-
- - match: (?={{modifier}})
- push: class-element-modifiers
-
- - match: |-
- (?x)(?=
- \#? {{identifier_name}}
- \s* = \s*
- {{either_func_lookahead}}
- )
- push:
- - initializer
- - function-name-meta
- - literal-variable-base
-
- - match: (?=(?:get|set|async){{identifier_break}})
- branch_point: prefixed-method
- branch:
- - prefixed-method
- - class-element
-
- - match: (?=\*)
- push: method-declaration
-
- - match: (?={{class_element_name}})
- push: class-element
-
- constructor-meta:
- - meta_include_prototype: false
- - meta_scope: meta.function-call.constructor.js
- - include: immediately-pop
-
- object-literal-contents:
- - meta_scope: meta.mapping.js
-
- - match: \}
- scope: punctuation.section.block.end.js
- pop: true
+ - match: \}
+ scope: punctuation.section.block.end.js
+ pop: true
- match: \.\.\.
scope: keyword.operator.spread.js
@@ -2714,47 +2349,112 @@ contexts:
- match: (?=\S)
push: expression-no-comma
- flow-type-annotation:
- - match: ':'
- scope: punctuation.separator.type.js
+ variable-binding-spread:
+ - match: \.\.\.
+ scope: keyword.operator.spread.js
+ push: variable-binding-pattern
+
+ literal-variable:
+ - include: special-identifier
+ - include: support
+
+ - match: (?={{identifier_name}}{{function_assignment_lookahead}})
set:
- - flow-type-meta
- - flow-type
- - match: (?!\s*(?:$|:|//|/\*))
+ - function-name-meta
+ - literal-variable-base
+
+ - match: '{{identifier_name}}(?={{nothing}}`)'
+ scope: variable.function.tagged-template.js
pop: true
- function-call-arguments:
- - match: ({{dot_accessor}})?(\()
- captures:
- 1: punctuation.accessor.js
- 2: punctuation.section.group.begin.js
+ - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))'
+ scope: support.class.js
+ pop: true
+
+ - match: '{{function_call_lookahead}}'
+ set: call-function-name
+
+ - include: literal-variable-base
+
+ expression-end:
+ - include: flow-function-type-arguments-or-less-than
+
+ - include: postfix-operators
+ - include: binary-operators
+ - include: ternary-operator
+
+ - include: left-expression-end
+
+ for-condition:
+ - match: \(
+ scope: punctuation.section.group.js
set:
- - meta_scope: meta.group.js
+ - for-condition-end
+ - for-condition-contents
+ - include: else-pop
+
+ decorator-expression-end:
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ push:
+ - include: decorator-name
+ - include: object-property
+
+ - include: left-expression-end
+
+ jsx-tag-name-end:
+ - match: '[:.]'
+ scope: punctuation.accessor.js
+ push: jsx-tag-name-component
+ - include: else-pop
+
+ import-export-from:
+ - match: from{{identifier_break}}
+ scope: keyword.control.import-export.js
+ set: literal-string
+ - include: else-pop
+
+ function-parameter-binding-name:
+ - match: '{{non_reserved_identifier}}'
+ scope: meta.binding.name.js variable.parameter.function.js
+ - match: '{{identifier_name}}'
+ scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js
+
+ import-check-branch:
+ - match: (?=[.(]) # Recovery for import expressions
+ fail: import-statement
+ - include: else-pop
+
+ function-declaration-parameters:
+ - match: \(
+ scope: punctuation.section.group.begin.js
+ set:
+ - clear_scopes: 1
+ - meta_scope: meta.function.parameters.js
- match: \)
scope: punctuation.section.group.end.js
pop: true
- - include: expression-list
+ - include: function-parameter-binding-list
- expression-end-no-in:
- - match: (?=in{{identifier_break}})
- pop: true
- - include: expression-end
+ export-extended:
+ - include: flow-type-export-type
- import-brace:
- - include: flow-type-import-type
+ - include: declaration
- - meta_scope: meta.block.js
- - include: comma-separator
- - match: \}
- scope: punctuation.section.block.end.js
- pop: true
- - match: '{{identifier_name}}'
- scope: variable.other.readwrite.js
- push: import-export-alias
- - match: \*
- scope: constant.other.js
- push: import-export-alias
- - include: else-pop
+ - match: default{{identifier_break}}
+ scope: keyword.control.import-export.js
+ set:
+ - include: declaration
+ - match: (?=\S)
+ set: expression-statement
+
+ - match: (?=\S)
+ set:
+ - expect-semicolon
+ - import-export-from
+ - export-list
+ - import-export-alias
+ - export-item
flow-type-literal:
- match: true{{identifier_break}}
@@ -2772,120 +2472,126 @@ contexts:
- match: (?=['"])
set: literal-string
- jsx-tag-attributes-top:
- - meta_scope: meta.tag.js
- - match: /
- scope: punctuation.definition.tag.begin.js
- set:
- - jsx-meta-unmatched-tag
- - jsx-expect-tag-end
- - jsx-tag-name
-
- - match: (?=\S)
- set:
- - jsx-tag-attributes
- - flow-jsx-tag-check
- - jsx-tag-name
- - flow-jsx-tag-check-name
-
- variable-declaration:
- - match: (?:const|let|var){{identifier_break}}
- scope: keyword.declaration.js
+ constructor:
+ - match: new{{identifier_break}}
+ scope: keyword.operator.word.new.js
set:
- - expect-semicolon
- - variable-binding-list-top
- - variable-binding-top
-
- 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
+ - 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
+ object-literal-property-check:
+ - match: (?=\()
+ fail: object-literal-property
- include: else-pop
- flow-type-function:
- - match: \(
- scope: punctuation.section.grouping.begin.js
- set:
- - meta_scope: meta.group.js
- - match: \)
- scope: punctuation.section.grouping.end.js
- pop: true
- - include: flow-type-list
-
- import-item:
- - include: flow-type-import-type
+ flow-type-end-no-arrow:
+ - match: (?==>)
+ pop: true
+ - include: flow-type-end
- - match: \{
- scope: punctuation.section.block.begin.js
- set: import-brace
+ function-declaration-expect-name:
- match: '{{non_reserved_identifier}}'
- scope: variable.other.readwrite.js
- pop: true
- - match: \*
- scope: constant.other.js
+ scope: entity.name.function.js
pop: true
- include: else-pop
- switch-meta:
- - meta_include_prototype: false
- - meta_scope: meta.switch.js
- - include: immediately-pop
-
- function-declaration-expect-generator-star:
- - match: \*
- scope: keyword.declaration.generator.js
- pop: true
+ function-parameter-binding-object-alias:
+ - match: ':'
+ scope: punctuation.separator.key-value.js
+ set: function-parameter-binding-pattern
- include: else-pop
- support-property-ecma-math:
- - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}}
- scope: support.constant.builtin.js
+ literal-variable-base:
+ - match: '{{dollar_only_identifier}}'
+ scope: variable.other.dollar.only.js punctuation.dollar.js
pop: true
- - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}}
- scope: support.function.builtin.js
+ - match: '{{dollar_identifier}}'
+ scope: variable.other.dollar.js
+ captures:
+ 1: punctuation.dollar.js
+ pop: true
+ - match: '{{constant_identifier}}'
+ scope: variable.other.constant.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.other.readwrite.js
pop: true
+ - include: literal-private-variable
- import-statement:
- - match: import{{identifier_break}}
- scope: keyword.control.import-export.js
- set:
- - import-meta
- - expect-semicolon
- - import-string-or-items
- - import-check-branch
+ flow-type-export-type:
+ - match: type{{identifier_break}}(?=\s*\{)
+ scope: keyword.declaration.js
+ set: export-item
+ - include: flow-type-alias
- flow-type-module-name:
- - include: literal-string
- - match: '{{non_reserved_identifier}}'
- scope: entity.name.module.js
- pop: true
+ flow-type-end:
+ - include: flow-type-operators
+ - include: flow-type-generic-arguments
- include: else-pop
- flow-function-type-arguments-or-less-than:
- - match: (?=<(?![<=]))
- branch_point: flow-function-type-arguments
+ call-path:
+ - match: '{{dot_accessor}}'
+ scope: punctuation.accessor.js
+ push: object-property
+ - include: else-pop
+
+ jsx-interpolation:
+ - match: (?={/\*)
+ branch_point: jsx-interpolation-comment
branch:
- - flow-function-type-arguments
- - flow-less-than
+ - jsx-interpolation-comment
+ - jsx-interpolation-plain
+ - match: (?={)
+ push: jsx-interpolation-plain
- call-function-meta:
- - meta_include_prototype: false
- - meta_scope: meta.function-call.js
+ import-brace:
+ - include: flow-type-import-type
+
+ - meta_scope: meta.block.js
+ - include: comma-separator
+ - match: \}
+ scope: punctuation.section.block.end.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.other.readwrite.js
+ push: import-export-alias
+ - match: \*
+ scope: constant.other.js
+ push: import-export-alias
- include: else-pop
- flow-type-object-indexer-type:
- - match: \]
- scope: punctuation.section.brackets.end.js
+ function-parameter-binding-object-key:
+ - match: '{{identifier_name}}(?=\s*:)'
pop: true
- - include: flow-type-list
+ - include: literal-string
+ - include: computed-property-name
+ - include: function-parameter-binding-name
+ - include: else-pop
+
+ literal-call:
+ - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\()
+ set:
+ - call-function-meta
+ - function-call-arguments
+ - literal-variable
+
+ - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\()
+ set:
+ - call-method-meta
+ - function-call-arguments
+ - call-path
+ - literal-variable
+
+ expression-end-no-in:
+ - match: (?=in{{identifier_break}})
+ pop: true
+ - include: expression-end
flow-type-declare:
- match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}})
@@ -2905,163 +2611,152 @@ contexts:
set: flow-type-declare-export
- include: else-pop
- flow-type-export-type:
- - match: type{{identifier_break}}(?=\s*\{)
- scope: keyword.declaration.js
- set: export-item
- - include: flow-type-alias
-
- flow-less-than:
- - match: <
- scope: keyword.operator.comparison.js
- set: expression-begin
-
- styled-components:
- - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}})
+ prefixed-method:
+ - match: (?:get|set){{identifier_break}}
+ scope: storage.type.accessor.js
set:
- - styled-component-end
- - styled-component-begin
- - match: (?=keyframes{{identifier_break}})
+ - meta_scope: meta.function.js
+ - match: (?={{class_element_name}})
+ set: method-declaration
+ - match: (?=\S)
+ fail: prefixed-method
+ - match: (?:async){{identifier_break}}
+ scope: keyword.declaration.async.js
set:
- - styled-component-keyframes-end
- - styled-component-begin
- jsx-tag-hack: []
- flow-arrow-function-declaration-with-type-parameters: []
- call-method-name:
- - include: support-property
- - match: '{{identifier_name}}'
- scope: variable.function.js
+ - meta_scope: meta.function.js
+ - match: (?=\*|{{class_element_name}})
+ set: method-declaration
+ - match: (?=\S)
+ fail: prefixed-method
+
+ postfix-operators:
+ - match: --
+ scope: keyword.operator.arithmetic.js
+ - match: \+\+
+ scope: keyword.operator.arithmetic.js
+
+ expression-break:
+ - match: (?=[;})\]])
pop: true
- - match: (#){{identifier_name}}
+
+ styled-component-begin:
+ - match: '{{non_reserved_identifier}}(?=\s*\()'
scope: variable.function.js
- captures:
- 1: punctuation.definition.js
pop: true
- - include: else-pop
-
- call-path:
- - match: '{{dot_accessor}}'
- scope: punctuation.accessor.js
- push: object-property
- - include: else-pop
- for-condition:
- - match: \(
- scope: punctuation.section.group.js
- set:
- - for-condition-end
- - for-condition-contents
- - include: else-pop
+ - match: '{{non_reserved_identifier}}(?=\s*`)'
+ scope: variable.function.tagged-template.js
+ pop: true
- expression-begin:
- - include: jsx-tag-hack
-
- - include: flow-arrow-function-declaration-with-type-parameters
-
- - match: (?=`)
- set:
- - include: literal-string-template-custom-comments
- - include: literal-string-template-custom-lookahead
- - include: custom-templates-default
-
- - include: expression-break
-
- - include: yield-expression
- - include: await-expression
-
- - include: regexp-complete
- - include: literal-string
- - include: literal-string-template
- - include: constructor
- - include: literal-number
- - include: prefix-operators
- - include: import-meta-expression
-
- - include: class
- - include: special-name
-
- - include: regular-function
-
- - match: (?={{reserved_word}})
+ - match: '{{non_reserved_identifier}}'
+ scope: variable.other.readwrite.js
pop: true
- - match: (?={{identifier_name}}{{function_assignment_lookahead}})
+ - include: else-pop
+ jsx-tag-attributes-top:
+ - meta_scope: meta.tag.js
+ - match: /
+ scope: punctuation.definition.tag.begin.js
set:
- - function-name-meta
- - literal-variable
+ - jsx-meta-unmatched-tag
+ - jsx-expect-tag-end
+ - jsx-tag-name
- - include: object-literal
+ - match: (?=\S)
+ set:
+ - jsx-tag-attributes
+ - flow-jsx-tag-check
+ - jsx-tag-name
+ - flow-jsx-tag-check-name
- # Newline not allowed between `async` and parameters.
- - match: (?=async{{identifier_break}}{{nothing}}{{possible_arrow_function_begin}})
+ decorator-name:
+ - match: '{{identifier_name}}{{left_expression_end_lookahead}}'
+ scope: variable.annotation.js
pop: true
- branch_point: async-arrow-function
- branch:
- - async-arrow-function
- - literal-variable
-
- - include: literal-call
- - match: (?={{possible_arrow_function_begin}})
- pop: true
- branch_point: arrow-function
- branch:
- - branch-possible-arrow-function
- - arrow-function-declaration
+ shebang:
+ - meta_include_prototype: false
+ - match: ^\#!
+ scope: punctuation.definition.comment.js
+ set: shebang-body
+ - match: ^|(?=\S) # Note: Ensure to highlight shebang if the syntax is embedded.
+ pop: 1
- - include: array-literal
+ ternary-operator:
+ - match: \?(?=[^.]|\.[0-9])
+ scope: keyword.operator.ternary.js
+ set:
+ - ternary-operator-expect-colon
+ - expression-no-comma
- - include: literal-private-variable
+ flow-arrow-function-return-type-annotation:
+ - match: ':'
+ scope: punctuation.separator.type.js
+ set:
+ - flow-type-meta
+ - flow-type-end-no-arrow
+ - flow-type-begin
+ - match: (?!\s*(?:$|:|//|/\*))
+ pop: true
- - include: else-pop
+ 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
- jsdoc-comment-body:
+ line-comment-other-body:
- meta_include_prototype: false
- - meta_scope: comment.block.documentation.js
- - include: block-comment-end
- # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation
- # line so directly after the '/**' or after the '*' marker on the next lines.
- - match: ^\s*(\*)(?!/)
- captures:
- 1: punctuation.definition.comment.js
- push: jsdoc-block-tag
+ - meta_scope: comment.line.other.js
+ - include: line-comment-end
- jsx-interpolation-comment:
- - match: ({)(/\*)
+ function-call-arguments:
+ - match: ({{dot_accessor}})?(\()
captures:
- 1: punctuation.definition.interpolation.begin.js
- 2: punctuation.definition.comment.begin.js
+ 1: punctuation.accessor.js
+ 2: punctuation.section.group.begin.js
set:
- - meta_include_prototype: false
- - meta_scope: meta.interpolation.js comment.block.js
- - match: (\*/)(})
- captures:
- 1: punctuation.definition.comment.end.js
- 2: punctuation.definition.interpolation.end.js
+ - meta_scope: meta.group.js
+ - match: \)
+ scope: punctuation.section.group.end.js
pop: true
- - match: (?=\*/)
- fail: jsx-interpolation-comment
+ - include: expression-list
- declaration:
- - include: variable-declaration
- - include: class
- - include: regular-function
+ flow-type-annotation-optional:
+ - match: \?(?=:)
+ scope: storage.modifier.optional.js
+ - include: flow-type-annotation
- literal-private-variable:
+ function-declaration-expect-parameters:
+ - include: function-declaration-parameters
+ - include: else-pop
+
+ object-property-base:
+ - match: '{{dollar_only_identifier}}'
+ scope: meta.property.object.dollar.only.js punctuation.dollar.js
+ pop: true
+ - match: '{{dollar_identifier}}'
+ scope: meta.property.object.dollar.js
+ captures:
+ 1: punctuation.dollar.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: meta.property.object.js
+ pop: true
+ - match: '{{identifier_part}}+{{identifier_break}}'
+ scope: invalid.illegal.illegal-identifier.js
+ pop: true
- match: (#)({{identifier_name}})
captures:
1: punctuation.definition.variable.js
- 2: variable.other.readwrite.js
+ 2: meta.property.object.js
pop: true
- literal-string-template-custom-tags: []
- arrow-function-expect-body:
- - include: function-block
- - match: (?=\S)
- set:
- - block-meta
- - expression-no-comma
-
class-field:
- match: ''
set:
@@ -3070,241 +2765,549 @@ contexts:
- class-field-check
- field-name
- call-function-name:
- - match: '{{dollar_only_identifier}}'
- scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js
- pop: true
- - match: '{{identifier_name}}'
- scope: variable.function.js
+ for-await:
+ - match: await{{identifier_break}}
+ scope: keyword.control.flow.await.js
pop: true
- include: else-pop
- export-meta:
+ block-meta:
- meta_include_prototype: false
- - meta_scope: meta.export.js
+ - meta_scope: meta.block.js
- include: immediately-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
-
- flow-jsx-tag-check-name:
- - match: (?=(?:(?:{{jsx_identifier_part}})|\.):)
- fail: arrow-function
- - include: else-pop
+ statement:
+ - include: flow-type-declare
+ - include: flow-type-alias
- support-property-ecma-date:
- - match: (?:now|parse|UTC){{identifier_break}}
- scope: support.function.builtin.js
+ - match: \;
+ scope: punctuation.terminator.statement.empty.js
pop: true
- call-method-meta:
- - meta_include_prototype: false
- - meta_scope: meta.function-call.method.js
- - include: else-pop
-
- object-literal-element:
- - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))'
- scope: variable.other.readwrite.js
- pop: true
- - match: (?=\S)
- pop: true
- branch_point: object-literal-property
- branch:
- - object-literal-property
- - method-declaration
+ - include: declaration
+ - include: import-statement-or-import-meta
+ - include: export-statement
+ - include: conditional
+ - include: block
+ - include: label
- inherited-class-name:
- - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}'
- scope: entity.other.inherited-class.js
- pop: true
+ - match: break{{identifier_break}}
+ scope: keyword.control.flow.break.js
+ set:
+ - expect-semicolon
+ - expect-label
- flow-type-tuple:
- - match: \[
- scope: punctuation.section.brackets.begin.js
+ - match: continue{{identifier_break}}
+ scope: keyword.control.flow.continue.js
set:
- - meta_scope: meta.sequence.js
- - match: \]
- scope: punctuation.section.brackets.end.js
- pop: true
- - include: flow-type-list
+ - expect-semicolon
+ - expect-label
- 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: debugger{{identifier_break}}
+ scope: keyword.control.flow.debugger.js
+ set: expect-semicolon
- jsx-tag-name-end:
- - match: '[:.]'
- scope: punctuation.accessor.js
- push: jsx-tag-name-component
- - include: else-pop
+ - match: return{{identifier_break}}
+ scope: keyword.control.flow.return.js
+ set: restricted-production
- prefixed-method:
- - match: (?:get|set){{identifier_break}}
- scope: storage.type.accessor.js
- set:
- - meta_scope: meta.function.js
- - match: (?={{class_element_name}})
- set: method-declaration
- - match: (?=\S)
- fail: prefixed-method
- - match: (?:async){{identifier_break}}
- scope: keyword.declaration.async.js
- set:
- - meta_scope: meta.function.js
- - match: (?=\*|{{class_element_name}})
- set: method-declaration
- - match: (?=\S)
- fail: prefixed-method
+ - match: throw{{identifier_break}}
+ scope: keyword.control.flow.throw.js
+ set: restricted-production
- jsx-meta-unmatched-tag:
- - meta_include_prototype: false
- - meta_scope: invalid.illegal.unmatched-tag.js
- - include: immediately-pop
+ - include: decorator
- variable-binding-list-top:
- - match: '{{line_ending_ahead}}'
+ - include: expression-statement
+
+ jsx-interpolation-comment:
+ - match: ({)(/\*)
+ captures:
+ 1: punctuation.definition.interpolation.begin.js
+ 2: punctuation.definition.comment.begin.js
set:
- - match: '{{line_continuation_lookahead}}'
- set: variable-binding-top
- - include: else-pop
+ - meta_include_prototype: false
+ - meta_scope: meta.interpolation.js comment.block.js
+ - match: (\*/)(})
+ captures:
+ 1: punctuation.definition.comment.end.js
+ 2: punctuation.definition.interpolation.end.js
+ pop: true
+ - match: (?=\*/)
+ fail: jsx-interpolation-comment
+
+ 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: variable-binding-top
+ push:
+ - import-export-alias
+ - export-item
- include: else-pop
- left-expression-end:
- - include: expression-break
+ field-name:
+ - match: '{{dollar_identifier}}'
+ scope: meta.mapping.key.dollar.js variable.other.readwrite.js
+ captures:
+ 1: punctuation.dollar.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.other.readwrite.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_name}})
+ captures:
+ 1: punctuation.definition.variable.js
+ 2: variable.other.readwrite.js
- - match: (?=`)
- push: literal-string-template
+ - match: (?=\[)
+ push: computed-property-name
- - match: (?=(?:{{dot_accessor}})?\()
- push: function-call-arguments
+ - include: else-pop
+
+ flow-type-object:
+ - match: \{\|
+ scope: punctuation.section.block.begin.js
+ set:
+ - meta_scope: meta.type.object.exact.js
+ - match: \|\}
+ scope: punctuation.section.block.end.js
+ pop: true
+ - include: flow-type-object-contents
+
+ - 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
+
+ regular-function:
+ - match: (?={{func_lookahead}})
+ set: function-declaration
+ variable-binding-list:
+ - include: comma-separator
+ - match: (?={{binding_pattern_lookahead}})
+ push:
+ - initializer
+ - variable-binding-pattern
+ - include: else-pop
+
+ constructor-body-expect-class-end:
- include: property-access
+ - include: else-pop
+
+ jsx-interpolation-plain:
+ - match: '{'
+ scope: punctuation.definition.interpolation.begin.js
+ set:
+ - - meta_scope: meta.interpolation.js
+ - meta_content_scope: source.js.embedded.jsx
+ - match: '}'
+ scope: punctuation.definition.interpolation.end.js
+ pop: true
+ - expression
+
+ support-property-ecma-proxy:
+ - match: revocable{{identifier_break}}
+ scope: support.function.builtin.js
+ pop: true
+
+ 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
- for-condition-end:
- - meta_scope: meta.group.js
+ arrow-function-expect-arrow-or-fail-async:
+ - match: =>
+ scope: keyword.declaration.function.arrow.js
+ pop: true
+ - match: (?=\S)
+ fail: async-arrow-function
- - match: \)
- scope: punctuation.section.group.js
+ decorator-expression-begin:
+ - include: decorator-name
+ - include: expression-begin
+
+ flow-type-object-indexer-label:
+ - match: ({{non_reserved_identifier}})\s*(:)
+ captures:
+ 1: meta.object-literal.key.js
+ 2: punctuation.separator.key-value.js
pop: true
+ - include: else-pop
-scope: source.js
-first_line_match: ^#!\s*/.*\b(node|js)\b
-variables:
- identifier_escape: (?:\\u(?:\h{4}|\{\h+\}))
- property_name: >-
- (?x:
- {{identifier_name}}
- | [0-9]+
- | '(?:[^\\']|\\.)*'
- | "(?:[^\\"]|\\.)*"
- | \[ .* \]
- )
- identifier_break: (?!{{identifier_part}})
- left_expression_end_lookahead: (?!\s*[.\[\(])
- function_assignment_lookahead: |-
- (?x:(?=
- \s* = \s*
- {{either_func_lookahead}}
- ))
- line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$)
- constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}})
- identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}})
- dollar_only_identifier: (?:\${{identifier_break}})
- identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}})
- dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*'
- dec_integer: (?:0|[1-9]{{dec_digit}}*)
- bin_digit: '[01_]'
- jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}'
- dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}})
- block_comment_contents: (?:(?:[^*]|\*(?!/))*)
- binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{)
- jsx_identifier_part: (?:{{identifier_part}}|-)
- method_lookahead: |-
- (?x)(?=
- (?: get|set|async ){{identifier_break}}(?!\s*:)
- | \*
- | {{property_name}} \s* (?:\(|<)
- )
- func_lookahead: |-
- (?x:
- (?:async{{identifier_break}}{{nothing}})?
- function{{identifier_break}}
- )
- oct_digit: '[0-7_]'
- either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}})
- line_continuation_lookahead: >-
- (?x:(?=
- (?! \+\+ | -- )
- (?=
- != |
- [-+*/%><=&|^\[(;,.:?] |
- (?:in|instanceof){{identifier_break}}
- )
- ))
- jsdoc_block_tag: \@[^\n\t\f\v *@]+
- jsx_identifier_break: (?!{{jsx_identifier_part}})
- identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}})
- class_element_name: |-
- (?x:
- \+?
- (?:
- \*?
- {{property_name}}
- | \#{{non_reserved_identifier}}
- )
- )
- modifier: (?:static{{identifier_break}})
- hex_digit: '[\h_]'
- reserved_word: |-
- (?x:
- break|case|catch|class|const|continue|debugger|default|delete|do|else|
- export|extends|finally|for|function|if|import|in|instanceof|new|return|
- super|switch|this|throw|try|typeof|var|void|while|with|yield|
- enum|
- null|true|false
- ){{identifier_break}}
- nothing: (?x:(?:\s|{{block_comment}})*)
- possible_arrow_function_begin: (?:\(|{{identifier_start}}|<)
- arrow_func_lookahead: |-
- (?x)(?:
- \s*(async\s*)?
- (?:
- {{non_reserved_identifier}}
- |\( (?: [^()]|\([^()]*\) )* \)
- )
- (?:
- \s*:
- \s*{{non_reserved_identifier}}
- )?
- \s*=>
- )
- dec_digit: '[0-9_]'
- function_call_lookahead: >-
- (?x:(?=
- {{identifier_name}}
- \s*
- (?:
- <
- .*
- >
- \s*
- )?
- (?:{{dot_accessor}})?
- \(
- ))
- block_comment: (?:/\*{{block_comment_contents}}\*/)
- non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}})
- dot_accessor: (?:\??\.)
+ literal-string-template-custom-lookahead: []
+ function-parameter:
+ - match: ''
+ set:
+ - initializer
+ - function-parameter-binding-pattern
+
+ literal-string:
+ - match: "'"
+ scope: punctuation.definition.string.begin.js
+ set:
+ - meta_include_prototype: false
+ - meta_scope: meta.string.js string.quoted.single.js
+ - match: \'
+ scope: punctuation.definition.string.end.js
+ pop: true
+ - match: \n
+ scope: invalid.illegal.newline.js
+ pop: true
+ - include: string-content
+ - match: '"'
+ scope: punctuation.definition.string.begin.js
+ set:
+ - meta_include_prototype: false
+ - meta_scope: meta.string.js string.quoted.double.js
+ - match: \"
+ scope: punctuation.definition.string.end.js
+ pop: true
+ - match: \n
+ scope: invalid.illegal.newline.js
+ pop: true
+ - include: string-content
+
+ while-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.while.js
+ - include: immediately-pop
+
+ flow-detect-arrow-function-return-type:
+ - match: (?=:)
+ pop: true
+ branch_point: flow-arrow-function-return-type
+ branch:
+ - flow-arrow-return-type
+ - immediately-pop
+ - include: else-pop
+
+ main:
+ - meta_include_prototype: false # don't match comments before shebang
+ - match: ''
+ push: [script, shebang]
+
+ function-parameter-binding-spread:
+ - match: \.\.\.
+ scope: keyword.operator.spread.js
+ push: function-parameter
+
+ flow-type-module-contents:
+ - match: \}
+ scope: punctuation.section.block.end.js
+ pop: true
+ - include: main
+
+ switch-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.switch.js
+ - include: immediately-pop
+
+ flow-type-operators:
+ - match: \|(?!\})
+ scope: keyword.operator.type.union.js
+ push: flow-type-begin
+ - match: \&
+ scope: keyword.operator.type.intersection.js
+ push: flow-type-begin
+ - match: =>
+ scope: keyword.declaration.function.arrow.js
+ push: flow-type-begin
+ - match: \?
+ scope: storage.modifier.maybe.js
+ push: flow-type-begin
+ - match: \.
+ scope: punctuation.separator.accessor.js
+ push: flow-type-begin
+
+ - match: \[\]
+ scope: storage.modifier.array.js
+ - match: '%checks{{identifier_break}}'
+ scope: storage.modifier.checks.js
+
+ inherited-class-name:
+ - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}'
+ scope: entity.other.inherited-class.js
+ pop: true
+
+ variable-binding-object-key:
+ - match: '{{identifier_name}}(?=\s*:)'
+ scope: string.unquoted.js
+ pop: true
+ - match: '{{identifier_name}}(?=\s*:)'
+ pop: true
+ - include: literal-string
+ - include: computed-property-name
+ - include: variable-binding-name
+ - include: else-pop
+
+ import-export-alias:
+ - match: as{{identifier_break}}
+ scope: keyword.control.import-export.js
+ set:
+ - match: default{{identifier_break}}
+ scope: keyword.control.import-export.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.other.readwrite.js
+ pop: true
+ - include: else-pop
+ - include: else-pop
+
+ comments:
+ - include: line-comments
+ - include: block-comments
+
+ special-name:
+ - match: true{{identifier_break}}
+ scope: constant.language.boolean.true.js
+ pop: true
+ - match: false{{identifier_break}}
+ scope: constant.language.boolean.false.js
+ pop: true
+ - match: null{{identifier_break}}
+ scope: constant.language.null.js
+ pop: true
+ - match: super{{identifier_break}}
+ scope: variable.language.super.js
+ pop: true
+ - match: this{{identifier_break}}
+ scope: variable.language.this.js
+ pop: true
+
+ arrow-function-declaration:
+ - meta_include_prototype: false
+ - match: ''
+ set:
+ - function-meta
+ - arrow-function-expect-body
+ - arrow-function-expect-arrow
+ - flow-arrow-function-return-type-annotation
+ - arrow-function-expect-parameters
+ - flow-type-generic-parameters
+
+ 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
+
+ flow-type-declare-export:
+ - match: default{{identifier_break}}
+ scope: keyword.control.import-export.js
+ set: flow-type
+ - match: (?=\S)
+ pop: true
+
+ switch-block:
+ - match: \{
+ scope: punctuation.section.block.begin.js
+ set: switch-block-contents
+ - include: else-pop
+
+ with-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.with.js
+ - include: immediately-pop
+
+ flow-type-function:
+ - match: \(
+ scope: punctuation.section.grouping.begin.js
+ set:
+ - meta_scope: meta.group.js
+ - match: \)
+ scope: punctuation.section.grouping.end.js
+ pop: true
+ - include: flow-type-list
+
+ flow-arrow-function-declaration-with-type-parameters: []
+ 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
+
+ computed-property-name:
+ - match: \[
+ scope: punctuation.section.brackets.begin.js
+ set:
+ - match: \]
+ scope: punctuation.section.brackets.end.js
+ pop: true
+ - match: (?=\S)
+ push: expression
+
+ 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_start}}|\[|'|")
+ push:
+ - initializer
+ - function-parameter-binding-object-alias
+ - object-literal-meta-key
+ - function-parameter-binding-object-key
+
+ constructor-body-expect-class-begin:
+ - match: (?={{non_reserved_identifier}}\s*\()
+ set:
+ - include: support
+ - match: '{{dollar_only_identifier}}'
+ scope: variable.type.dollar.only.js punctuation.dollar.js
+ pop: true
+ - match: '{{dollar_identifier}}'
+ scope: variable.type.dollar.js
+ captures:
+ 1: punctuation.dollar.js
+ pop: true
+ - match: '{{identifier_name}}'
+ scope: variable.type.js
+ pop: true
+ - include: else-pop
+
+ - include: expression-begin
+
+ 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-expect-parameters
+
+ - match: (?=static{{identifier_break}})
+ branch_point: static-block
+ branch:
+ - static-block
+ - class-element-modifiers
+
+ - match: (?={{modifier}})
+ push: class-element-modifiers
+
+ - match: |-
+ (?x)(?=
+ \#? {{identifier_name}}
+ \s* = \s*
+ {{either_func_lookahead}}
+ )
+ push:
+ - initializer
+ - function-name-meta
+ - literal-variable-base
+
+ - match: (?=(?:get|set|async){{identifier_break}})
+ branch_point: prefixed-method
+ branch:
+ - prefixed-method
+ - class-element
+
+ - match: (?=\*)
+ push: method-declaration
+
+ - match: (?={{class_element_name}})
+ push: class-element
+
+ import-meta:
+ - meta_include_prototype: false
+ - meta_scope: meta.import.js
+ - include: immediately-pop
+
+ initializer:
+ - match: '='
+ scope: keyword.operator.assignment.js
+ set: expression-no-comma
+ - include: else-pop
+
+first_line_match: |-
+ (?xi:
+ ^ \s* // .*? -\*- .*? \bjsx\b .*? -\*- # editorconfig
+ )
+version: 2
diff --git a/tests/syntax_test_js.js b/tests/syntax_test_js.js
index 73e67b5..5c88a76 100644
--- a/tests/syntax_test_js.js
+++ b/tests/syntax_test_js.js
@@ -73,10 +73,6 @@
// ^^^^ comment.block.documentation.js
// ^ - comment
-///
-// <- comment.line.triple-slash.js punctuation.definition.comment.js
-//^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor
-
////
// <- comment.line.other.js punctuation.definition.comment.js
//^^^^^^^^^^^^^^^^^^^^ comment.line.other.js - meta.preprocessor
diff --git a/tests/syntax_test_js_not_typescript.js b/tests/syntax_test_js_not_typescript.js
new file mode 100644
index 0000000..084a0da
--- /dev/null
+++ b/tests/syntax_test_js_not_typescript.js
@@ -0,0 +1,5 @@
+// SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax"
+
+///
+// <- comment.line.triple-slash.js punctuation.definition.comment.js
+//^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor
diff --git a/tests/syntax_test_jsx.jsx b/tests/syntax_test_jsx.jsx
index f454b70..8b76dcf 100644
--- a/tests/syntax_test_jsx.jsx
+++ b/tests/syntax_test_jsx.jsx
@@ -73,10 +73,6 @@
// ^^^^ comment.block.documentation.js
// ^ - comment
-///
-// <- comment.line.triple-slash.js punctuation.definition.comment.js
-//^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor
-
////
// <- comment.line.other.js punctuation.definition.comment.js
//^^^^^^^^^^^^^^^^^^^^ comment.line.other.js - meta.preprocessor