diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax index 6fd3bbd..5ee56d1 100644 --- a/JavaScript (Babel).sublime-syntax +++ b/JavaScript (Babel).sublime-syntax @@ -1,77 +1,210 @@ %YAML 1.2 --- -version: 2 +name: JavaScript (Babel) contexts: - object-literal-property-check: - - match: (?=\() - fail: object-literal-property - - include: else-pop + parenthesized-expression: + - match: \( + scope: punctuation.section.group.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - match: (?=:) + push: flow-type-annotation + - match: (?=\S) + push: expression - line-comment-triple-slash-body: + expression-end-no-comma: + - match: (?=,) + pop: true + - include: expression-end + + export-statement: + - match: export{{identifier_break}} + scope: keyword.control.import-export.js + set: + - export-meta + - export-extended + + immediately-pop-2: - meta_include_prototype: false - - meta_scope: comment.line.triple-slash.js + - match: '' + pop: 2 + + line-comment-double-slash-body: + - meta_include_prototype: false + - meta_scope: comment.line.double-slash.js - include: line-comment-end - arrow-function-expect-body: - - include: function-block - - match: (?=\S) + function-parameter-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + pop: true + - include: literal-string + - include: computed-property-name + - include: function-parameter-binding-name + - include: else-pop + + import-export-alias: + - match: as{{identifier_break}} + scope: keyword.control.import-export.js set: - - block-meta - - expression-no-comma + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + pop: true + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + pop: true + - include: else-pop + - include: else-pop - flow-detect-arrow-after-return-type: - - match: (?==>) - fail: arrow-function - - match: (?=\S) - fail: flow-arrow-function-return-type + 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 - object-literal-element: - - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' + support: + - include: support-variable-ecma + - include: support-variable-console + - include: support-variable-dom + - include: support-variable-node + + 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-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 + + catch-meta: + - meta_include_prototype: false + - meta_scope: meta.catch.js + - include: immediately-pop + + flow-type-list: + - include: comma-separator - match: (?=\S) - pop: true - branch_point: object-literal-property - branch: - - object-literal-property - - method-declaration + push: flow-type - variable-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: variable-binding-pattern + ternary-operator: + - match: \?(?=[^.]|\.[0-9]) + scope: keyword.operator.ternary.js + set: + - ternary-operator-expect-colon + - expression-no-comma - 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 + expect-semicolon: + - match: \; + scope: punctuation.terminator.statement.js + pop: true + - include: else-pop - variable-binding-pattern: - - match: '' + flow-type-generic-parameters: + - match: < + scope: punctuation.definition.generic.begin.js set: - - - include: flow-type-annotation - - - include: variable-binding-name - - include: variable-binding-array-destructuring - - include: variable-binding-object-destructuring - - include: else-pop + - 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-name-meta: - - meta_include_prototype: false - - meta_scope: entity.name.function.js - - include: immediately-pop + call-function-name: + - match: '{{dollar_only_identifier}}' + scope: variable.function.js variable.other.dollar.only.js punctuation.dollar.js + pop: true + - match: '{{identifier_name}}' + scope: variable.function.js + pop: true + - include: else-pop - literal-string: + support-property-ecma-promise: + - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} + scope: support.function.builtin.js + pop: true + + 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: + - import-export-alias + - import-item + - include: else-pop + + 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 @@ -84,6 +217,7 @@ contexts: 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 @@ -91,126 +225,122 @@ contexts: scope: invalid.illegal.newline.js pop: true - include: string-content + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js - 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 + - match: (?=\[) + push: computed-property-name - 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 - - support-property-ecma-promise: - - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} - scope: support.function.builtin.js - pop: true + - include: else-pop - static-block: - - match: static{{identifier_break}} - scope: storage.modifier.js + variable-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - match: \{ - scope: punctuation.section.block.begin.js - set: static-block-body - - match: (?=\S) - fail: static-block + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: variable-binding-spread + - include: variable-binding-list - for-condition: - - match: \( - scope: punctuation.section.group.js + import-statement: + - match: import{{identifier_break}} + scope: keyword.control.import-export.js set: - - for-condition-end - - for-condition-contents - - 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 + - import-meta + - expect-semicolon + - import-string-or-items + - import-check-branch - - match: \[\] - scope: storage.modifier.array.js - - match: '%checks{{identifier_break}}' - scope: storage.modifier.checks.js + class-element: + - match: '' + pop: true + branch_point: class-field + branch: + - class-field + - method-declaration - parenthesized-expression: - - match: \( - scope: punctuation.section.group.begin.js - set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - - match: (?=:) - push: flow-type-annotation - - match: (?=\S) - push: expression + decorator-expression-begin: + - include: decorator-name + - include: expression-begin - line-comment-other-body: + try-meta: - meta_include_prototype: false - - meta_scope: comment.line.other.js - - include: line-comment-end + - meta_scope: meta.try.js + - include: immediately-pop - flow-type-declare: - - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) - scope: keyword.declaration.js + expression-end-no-in: + - match: (?=in{{identifier_break}}) + pop: true + - include: expression-end + + flow-type-alias: + - match: (?=type{{identifier_break}}) set: - - match: opaque{{identifier_break}} - scope: storage.modifier.js - pop: true - - match: module{{identifier_break}} - scope: keyword.declaration.js - set: - - flow-type-module-meta - - flow-type-module-body - - flow-type-module-name - - match: export{{identifier_break}} - scope: keyword.declaration.js - set: flow-type-declare-export - - include: else-pop + - - 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 - computed-property-name: - - match: \[ - scope: punctuation.section.brackets.begin.js + - 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 + + for-oldstyle-rest: + - match: (?=\)) + pop: true + - match: ; + scope: punctuation.separator.expression.js + - match: (?=\S) + push: expression + + flow-arrow-function-declaration-with-type-parameters: [] + expression-list: + - include: expression-break + - include: comma-separator + - match: (?=\S) + push: expression-no-comma + + 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 + + variable-declaration: + - match: (?:const|let|var){{identifier_break}} + scope: keyword.declaration.js set: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - match: (?=\S) - push: expression + - expect-semicolon + - variable-binding-list-top + - variable-binding-top - prefixed-method: + prefixed-object-literal-method: - match: (?:get|set){{identifier_break}} scope: storage.type.accessor.js set: @@ -218,7 +348,7 @@ contexts: - match: (?={{class_element_name}}) set: method-declaration - match: (?=\S) - fail: prefixed-method + fail: prefixed-object-literal-method - match: (?:async){{identifier_break}} scope: keyword.declaration.async.js set: @@ -226,549 +356,670 @@ contexts: - match: (?=\*|{{class_element_name}}) set: method-declaration - match: (?=\S) - fail: prefixed-method + fail: prefixed-object-literal-method - 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 + do-while-condition: + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: parenthesized-expression + - include: else-pop - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() + support-variable-ecma: + - match: Array{{identifier_break}} + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - call-method-meta - - function-call-arguments - - call-path - - object-property - - include: object-property + - include: support-property-ecma-array + - include: object-property + - include: else-pop + - include: else-pop - variable-binding-top: - - match: (?={{binding_pattern_lookahead}}) + - match: ArrayBuffer{{identifier_break}} + scope: support.class.builtin.js set: - - initializer - - variable-binding-pattern - - include: else-pop - - export-meta: - - meta_include_prototype: false - - meta_scope: meta.export.js - - include: immediately-pop - - literal-string-template-custom-lookahead: [] - flow-type-meta: - - meta_scope: meta.flow-type.js - - include: immediately-pop + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-arraybuffer + - include: object-property + - include: else-pop + - include: else-pop - expression-statement: - - match: (?=\S) + - match: Atomics{{identifier_break}} + scope: support.constant.builtin.js set: - - expect-semicolon - - expression-statement-end - - expression-begin - - conditional: - - match: switch{{identifier_break}} - scope: keyword.control.conditional.switch.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: - - switch-meta - - switch-block - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-bigint + - include: object-property + - include: else-pop + - include: else-pop - - match: do{{identifier_break}} - scope: keyword.control.loop.do-while.js + - match: Date{{identifier_break}} + scope: support.class.builtin.js set: - - do-while-meta - - do-while-condition - - statement + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-date + - include: object-property + - include: else-pop + - include: else-pop - - match: for{{identifier_break}} - scope: keyword.control.loop.for.js + - match: JSON{{identifier_break}} + scope: support.constant.builtin.js set: - - for-meta - - block-scope - - for-condition - - for-await + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-json + - include: object-property + - include: else-pop + - include: else-pop - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js + - match: Math{{identifier_break}} + scope: support.constant.builtin.js set: - - while-meta - - block-scope - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-math + - include: object-property + - include: else-pop + - include: else-pop - - match: with{{identifier_break}} - scope: keyword.control.import.with.js + - match: Number{{identifier_break}} + scope: support.class.builtin.js set: - - with-meta - - block-scope - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-number + - include: object-property + - include: else-pop + - include: else-pop - - match: if{{identifier_break}} - scope: keyword.control.conditional.if.js + - match: Object{{identifier_break}} + scope: support.class.builtin.js set: - - conditional-meta - - statement - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-object + - include: object-property + - include: else-pop + - include: else-pop - - match: else\s+if{{identifier_break}} - scope: keyword.control.conditional.elseif.js + - match: Promise{{identifier_break}} + scope: support.class.builtin.js set: - - conditional-meta - - statement - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-promise + - include: object-property + - include: else-pop + - include: else-pop - - match: else{{identifier_break}} - scope: keyword.control.conditional.else.js + - match: Proxy{{identifier_break}} + scope: support.class.builtin.js set: - - conditional-meta - - statement + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-proxy + - include: object-property + - include: else-pop + - include: else-pop - - match: try{{identifier_break}} - scope: keyword.control.exception.try.js + - match: Reflect{{identifier_break}} + scope: support.constant.builtin.js set: - - try-meta - - block-scope + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-reflect + - include: object-property + - include: else-pop + - include: else-pop - - match: finally{{identifier_break}} - scope: keyword.control.exception.finally.js + - match: String{{identifier_break}} + scope: support.class.builtin.js set: - - finally-meta - - block-scope + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-string + - include: object-property + - include: else-pop + - include: else-pop - - match: catch{{identifier_break}} - scope: keyword.control.exception.catch.js + - match: Symbol{{identifier_break}} + scope: support.class.builtin.js set: - - catch-meta - - block-scope - - expect-parenthesized-expression + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-symbol + - include: object-property + - include: else-pop + - 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 + (?: + BigInt64| + BigUint64| + Float(?:32|64)| + Int(?:8|16|32)| + Uint(?:8|16|32|32Clamped) + ) + Array{{identifier_break}} + ) + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-typedarray + - include: object-property + - include: else-pop + - include: else-pop - - 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 + # Classes with no constructor properties + - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} + scope: support.class.builtin.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 + - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} + scope: support.class.builtin.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 + - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + scope: support.function.js pop: true - # illegal numbers - - match: 0[Xx]{{identifier_part}}+ - scope: invalid.illegal.numeric.hexadecimal.js - pop: true + finally-meta: + - meta_include_prototype: false + - meta_scope: meta.finally.js + - include: immediately-pop - - match: 0[Bb]{{identifier_part}}+ - scope: invalid.illegal.numeric.binary.js + support-property-ecma-string: + - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: 0{{identifier_part}}+ - scope: invalid.illegal.numeric.octal.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 - - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' - scope: invalid.illegal.numeric.decimal.js - pop: true + class-field: + - match: '' + set: + - initializer + - flow-type-annotation + - class-field-check + - field-name - variable-binding-object-alias: + ternary-operator-expect-colon: - match: ':' - scope: punctuation.separator.key-value.js - set: variable-binding-pattern + scope: keyword.operator.ternary.js + set: expression-no-comma - include: else-pop - flow-type-module-contents: - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: main - - decorator: - - match: '@' - scope: punctuation.definition.annotation.js - push: - - decorator-meta - - decorator-expression-end - - decorator-expression-begin + call-function-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.js + - include: else-pop - catch-meta: + line-comment-triple-slash-body: - meta_include_prototype: false - - meta_scope: meta.catch.js - - include: immediately-pop + - meta_scope: comment.line.triple-slash.js + - include: line-comment-end - flow-type-alias: - - match: (?=type{{identifier_break}}) + jsx-interpolation-plain: + - match: '{' + scope: punctuation.definition.interpolation.begin.js 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 + - - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded.jsx + - match: '}' + scope: punctuation.definition.interpolation.end.js + pop: true + - expression - - 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 + 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 + regexp-complete: + - match: / + scope: punctuation.definition.string.begin.js + set: regexp - support-property-ecma-array: - - match: (?:from|isArray|of){{identifier_break}} - scope: support.function.builtin.js - pop: true + import-brace: + - include: flow-type-import-type - class-body-contents: - 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 + + block-comment-end: + - match: \*+/ + scope: punctuation.definition.comment.end.js + pop: true - - match: \; - scope: punctuation.terminator.statement.js + flow-type-end-no-arrow: + - match: (?==>) + pop: true + - include: flow-type-end - - include: decorator + inherited-class-expression-begin: + - include: inherited-class-name + - include: expression-begin - - match: constructor{{identifier_break}} - scope: entity.name.function.constructor.js - push: + flow-function-type-arguments-or-less-than: + - match: (?=<(?![<=])) + branch_point: flow-function-type-arguments + branch: + - flow-function-type-arguments + - flow-less-than + + function-declaration: + - match: '' + set: - function-meta - function-declaration-expect-body + - flow-type-annotation - function-declaration-expect-parameters + - flow-type-generic-parameters + - function-declaration-expect-name + - function-declaration-expect-generator-star + - function-declaration-expect-function-keyword + - function-declaration-expect-async - - match: (?=static{{identifier_break}}) - branch_point: static-block - branch: - - static-block - - class-element-modifiers + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop - - match: (?={{modifier}}) - push: class-element-modifiers + object-literal-property-check: + - match: (?=\() + fail: object-literal-property + - include: else-pop - - match: |- - (?x)(?= - \#? {{identifier_name}} - \s* = \s* - {{either_func_lookahead}} - ) - push: - - initializer - - function-name-meta - - literal-variable-base + flow-type-module-name: + - include: literal-string + - match: '{{non_reserved_identifier}}' + scope: entity.name.module.js + pop: true + - include: else-pop - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-method - branch: - - prefixed-method - - class-element + restricted-production: + - meta_include_prototype: false + - match: '{{line_ending_ahead}}' + pop: true + - match: '' + set: expression-statement - - match: (?=\*) - push: method-declaration + 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: (?={{class_element_name}}) - push: class-element + - match: \[\] + scope: storage.modifier.array.js + - match: '%checks{{identifier_break}}' + scope: storage.modifier.checks.js - flow-type-import-type: - - match: type{{identifier_break}} - scope: keyword.declaration.js + variable-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: variable-binding-pattern - - match: typeof{{identifier_break}} - scope: keyword.operator.js + 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 - decorator-name: - - match: '{{identifier_name}}{{left_expression_end_lookahead}}' - scope: variable.annotation.js + flow-type-special: + - match: any{{identifier_break}} + scope: support.type.any.js pop: true - flow-type-declare-export: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: flow-type - - match: (?=\S) + - match: mixed{{identifier_break}} + scope: support.type.mixed.js pop: true - ternary-operator: - - match: \?(?=[^.]|\.[0-9]) - scope: keyword.operator.ternary.js - set: - - ternary-operator-expect-colon - - expression-no-comma - - call-method-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.method.js + jsx-tag-name-end: + - match: '[:.]' + scope: punctuation.accessor.js + push: jsx-tag-name-component - include: else-pop - import-string-or-items: - - include: literal-string - - match: (?=\S) + flow-type-object: + - match: \{\| + scope: punctuation.section.block.begin.js set: - - import-export-from - - import-list - - import-export-alias - - import-item - - 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 - - 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 - - expression-end-no-comma: - - match: (?=,) - pop: true - - include: expression-end - - import-item: - - include: flow-type-import-type + - 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: import-brace - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js - pop: true - - match: \* - scope: constant.other.js - pop: true - - include: else-pop + set: + - meta_scope: meta.type.object.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: flow-type-object-contents - flow-type-object-value: - - match: (\?)?(:) - captures: - 1: storage.modifier.optional.js - 2: punctuation.separator.key-value.js - set: flow-type - - include: else-pop + object-literal-contents: + - meta_scope: meta.mapping.js - inherited-class-expression-end: - - include: flow-type-generic-arguments + - match: \} + scope: punctuation.section.block.end.js + pop: true - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js + - match: \.\.\. + scope: keyword.operator.spread.js + push: expression-no-comma + + - match: >- + (?x)(?= + {{property_name}}\s*:\s* + {{either_func_lookahead}} + ) push: - - include: inherited-class-name - - include: object-property + - object-literal-meta-key + - method-name - - include: left-expression-end + - match: (?=\*) + push: method-declaration - flow-arrow-function-declaration-with-type-parameters: [] - export-extended: - - include: flow-type-export-type + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-object-literal-method + branch: + - prefixed-object-literal-method + - object-literal-element - - include: declaration + - match: (?={{property_name}}) + push: object-literal-element - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: - - include: declaration - - match: (?=\S) - set: expression-statement + - include: comma-separator + + - match: ':' + scope: punctuation.separator.key-value.js + push: expression-no-comma + # If there's any garbage, parse it as an expression + # so that close braces won't break things. - match: (?=\S) - set: - - expect-semicolon - - import-export-from - - export-list - - import-export-alias - - export-item + push: expression-no-comma - 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 + flow-type-primitive: + - match: boolean{{identifier_break}} + scope: support.type.primitive.boolean.js + pop: true - array-literal: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: expression-list + - match: number{{identifier_break}} + scope: support.type.primitive.number.js + pop: true - finally-meta: - - meta_include_prototype: false - - meta_scope: meta.finally.js - - include: immediately-pop + - match: string{{identifier_break}} + scope: support.type.primitive.string.js + pop: true - async-arrow-function: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow-or-fail-async - - arrow-function-expect-parameters + - match: null{{identifier_break}} + scope: support.type.primitive.null.js + pop: true - constructor-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.constructor.js - - include: immediately-pop + - match: void{{identifier_break}} + scope: support.type.primitive.void.js + pop: true - switch-block: - - match: \{ - scope: punctuation.section.block.begin.js - set: switch-block-contents + 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 + + object-literal-meta-key: + - meta_scope: meta.mapping.key.js - include: else-pop - jsx-tag-name-component: - - match: '{{jsx_identifier}}' - scope: entity.name.tag.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 - flow-type-literal: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js + - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} + scope: support.function.js pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js + + # Annex B + - match: __proto__{{identifier_break}} + scope: invalid.deprecated.js variable.language.prototype.js + pop: true + - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} + scope: invalid.deprecated.js support.function.js pop: true - - match: (?=\d) - set: - - - match: '{{identifier_part}}+' - scope: invalid.illegal.js - - include: immediately-pop - - literal-number - - match: (?=['"]) - set: literal-string - switch-meta: + export-meta: - meta_include_prototype: false - - meta_scope: meta.switch.js + - meta_scope: meta.export.js - include: immediately-pop - variable-binding-list: - - include: comma-separator - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer - - variable-binding-pattern - - include: else-pop - - flow-type-end-no-arrow: - - match: (?==>) - pop: true - - include: flow-type-end + 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 - declaration: - - include: variable-declaration - - include: class - - include: regular-function + jsx-meta: + - meta_include_prototype: false + - meta_scope: meta.jsx.js + - include: immediately-pop - import-export-from: - - match: from{{identifier_break}} - scope: keyword.control.import-export.js - set: literal-string - - include: else-pop + block-comment-body: + - meta_include_prototype: false + - meta_scope: comment.block.js + - include: block-comment-end - comments: - - include: line-comments - - include: block-comments + 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: + - 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 - inherited-class-expression-begin: - - include: inherited-class-name - - include: expression-begin + - match: (?=\[) + push: computed-property-name - class: - - match: class{{identifier_break}} - scope: keyword.declaration.class.js + - include: else-pop + + support-property-ecma-array: + - match: (?:from|isArray|of){{identifier_break}} + scope: support.function.builtin.js + pop: true + + variable-binding-list-top: + - match: '{{line_ending_ahead}}' set: - - class-meta - - class-body - - class-extends - - class-name + - match: '{{line_continuation_lookahead}}' + set: variable-binding-top + - include: else-pop + - match: ',' + scope: punctuation.separator.comma.js + push: variable-binding-top + - include: else-pop - 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-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 - immediately-pop-2: + method-declaration: - meta_include_prototype: false - match: '' - pop: 2 + set: + - function-meta + - function-declaration-expect-body + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - method-name + - method-declaration-expect-asterisk + + class-element-modifier: + - match: '{{modifier}}' + scope: storage.modifier.js + set: + - match: (?={{class_element_name}}|\*) + pop: true + - match: (?=\S) + fail: class-element-modifier + + styled-component-begin: + - match: '{{non_reserved_identifier}}(?=\s*\()' + scope: variable.function.js + pop: true + + - match: '{{non_reserved_identifier}}(?=\s*[`<])' + scope: variable.function.tagged-template.js + pop: true + + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: true - constructor-body-expect-class-end: - - include: property-access + - include: else-pop + call-method-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.method.js - include: else-pop statement: @@ -814,38 +1065,95 @@ contexts: - include: expression-statement - class-meta: - - meta_include_prototype: false - - meta_scope: meta.class.js - - include: immediately-pop - - support-property-ecma-arraybuffer: - - match: isView{{identifier_break}} - scope: support.function.builtin.js - pop: true - - 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 + export-item: + - match: \{ + scope: punctuation.section.block.begin.js + set: export-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js pop: true - - match: this{{identifier_break}} - scope: variable.language.this.js + - match: \* + scope: constant.other.js pop: true + - include: else-pop - expression-list: - - include: expression-break - - include: comma-separator - - match: (?=\S) - push: expression-no-comma + 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 + + expression-statement-end: + - match: '{{line_ending_ahead}}' + set: + - match: '{{line_continuation_lookahead}}' + set: expression-statement-end + - include: else-pop + - include: expression-end string-content: - match: \\\n @@ -853,86 +1161,198 @@ contexts: - match: \\(?:x\h\h|u\h\h\h\h|.) scope: constant.character.escape.js - styled-component-end: - - match: \. - scope: punctuation.accessor.dot.js - push: styled-component-begin + builtin-console-properties: + - match: (?:warn|info|log|error|time|timeEnd|assert|count|dir|group|groupCollapsed|groupEnd|profile|profileEnd|table|trace|timeStamp){{identifier_break}} + scope: support.function.console.js + pop: true + - include: object-property - - match: (?=`) + flow-type-end: + - match: (?=\|\||&&) + fail: flow-function-type-arguments + - include: flow-type-operators + - include: flow-type-generic-arguments + - include: else-pop + + function-parameter-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: function-parameter + + function-parameter-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - match: '`' - scope: string.quoted.other.js punctuation.definition.string.begin.js - push: - - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - include: immediately-pop - - - 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 + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: function-parameter-binding-list - flow-type-begin: - - include: flow-type-existential - - include: flow-type-literal - - include: flow-type-special - - include: flow-type-primitive - - include: flow-type-utility - - include: flow-type-typeof - - include: flow-type-class - - include: flow-type-function - - include: flow-type-tuple - - include: flow-type-object + computed-property-name: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - match: (?=\S) + push: expression + + 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 - flow-type-end: - - include: flow-type-operators - - include: flow-type-generic-arguments + flow-jsx-tag-check: + - match: (?=[:,]) + fail: arrow-function + - include: else-pop + call-path: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: object-property - include: else-pop - import-brace: - - include: flow-type-import-type + expect-parenthesized-expression: + - include: parenthesized-expression + - include: else-pop - - meta_scope: meta.block.js - - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js + flow-type-class: + - match: '{{non_reserved_identifier}}' + scope: variable.other.class.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 - for-meta: + block-meta: - meta_include_prototype: false - - meta_scope: meta.for.js + - meta_scope: meta.block.js - include: immediately-pop + class-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.class.js + set: flow-type-generic-parameters + - include: else-pop + + literal-string-template-custom-comments: [] + function-declaration-expect-function-keyword: + - match: function{{identifier_break}} + scope: keyword.declaration.function.js + pop: true + - include: else-pop + + script: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + # Don't pop or embedding could break. + + - include: statements + + decorator: + - match: '@' + scope: punctuation.definition.annotation.js + push: + - decorator-meta + - decorator-expression-end + - decorator-expression-begin + + 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 + + import-export-from: + - match: from{{identifier_break}} + scope: keyword.control.import-export.js + set: literal-string + - include: else-pop + branch-possible-arrow-function: - match: (?=<) set: jsx-tag @@ -953,83 +1373,21 @@ contexts: - detect-arrow - literal-variable - flow-type-generic-arguments: - - match: < - scope: punctuation.definition.generic.begin.js + block: + - match: \{ + scope: punctuation.section.block.begin.js set: - - meta_scope: meta.generic.js - - match: '>' - scope: punctuation.definition.generic.end.js + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js pop: true - - include: flow-type-list + - include: statements - import-expression-end: - - match: (?=\() - set: function-call-arguments - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - match: meta{{identifier_break}} - scope: variable.language.import.js - pop: true - - include: object-property - - include: else-pop - 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 - - 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 - - support-property-ecma-proxy: - - match: revocable{{identifier_break}} - scope: support.function.builtin.js - pop: true - - literal-private-variable: - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js - pop: true - - class-element-modifier: - - match: '{{modifier}}' - scope: storage.modifier.js - set: - - match: (?={{class_element_name}}|\*) - pop: true - - match: (?=\S) - fail: class-element-modifier - - do-while-meta: + decorator-meta: - meta_include_prototype: false - - meta_scope: meta.do-while.js + - meta_scope: meta.annotation.js - include: immediately-pop - support-property-ecma-string: - - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} - scope: support.function.builtin.js - pop: true - - 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 - import-statement-or-import-meta: - match: (?=import{{identifier_break}}) branch_point: import-statement @@ -1037,125 +1395,241 @@ contexts: - import-statement - expression-statement - function-parameter-binding-list: - - match: ',' - scope: punctuation.separator.parameter.function.js - - include: function-parameter-binding-spread - - match: (?={{binding_pattern_lookahead}}) - push: function-parameter + function-parameter-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: function-parameter-binding-pattern - include: else-pop - flow-type-alias-initializer: - - match: '=' - scope: keyword.operator.assignment.js + flow-type-generic-arguments: + - match: < + scope: punctuation.definition.generic.begin.js set: - - flow-type-meta - - flow-type - - include: else-pop - for-of-rest: - - match: (?:of|in){{identifier_break}} - scope: keyword.operator.word.js - set: expression + - meta_scope: meta.generic.js + - match: '>' + scope: punctuation.definition.generic.end.js + pop: true + - include: flow-type-list - for-oldstyle-rest: - - match: (?=\)) - pop: true - - match: ; - scope: punctuation.separator.expression.js - - match: (?=\S) - push: expression + 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 - function-parameter: - - match: '' + literal-call: + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() set: - - initializer - - function-parameter-binding-pattern + - call-function-meta + - function-call-arguments + - literal-variable - jsx-tag-attributes-top: - - meta_scope: meta.tag.js - - match: / - scope: punctuation.definition.tag.begin.js + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() set: - - jsx-meta-unmatched-tag - - jsx-expect-tag-end - - jsx-tag-name + - call-method-meta + - function-call-arguments + - call-path + - literal-variable - - match: (?=\S) + prototype: + - include: comments + + support-variable-console: + # https://console.spec.whatwg.org/ + - match: console{{identifier_break}} + scope: support.type.object.console.js set: - - jsx-tag-attributes - - flow-jsx-tag-check - - jsx-tag-name - - flow-jsx-tag-check-name + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: builtin-console-properties + - include: else-pop - jsx-meta: - - meta_include_prototype: false - - meta_scope: meta.jsx.js - - include: immediately-pop + for-condition: + - match: \( + scope: punctuation.section.group.js + set: + - for-condition-end + - for-condition-contents + - include: else-pop - object-literal: + function-block: - match: \{ scope: punctuation.section.block.begin.js - set: object-literal-contents + set: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements - function-parameter-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: function-parameter-binding-pattern + 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 - 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 + support-property-node-module: + - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} + scope: support.constant.node.js pop: true - - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} - scope: support.function.builtin.js + - match: require{{identifier_break}} + scope: support.function.node.js pop: true - jsx-tag-attributes: - - meta_scope: meta.tag.attributes.js - - - match: '>' - scope: punctuation.definition.tag.end.js - set: jsx-body + flow-type-literal: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js + pop: true + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js + pop: true + - match: (?=\d) + set: + - - match: '{{identifier_part}}+' + scope: invalid.illegal.js + - include: immediately-pop + - literal-number + - match: (?=['"]) + set: literal-string - - match: / - scope: punctuation.definition.tag.end.js - set: jsx-expect-tag-end + flow-type-existential: + - match: \* + scope: constant.language.type.existential.js + pop: true - - include: jsx-interpolation + expression-no-comma: + - meta_include_prototype: false + - match: '' + set: [expression-end-no-comma, expression-begin] - - match: '{{jsx_identifier}}' - scope: entity.other.attribute-name.js + flow-less-than: + - match: < + scope: keyword.operator.comparison.js + set: expression-begin - - match: '=' - scope: punctuation.separator.key-value.js - push: jsx-attribute-value + expression-break: + - match: (?=[;})\]]) + pop: true - expression-statement-end: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: expression-statement-end - - include: else-pop - - include: expression-end + flow-type-module-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: flow-type-module-contents + - include: else-pop - with-meta: + shebang-body: - meta_include_prototype: false - - meta_scope: meta.with.js - - include: immediately-pop - - decorator-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: decorator-name - - include: object-property + - 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: left-expression-end + class-body-contents: + - meta_scope: meta.block.js - flow-type-class: - - match: '{{non_reserved_identifier}}' - scope: variable.other.class.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 + + styled-component-end: + - match: \. + scope: punctuation.accessor.dot.js + push: styled-component-begin + + - 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 + + support-property-ecma-typedarray: + - match: (?:BYTES_PER_ELEMENT){{identifier_break}} + scope: support.constant.builtin.js pop: true function-declaration-expect-name: @@ -1164,80 +1638,113 @@ contexts: pop: true - include: else-pop + statements: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + pop: true + + - match: (?=\S) + push: statement + + function-declaration-expect-async: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + pop: true + - include: else-pop + conditional-meta: - meta_include_prototype: false - meta_scope: meta.conditional.js - include: immediately-pop - initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: expression-no-comma + 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 - class-element: - - match: '' + flow-jsx-tag-check-name: + - match: (?=(?:(?:{{jsx_identifier_part}})|\.):) + fail: arrow-function + - include: else-pop + + switch-block-contents: + - meta_scope: meta.block.js + + - match: \} + scope: punctuation.section.block.end.js pop: true - branch_point: class-field - branch: - - class-field - - method-declaration - object-property: - - include: support-property + - match: case{{identifier_break}} + scope: keyword.control.conditional.case.js + push: + - expect-case-colon + - expression - - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) - set: - - function-name-meta - - object-property-base + - match: default{{identifier_break}} + scope: keyword.control.conditional.default.js + push: + - expect-case-colon - - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: call-method-name + - include: statements - - match: '{{identifier_name}}(?={{nothing}}`)' - scope: variable.function.tagged-template.js + arrow-function-expect-arrow: + - match: => + scope: keyword.declaration.function.arrow.js pop: true - - - include: object-property-base - include: else-pop - expect-case-colon: - - match: ':' - scope: punctuation.separator.js + 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 + + flow-type-declare-export: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + set: flow-type + - match: (?=\S) pop: true - - include: else-pop - new-target: - - match: \. - scope: punctuation.accessor.dot.js + constructor-body-expect-class-begin: + - match: (?={{non_reserved_identifier}}\s*\() set: - - match: target{{identifier_break}} - scope: variable.language.target.js + - 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: else-pop - - 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 + - include: expression-begin - - match: (?=\S) - set: - - - include: for-of-rest - - match: (?=\S) - set: for-oldstyle-rest - - expression-end-no-in - - expression-begin + literal-string-template-custom-lookahead: [] + line-comment-end: + - match: (//+)?\n + captures: + 1: punctuation.definition.comment.js + pop: 1 object-property-base: - match: '{{dollar_only_identifier}}' @@ -1260,216 +1767,111 @@ contexts: 2: meta.property.object.js pop: true - flow-jsx-tag-check-name: - - match: (?=(?:(?:{{jsx_identifier_part}})|\.):) - fail: arrow-function - - include: else-pop + jsx-tag: + - match: < + scope: punctuation.definition.tag.begin.js + set: + - jsx-meta + - jsx-tag-attributes-top - import-meta-expression: - - match: import{{identifier_break}} - scope: keyword.import.js - set: import-expression-end + class-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: class-body-contents - 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 - - flow-type-generic-parameters: - - match: < - scope: punctuation.definition.generic.begin.js - 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 - flow-type-tuple: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list - - object-literal-meta-key: - - meta_scope: meta.mapping.key.js - - include: else-pop - - support-property: - - include: support-property-ecma - - function-meta: - - meta_include_prototype: false - - meta_scope: meta.function.js - - include: immediately-pop - - function-declaration-expect-generator-star: - - match: \* - scope: keyword.declaration.generator.js - pop: true + styled-component-keyframes-end: + - match: (?=`) + push: + - 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#at-keyframe-block-content + 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: else-pop - line-comment-double-slash-body: + line-comment-other-body: - meta_include_prototype: false - - meta_scope: comment.line.double-slash.js + - meta_scope: comment.line.other.js - include: line-comment-end - export-statement: - - match: export{{identifier_break}} - scope: keyword.control.import-export.js - set: - - export-meta - - export-extended - - constructor-body-expect-arguments: - - include: function-call-arguments - - include: else-pop - - left-expression-end: - - include: expression-break - - - match: (?=`) - push: literal-string-template - - - match: (?=(?:{{dot_accessor}})?\() - push: function-call-arguments - - - include: property-access - + detect-arrow: + - match: (?==>) + fail: arrow-function - include: else-pop - expression-no-comma: - - meta_include_prototype: false - - match: '' - set: [expression-end-no-comma, expression-begin] + support-property-ecma-bigint: + - match: (?:asUintN|asIntN){{identifier_break}} + scope: support.function.builtin.js + pop: true - jsx-tag-name-end: - - match: '[:.]' - scope: punctuation.accessor.js - push: jsx-tag-name-component - - include: else-pop + postfix-operators: + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js - method-declaration: + import-meta: - meta_include_prototype: false - - 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 - - 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 - - support: - - include: support-variable-ecma - - include: support-variable-console - - include: support-variable-dom - - include: support-variable-node + - meta_scope: meta.import.js + - include: immediately-pop - statements: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js + support-property-ecma-json: + - match: (?:parse|stringify){{identifier_break}} + scope: support.function.builtin.js pop: true + arrow-function-expect-arrow-or-fail-async: + - match: => + scope: keyword.declaration.function.arrow.js + pop: true - match: (?=\S) - push: statement - - class-extends: - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop + fail: async-arrow-function - literal-variable: - - include: special-identifier - - include: support + inherited-class-expression-end: + - include: flow-type-generic-arguments - - match: (?={{identifier_name}}{{function_assignment_lookahead}}) - set: - - function-name-meta - - literal-variable-base + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: inherited-class-name + - include: object-property - - match: '{{identifier_name}}(?={{nothing}}`)' - scope: variable.function.tagged-template.js - pop: true + - include: left-expression-end - - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' - scope: support.class.js + jsx-tag-name-component: + - match: '{{jsx_identifier}}' + scope: entity.name.tag.js pop: true - - - match: '{{function_call_lookahead}}' - set: call-function-name - - - include: literal-variable-base - - function-declaration: - - match: '' - set: - - function-meta - - function-declaration-expect-body - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - function-declaration-expect-name - - function-declaration-expect-generator-star - - function-declaration-expect-function-keyword - - function-declaration-expect-async - - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - include: else-pop - expression-end-no-in: - - match: (?=in{{identifier_break}}) - pop: true - - include: expression-end - support-variable-node: - match: global{{identifier_break}} scope: support.type.object.node.js @@ -1508,68 +1910,76 @@ contexts: scope: support.function.node.js pop: true - do-while-condition: - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: parenthesized-expression - - include: else-pop + inherited-class-name: + - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' + scope: entity.other.inherited-class.js + pop: true - literal-string-template-custom-comments: [] - 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 + 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 - 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 + - 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 + + 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 + + custom-templates-default: + - include: literal-string-template + + call-method-name: + - include: support-property + - match: '{{identifier_name}}' + scope: variable.function.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: (#){{identifier_name}} + scope: variable.function.js + captures: + 1: punctuation.definition.js pop: true - - styled-component-keyframes-end: - - match: (?=`) - push: - - 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#at-keyframe-block-content - 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: else-pop + function-meta: + - meta_include_prototype: false + - meta_scope: meta.function.js + - include: immediately-pop + + constructor-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.constructor.js + - include: immediately-pop + + for-meta: + - meta_include_prototype: false + - meta_scope: meta.for.js + - include: immediately-pop + for-condition-end: - meta_scope: meta.group.js @@ -1577,53 +1987,71 @@ contexts: scope: punctuation.section.group.js pop: true - 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 + export-extended: + - include: flow-type-export-type - - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} - scope: support.function.js - pop: true + - include: declaration - # Annex B - - match: __proto__{{identifier_break}} - scope: invalid.deprecated.js variable.language.prototype.js - pop: true - - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} - scope: invalid.deprecated.js support.function.js - pop: true + - 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-meta: + - meta_scope: meta.flow-type.js + - include: immediately-pop + + left-expression-end: + - include: expression-break + + - match: (?=`) + push: literal-string-template + + - match: (?=(?:{{dot_accessor}})?\() + push: function-call-arguments + + - include: property-access - 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 - jsdoc-block-tag: - - match: '{{jsdoc_block_tag}}' - scope: entity.other.attribute-name.documentation.js - pop: 1 - - match: (?=\S)|$ - pop: 1 + 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 - export-list: - - match: ',' - scope: punctuation.separator.comma.js + flow-arrow-return-type: + - match: '' push: - - import-export-alias - - export-item - - include: else-pop + - flow-detect-arrow-after-return-type + - flow-arrow-function-return-type-annotation + + 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 + + import-item: + - include: flow-type-import-type - export-item: - match: \{ scope: punctuation.section.block.begin.js - set: export-brace + set: import-brace - match: '{{non_reserved_identifier}}' scope: variable.other.readwrite.js pop: true @@ -1632,70 +2060,174 @@ contexts: pop: true - include: else-pop - comma-separator: - - match: ',' - scope: punctuation.separator.comma.js - - call-path: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: object-property - - include: else-pop - - literal-call: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: - - call-function-meta - - function-call-arguments - - literal-variable + jsx-meta-unmatched-tag: + - meta_include_prototype: false + - meta_scope: invalid.illegal.unmatched-tag.js + - include: immediately-pop - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() - set: - - call-method-meta - - function-call-arguments - - call-path - - literal-variable + flow-type-import-type: + - match: type{{identifier_break}} + scope: keyword.declaration.js - 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 + - match: typeof{{identifier_break}} + scope: keyword.operator.js - inherited-class-name: - - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' - scope: entity.other.inherited-class.js + flow-type-object-indexer-label: + - match: ({{non_reserved_identifier}})\s*(:) + captures: + 1: meta.object-literal.key.js + 2: punctuation.separator.key-value.js pop: true + - include: else-pop - literal-string-template-custom-tags: [] - support-property-ecma-date: - - match: (?:now|parse|UTC){{identifier_break}} - scope: support.function.builtin.js - pop: true + variable-binding-list: + - include: comma-separator + - match: (?={{binding_pattern_lookahead}}) + push: + - initializer + - variable-binding-pattern + - include: else-pop - regular-function: - - match: (?={{func_lookahead}}) - set: function-declaration + flow-type-declare: + - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) + scope: keyword.declaration.js + set: + - match: opaque{{identifier_break}} + scope: storage.modifier.js + pop: true + - match: module{{identifier_break}} + scope: keyword.declaration.js + set: + - flow-type-module-meta + - flow-type-module-body + - flow-type-module-name + - match: export{{identifier_break}} + scope: keyword.declaration.js + set: flow-type-declare-export + - include: else-pop - support-variable-dom: - - match: XMLHttpRequest{{identifier_break}} - scope: support.class.dom.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 - - match: (?:document|window|navigator){{identifier_break}} - scope: support.type.object.dom.js + + jsx-expect-tag-end: + - meta_content_scope: meta.tag.js + - match: '>' + scope: meta.tag.js punctuation.definition.tag.end.js pop: true - - match: (?:clearTimeout|clearInterval|setTimeout|setInterval){{identifier_break}} - scope: support.function.dom.js + - include: else-pop + + immediately-pop: + - match: '' pop: true - support-property-ecma-math: - - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} + 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: (?: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}} + - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} scope: support.function.builtin.js pop: true + expression-statement: + - match: (?=\S) + set: + - expect-semicolon + - expression-statement-end + - expression-begin + + 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 + + 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 + + export-list: + - match: ',' + scope: punctuation.separator.comma.js + push: + - import-export-alias + - export-item + - include: else-pop + + 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 + + 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 + + expression-end: + - include: flow-function-type-arguments-or-less-than + + - include: postfix-operators + - include: binary-operators + - include: ternary-operator + + - include: left-expression-end + + 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-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 + + jsdoc-block-tag: + - match: '{{jsdoc_block_tag}}' + scope: entity.other.attribute-name.documentation.js + pop: 1 + - match: (?=\S)|$ + pop: 1 + export-brace: - meta_scope: meta.block.js - include: comma-separator @@ -1710,193 +2242,169 @@ contexts: push: import-export-alias - include: else-pop - class-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.class.js - set: flow-type-generic-parameters - - include: else-pop + decorator-expression-end: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: decorator-name + - include: object-property - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation + - include: left-expression-end - - 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 + literal-private-variable: + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js + pop: true - - include: else-pop + flow-type-annotation-optional: + - match: \?(?=:) + scope: storage.modifier.optional.js + - include: flow-type-annotation - 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 + class-meta: + - meta_include_prototype: false + - meta_scope: meta.class.js + - include: immediately-pop - - 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 + literal-string-template-custom-tags: [] + jsx-interpolation: + - match: (?={/\*) + branch_point: jsx-interpolation-comment + branch: + - jsx-interpolation-comment + - jsx-interpolation-plain + - match: (?={) + push: jsx-interpolation-plain - object-literal-property: - - match: '' - set: - - object-literal-property-check - - object-literal-meta-key - - object-property-name + declaration: + - include: variable-declaration + - include: class + - include: regular-function - else-pop: - - match: (?=\S) + decorator-name: + - match: '{{identifier_name}}{{left_expression_end_lookahead}}' + scope: variable.annotation.js pop: true - import-export-alias: - - match: as{{identifier_break}} - scope: keyword.control.import-export.js + jsx-tag-name: + - meta_include_prototype: false + - match: '' 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 - - expression-begin: - - include: jsx-tag-hack - - - include: flow-arrow-function-declaration-with-type-parameters + - jsx-tag-name-meta + - jsx-tag-name-end + - jsx-tag-name-component-possibly-native - - 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}}) - pop: true + conditional: + - match: switch{{identifier_break}} + scope: keyword.control.conditional.switch.js + set: + - switch-meta + - switch-block + - expect-parenthesized-expression - - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + - match: do{{identifier_break}} + scope: keyword.control.loop.do-while.js set: - - function-name-meta - - literal-variable + - do-while-meta + - do-while-condition + - statement - - include: object-literal + - match: for{{identifier_break}} + scope: keyword.control.loop.for.js + set: + - for-meta + - block-scope + - for-condition + - for-await - # 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 + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: + - while-meta + - block-scope + - expect-parenthesized-expression - - include: literal-call + - match: with{{identifier_break}} + scope: keyword.control.import.with.js + set: + - with-meta + - block-scope + - expect-parenthesized-expression - - match: (?={{possible_arrow_function_begin}}) - pop: true - branch_point: arrow-function - branch: - - branch-possible-arrow-function - - arrow-function-declaration + - match: if{{identifier_break}} + scope: keyword.control.conditional.if.js + set: + - conditional-meta + - statement + - expect-parenthesized-expression - - include: array-literal + - match: else\s+if{{identifier_break}} + scope: keyword.control.conditional.elseif.js + set: + - conditional-meta + - statement + - expect-parenthesized-expression - - include: literal-private-variable + - match: else{{identifier_break}} + scope: keyword.control.conditional.else.js + set: + - conditional-meta + - statement - - include: else-pop + - match: try{{identifier_break}} + scope: keyword.control.exception.try.js + set: + - try-meta + - block-scope - decorator-meta: - - meta_include_prototype: false - - meta_scope: meta.annotation.js - - include: immediately-pop + - match: finally{{identifier_break}} + scope: keyword.control.exception.finally.js + set: + - finally-meta + - block-scope - custom-templates-default: - - include: literal-string-template + - match: catch{{identifier_break}} + scope: keyword.control.exception.catch.js + set: + - catch-meta + - block-scope + - expect-parenthesized-expression - flow-type-existential: - - match: \* - scope: constant.language.type.existential.js - pop: true + 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 - flow-type-object-indexer-type: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list + - match: (?=\S) + set: + - jsx-tag-attributes + - flow-jsx-tag-check + - jsx-tag-name + - flow-jsx-tag-check-name - expect-label: - - meta_include_prototype: false - - match: (?={{nothing}}{{identifier_name}}) + new-target: + - match: \. + scope: punctuation.accessor.dot.js set: - - match: '{{non_reserved_identifier}}' - scope: variable.label.js - pop: true - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js variable.label.js + - match: target{{identifier_break}} + scope: variable.language.target.js pop: true - include: else-pop - - include: immediately-pop - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.js - - include: immediately-pop + - include: else-pop - block-meta: - - meta_include_prototype: false + static-block-body: - meta_scope: meta.block.js - - include: immediately-pop - - block: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements flow-type-annotation: - match: ':' @@ -1907,66 +2415,206 @@ contexts: - match: (?!\s*(?:$|:|//|/\*)) pop: true - variable-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' - scope: string.unquoted.js - pop: true - - match: '{{identifier_name}}(?=\s*:)' + jsx-tag-name-component-possibly-native: + - match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])' + scope: entity.name.tag.native.js pop: true - - include: literal-string - - include: computed-property-name - - include: variable-binding-name - - include: else-pop + - include: jsx-tag-name-component - import-check-branch: - - match: (?=[.(]) # Recovery for import expressions - fail: import-statement + with-meta: + - meta_include_prototype: false + - meta_scope: meta.with.js + - include: immediately-pop + + method-declaration-expect-asterisk: + - match: \* + scope: keyword.generator.asterisk.js - include: else-pop - jsx-tag-hack: [] - label: - - match: ({{identifier_name}})\s*(:) - captures: - 1: entity.name.label.js - 2: punctuation.separator.js + flow-function-type-arguments: + - match: \<(?!<) + scope: punctuation.definition.generic.begin.js + set: + - - match: (?=[\]()};,`]) + pop: true + - match: (?=\S) + fail: flow-function-type-arguments + - - meta_scope: meta.generic.js + - match: \> + scope: punctuation.definition.generic.end.js + pop: true + - match: ',' + scope: punctuation.separator.comma.js + push: flow-type + - match: (?=\S) + fail: flow-function-type-arguments + - flow-type - flow-type-module-body: + variable-binding-object-destructuring: - match: \{ scope: punctuation.section.block.begin.js - set: flow-type-module-contents - - include: else-pop - - block-scope: - - include: block - - include: else-pop + set: + - meta_scope: meta.binding.destructuring.mapping.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: variable-binding-spread + - match: (?={{identifier_start}}|\[|'|") + push: + - initializer + - variable-binding-object-alias + - object-literal-meta-key + - variable-binding-object-key + - include: comma-separator - support-property-ecma-typedarray: - - match: (?:BYTES_PER_ELEMENT){{identifier_break}} + support-property-ecma-math: + - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} scope: support.constant.builtin.js pop: true + - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} + scope: support.function.builtin.js + pop: true - flow-less-than: - - match: < - scope: keyword.operator.comparison.js - set: expression-begin - - yield-expression: - - match: yield{{identifier_break}} - scope: keyword.control.flow.yield.js + literal-variable: + - include: special-identifier + - include: support + + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) set: - - match: $ + - function-name-meta + - literal-variable-base + + - match: '{{identifier_name}}(?={{nothing}}`)' + scope: variable.function.tagged-template.js + pop: true + + - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' + scope: support.class.js + pop: true + + - match: '{{function_call_lookahead}}' + set: call-function-name + + - include: literal-variable-base + + import-expression-end: + - match: (?=\() + set: function-call-arguments + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - match: meta{{identifier_break}} + scope: variable.language.import.js pop: true - - match: \* - scope: keyword.generator.asterisk.js - set: expression-begin - - match: (?=\S) - set: expression-begin + - include: object-property + - include: else-pop + 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 - flow-type: - - match: '' + flow-detect-arrow-after-return-type: + - match: (?==>) + fail: arrow-function + - match: (?=\S) + fail: flow-arrow-function-return-type + + jsx-html-escapes: + - match: (&)#?[[:alnum:]]+(;) + scope: constant.character.escape.js + captures: + 1: punctuation.definition.entity.js + 2: punctuation.definition.entity.js + + expect-label: + - meta_include_prototype: false + - match: (?={{nothing}}{{identifier_name}}) set: - - flow-type-end - - flow-type-begin + - 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 + + jsx-tag-name-meta: + - clear_scopes: 1 + - meta_include_prototype: false + - meta_scope: meta.tag.name.js + - include: immediately-pop + + class-field-check: + - match: (?=[(<]) + fail: class-field + - include: else-pop + + function-declaration-expect-parameters: + - include: function-declaration-parameters + - include: else-pop + + support-property-ecma-symbol: + - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} + scope: support.constant.builtin.js + pop: true + - match: (?:for|keyFor){{identifier_break}} + scope: support.function.builtin.js + pop: true + + 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 + + label: + - match: ({{identifier_name}})\s*(:) + captures: + 1: entity.name.label.js + 2: punctuation.separator.js + + comments: + - include: line-comments + - include: block-comments + + variable-binding-name: + - match: (?={{non_reserved_identifier}}) + set: + - - meta_scope: meta.binding.name.js + - include: immediately-pop + - literal-variable + + jsx-tag-hack: [] + await-expression: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js + + import-string-or-items: + - include: literal-string + - match: (?=\S) + set: + - import-export-from + - import-list + - import-export-alias + - import-item jsx-body: - meta_include_prototype: false @@ -1990,143 +2638,92 @@ contexts: - include: jsx-html-escapes - include: jsx-interpolation - jsx-tag: - - match: < - scope: punctuation.definition.tag.begin.js - set: - - jsx-meta - - jsx-tag-attributes-top + 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 - variable-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + variable-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: variable-binding-pattern + - include: else-pop + + regexp: + - meta_include_prototype: false + - meta_scope: meta.string.js string.regexp.js + - match: / + scope: punctuation.definition.string.end.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.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: variable-binding-spread - - include: variable-binding-list + - include: scope:source.regexp.js - main: - - meta_include_prototype: false # don't match comments before shebang - - match: '' - push: [script, shebang] + variable-binding-top: + - match: (?={{binding_pattern_lookahead}}) + set: + - initializer + - variable-binding-pattern + - include: else-pop - jsx-tag-name: - - meta_include_prototype: false + flow-type: - match: '' set: - - jsx-tag-name-meta - - jsx-tag-name-end - - jsx-tag-name-component-possibly-native + - flow-type-end + - flow-type-begin - object-property-name: - - match: '{{identifier_name}}' - scope: string.unquoted.js - pop: true + import-check-branch: + - match: (?=[.(]) # Recovery for import expressions + fail: import-statement + - include: else-pop - - match: (?=\[) - set: computed-property-name + function-parameter: + - match: '' + set: + - initializer + - function-parameter-binding-pattern - - include: literal-string - - include: literal-number + main: + - meta_include_prototype: false # don't match comments before shebang + - match: '' + push: [script, shebang] - - match: '{{identifier_name}}' + flow-type-object-indexer-type: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: flow-type-list + + 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 + while-meta: + - meta_include_prototype: false + - meta_scope: meta.while.js + - include: immediately-pop + + function-declaration-expect-body: + - include: function-block - include: else-pop - function-parameter-binding-pattern: - - match: '' - set: - - - include: flow-type-annotation-optional - - - include: function-parameter-binding-name - - include: function-parameter-binding-array-destructuring - - include: function-parameter-binding-object-destructuring - - include: else-pop - - variable-binding-list-top: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: variable-binding-top - - include: else-pop - - match: ',' - scope: punctuation.separator.comma.js - push: variable-binding-top - - include: else-pop - - jsx-tag-name-meta: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: meta.tag.name.js - - include: immediately-pop - - jsx-interpolation: - - match: (?={/\*) - branch_point: jsx-interpolation-comment - branch: - - jsx-interpolation-comment - - jsx-interpolation-plain - - match: (?={) - push: jsx-interpolation-plain - - function-declaration-expect-parameters: - - include: function-declaration-parameters - - include: else-pop - - function-declaration-expect-function-keyword: - - match: function{{identifier_break}} - scope: keyword.declaration.function.js - pop: true - - include: else-pop - - variable-binding-object-destructuring: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.binding.destructuring.mapping.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: variable-binding-spread - - match: (?={{identifier_start}}|\[|'|") - push: - - initializer - - variable-binding-object-alias - - object-literal-meta-key - - variable-binding-object-key - - include: comma-separator - - 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 - - restricted-production: - - meta_include_prototype: false - - match: '{{line_ending_ahead}}' - pop: true - - match: '' - set: expression-statement - - prototype: - - include: comments - - static-block-body: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements - flow-type-object-contents: - include: comma-separator - match: ; @@ -2145,703 +2742,100 @@ contexts: - flow-type-object-indexer-type - flow-type-object-indexer-label - decorator-expression-begin: - - include: decorator-name - - include: expression-begin - - object-literal-contents: - - meta_scope: meta.mapping.js - - - match: \} - scope: punctuation.section.block.end.js + support-property-ecma-proxy: + - match: revocable{{identifier_break}} + scope: support.function.builtin.js pop: true - - match: \.\.\. - scope: keyword.operator.spread.js - push: expression-no-comma - - - match: >- - (?x)(?= - {{property_name}}\s*:\s* - {{either_func_lookahead}} - ) - push: - - object-literal-meta-key - - method-name - - - match: (?=\*) - push: method-declaration - - - match: (?=(?:get|set|async){{identifier_break}}) - branch_point: prefixed-object-literal-method - branch: - - prefixed-object-literal-method - - object-literal-element - - - match: (?={{property_name}}) - push: object-literal-element - - - include: comma-separator - + expect-case-colon: - match: ':' - scope: punctuation.separator.key-value.js - push: expression-no-comma - - # If there's any garbage, parse it as an expression - # so that close braces won't break things. - - match: (?=\S) - push: expression-no-comma - - line-comment-end: - - match: (//+)?\n - captures: - 1: punctuation.definition.comment.js - pop: 1 - - 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 - - flow-type-module-meta: - - meta_scope: meta.module.js - - include: immediately-pop - - 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 - - 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 + scope: punctuation.separator.js + pop: true - include: else-pop - class-field: - - match: '' + class: + - match: class{{identifier_break}} + scope: keyword.declaration.class.js set: - - initializer - - flow-type-annotation - - class-field-check - - field-name - - expression-break: - - match: (?=[;})\]]) - pop: true - - 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 + - class-meta + - class-body + - class-extends + - class-name - regexp: + jsdoc-comment-body: - 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 - - support-property-ecma-bigint: - - match: (?:asUintN|asIntN){{identifier_break}} - scope: support.function.builtin.js - pop: true - - function-parameter-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: function-parameter - - method-declaration-expect-asterisk: - - match: \* - scope: keyword.generator.asterisk.js - - include: else-pop - - import-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - import-item - - include: else-pop - - flow-type-list: - - include: comma-separator - - match: (?=\S) - push: flow-type - - flow-function-type-arguments: - - match: \<(?!<) - scope: punctuation.definition.generic.begin.js - set: - - - match: (?=[\]()};,`]) - pop: true - - match: (?=\S) - fail: flow-function-type-arguments - - - meta_scope: meta.generic.js - - match: \> - scope: punctuation.definition.generic.end.js - pop: true - - match: ',' - scope: punctuation.separator.comma.js - push: flow-type - - match: (?=\S) - fail: flow-function-type-arguments - - flow-type - - 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 - - support-property-ecma-json: - - match: (?:parse|stringify){{identifier_break}} - scope: support.function.builtin.js - pop: true - - variable-declaration: - - match: (?:const|let|var){{identifier_break}} - scope: keyword.declaration.js - set: - - expect-semicolon - - variable-binding-list-top - - variable-binding-top - - block-comment-body: - - meta_include_prototype: false - - meta_scope: comment.block.js + - 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 - script: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - # Don't pop or embedding could break. - - - include: statements - - flow-type-primitive: - - match: boolean{{identifier_break}} - scope: support.type.primitive.boolean.js - pop: true - - - match: number{{identifier_break}} - scope: support.type.primitive.number.js - pop: true - - - 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 - - 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 - - call-method-name: - - include: support-property - - match: '{{identifier_name}}' - scope: variable.function.js - pop: true - - match: (#){{identifier_name}} - scope: variable.function.js - captures: - 1: punctuation.definition.js - pop: true - - include: else-pop - - 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: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js - pop: true - - match: \$\{ - scope: punctuation.section.interpolation.begin.js - push: - - clear_scopes: 1 - - meta_scope: meta.interpolation.js - - meta_content_scope: source.js.embedded - - match: \} - scope: punctuation.section.interpolation.end.js - pop: true - - match: (?=\S) - push: expression - - include: string-content - - 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 - - immediately-pop: - - match: '' - pop: true - - 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 - - jsx-meta-unmatched-tag: - - meta_include_prototype: false - - meta_scope: invalid.illegal.unmatched-tag.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 - - call-function-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.js - - 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 - - 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 - - flow-type-special: - - match: any{{identifier_break}} - scope: support.type.any.js - pop: true - - - match: mixed{{identifier_break}} - scope: support.type.mixed.js - pop: true - - function-parameter-binding-object-key: - - match: '{{identifier_name}}(?=\s*:)' - pop: true - - include: literal-string - - include: computed-property-name - - include: function-parameter-binding-name - - include: else-pop - - await-expression: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js - - 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 - - flow-jsx-tag-check: - - match: (?=[:,]) - fail: arrow-function - - include: else-pop - ternary-operator-expect-colon: - - match: ':' - scope: keyword.operator.ternary.js - set: expression-no-comma - - 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 - - flow-type-export-type: - - match: type{{identifier_break}}(?=\s*\{) - scope: keyword.declaration.js - set: export-item - - include: flow-type-alias - - variable-binding-name: - - match: (?={{non_reserved_identifier}}) - set: - - - meta_scope: meta.binding.name.js - - include: immediately-pop - - literal-variable - - postfix-operators: - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - 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 - - arrow-function-expect-arrow: - - match: => - scope: keyword.declaration.function.arrow.js - pop: true - - 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: function-parameter-binding-list - - function-declaration-expect-async: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js - pop: true - - include: else-pop - - block-comment-end: - - match: \*+/ - scope: punctuation.definition.comment.end.js - pop: true - - detect-arrow: - - match: (?==>) - fail: arrow-function - - include: else-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 - - 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 - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-bigint - - include: object-property - - include: else-pop - - include: else-pop - - - match: Date{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-date - - include: object-property - - include: else-pop - - include: else-pop - - - match: JSON{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-json - - include: object-property - - include: else-pop - - include: else-pop - - - match: Math{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-math - - include: object-property - - include: else-pop - - include: else-pop - - - match: Number{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-number - - include: object-property - - include: else-pop - - include: else-pop - - - match: Object{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-object - - include: object-property - - include: else-pop - - include: else-pop - - - match: Promise{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-promise - - include: object-property - - include: else-pop - - include: else-pop - - - match: Proxy{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-proxy - - include: object-property - - include: else-pop - - include: else-pop - - - match: Reflect{{identifier_break}} - scope: support.constant.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-reflect - - include: object-property - - include: else-pop - - include: else-pop - - - match: String{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-string - - include: object-property - - include: else-pop - - include: else-pop - - - match: Symbol{{identifier_break}} - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-symbol - - include: object-property - - include: else-pop - - include: else-pop - - - match: |- - (?x: - (?: - BigInt64| - BigUint64| - Float(?:32|64)| - Int(?:8|16|32)| - Uint(?:8|16|32|32Clamped) - ) - Array{{identifier_break}} - ) - scope: support.class.builtin.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-typedarray - - include: object-property - - include: else-pop - - include: else-pop - - # Classes with no constructor properties - - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} - scope: support.class.builtin.js - pop: true - - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} - scope: support.class.builtin.js - pop: true - - - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} - scope: support.function.js + else-pop: + - match: (?=\S) pop: true - flow-arrow-return-type: - - match: '' - push: - - flow-detect-arrow-after-return-type - - flow-arrow-function-return-type-annotation + jsx-interpolation-comment: + - match: ({)(/\*) + captures: + 1: punctuation.definition.interpolation.begin.js + 2: punctuation.definition.comment.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 + pop: true + - match: (?=\*/) + fail: jsx-interpolation-comment - expect-semicolon: - - match: \; - scope: punctuation.terminator.statement.js - pop: true + arrow-function-expect-body: + - include: function-block + - match: (?=\S) + set: + - block-meta + - expression-no-comma + + switch-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: switch-block-contents - include: else-pop - regexp-complete: - - match: / - scope: punctuation.definition.string.begin.js - set: regexp + initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: expression-no-comma + - include: else-pop - for-await: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js + flow-type-typeof: + - match: typeof{{identifier_break}} + scope: keyword.operator.js + set: + - left-expression-end + - expression-begin + + support-property-ecma-arraybuffer: + - match: isView{{identifier_break}} + scope: support.function.builtin.js pop: true + + for-of-rest: + - match: (?:of|in){{identifier_break}} + scope: keyword.operator.word.js + set: expression + + do-while-meta: + - meta_include_prototype: false + - meta_scope: meta.do-while.js + - include: immediately-pop + + constructor-body-expect-arguments: + - include: function-call-arguments - include: else-pop function-call-arguments: @@ -2856,376 +2850,405 @@ contexts: pop: true - include: expression-list - styled-components: - - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}}) - set: - - styled-component-end - - styled-component-begin - - match: (?=keyframes{{identifier_break}}) + class-element-modifiers: + - match: '' + pop: true + branch_point: class-element-modifier + branch: + - class-element-modifier + - class-element + + support-property-ecma-date: + - match: (?:now|parse|UTC){{identifier_break}} + scope: support.function.builtin.js + pop: true + + object-property: + - include: support-property + + - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) set: - - styled-component-keyframes-end - - styled-component-begin - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js + - 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 - constructor-body-expect-class-begin: - - match: (?={{non_reserved_identifier}}\s*\() + flow-type-object-value: + - match: (\?)?(:) + captures: + 1: storage.modifier.optional.js + 2: punctuation.separator.key-value.js + set: flow-type + - include: else-pop + + arrow-function-expect-parameters: + - match: (?={{identifier_start}}) 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 + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js - match: '{{identifier_name}}' - scope: variable.type.js + scope: variable.parameter.function.js pop: true - - include: else-pop + - include: function-declaration-parameters + - include: else-pop - - include: expression-begin + 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 - field-name: - - match: '{{dollar_identifier}}' - scope: meta.mapping.key.dollar.js variable.other.readwrite.js - captures: - 1: punctuation.dollar.js + for-await: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js pop: true + - include: else-pop + + variable-binding-pattern: + - match: '' + set: + - - include: flow-type-annotation + - - include: variable-binding-name + - include: variable-binding-array-destructuring + - include: variable-binding-object-destructuring + - include: else-pop + + 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 + + object-literal: + - match: \{ + scope: punctuation.section.block.begin.js + set: object-literal-contents + + function-parameter-binding-name: + - match: '{{non_reserved_identifier}}' + scope: meta.binding.name.js variable.parameter.function.js - match: '{{identifier_name}}' - scope: variable.other.readwrite.js + scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js + + object-literal-property: + - match: '' + set: + - object-literal-property-check + - object-literal-meta-key + - object-property-name + + constructor-body-expect-class-end: + - include: property-access + - include: else-pop + + flow-type-module-contents: + - match: \} + scope: punctuation.section.block.end.js pop: true - - match: "'" - scope: punctuation.definition.string.begin.js + - include: main + + array-literal: + - match: \[ + scope: punctuation.section.brackets.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 + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js + - include: expression-list + + 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 + + - match: (?=\S) + set: + - - include: for-of-rest + - match: (?=\S) + set: for-oldstyle-rest + - expression-end-no-in + - expression-begin + + flow-type-tuple: + - match: \[ + scope: punctuation.section.brackets.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 + - meta_scope: meta.sequence.js + - match: \] + scope: punctuation.section.brackets.end.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 + - include: flow-type-list + function-declaration-expect-generator-star: + - match: \* + scope: keyword.declaration.generator.js + pop: true - include: else-pop - flow-type-annotation-optional: - - match: \?(?=:) - scope: storage.modifier.optional.js - - include: flow-type-annotation + support-property: + - include: support-property-ecma - flow-type-typeof: - - match: typeof{{identifier_break}} - scope: keyword.operator.js - set: - - left-expression-end - - expression-begin + flow-type-module-meta: + - meta_scope: meta.module.js + - include: immediately-pop - jsx-interpolation-comment: - - match: ({)(/\*) - captures: - 1: punctuation.definition.interpolation.begin.js - 2: punctuation.definition.comment.begin.js + expression-begin: + - include: jsx-tag-hack + + - include: flow-arrow-function-declaration-with-type-parameters + + - match: (?=`) set: - - meta_include_prototype: false - - meta_scope: meta.interpolation.js comment.block.js - - match: (\*/)(}) - captures: - 1: punctuation.definition.comment.end.js - 2: punctuation.definition.interpolation.end.js - pop: true - - match: (?=\*/) - fail: jsx-interpolation-comment + - include: literal-string-template-custom-comments + - include: literal-string-template-custom-lookahead + - include: custom-templates-default - jsx-html-escapes: - - match: (&)#?[[:alnum:]]+(;) - scope: constant.character.escape.js - captures: - 1: punctuation.definition.entity.js - 2: punctuation.definition.entity.js + - include: expression-break - class-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: class-body-contents + - include: yield-expression + - include: await-expression - - include: else-pop + - include: regexp-complete + - include: literal-string + - include: literal-string-template + - include: constructor + - include: literal-number + - include: prefix-operators + - include: import-meta-expression - try-meta: - - meta_include_prototype: false - - meta_scope: meta.try.js - - include: immediately-pop + - include: class + - include: special-name - styled-component-begin: - - match: '{{non_reserved_identifier}}(?=\s*\()' - scope: variable.function.js + - include: regular-function + + - match: (?={{reserved_word}}) pop: true - - match: '{{non_reserved_identifier}}(?=\s*`)' - scope: variable.function.tagged-template.js + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + set: + - function-name-meta + - literal-variable + + - 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 - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js + - include: literal-call + + - match: (?={{possible_arrow_function_begin}}) pop: true + branch_point: arrow-function + branch: + - branch-possible-arrow-function + - arrow-function-declaration + + - include: array-literal + + - include: literal-private-variable - include: else-pop - import-statement: - - match: import{{identifier_break}} - scope: keyword.control.import-export.js - set: - - import-meta - - expect-semicolon - - import-string-or-items - - import-check-branch - 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-alias-initializer: + - match: '=' + scope: keyword.operator.assignment.js set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.single.js - - meta_content_scope: entity.name.function.js - - match: \' - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js + - flow-type-meta + - flow-type + - include: else-pop + flow-type-function: + - match: \( + scope: punctuation.section.grouping.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.group.js + - match: \) + scope: punctuation.section.grouping.end.js pop: true - - include: string-content + - include: flow-type-list - - match: (?=\[) - push: computed-property-name + expression: + - meta_include_prototype: false + - match: '' + set: [expression-end, 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 + block-scope: + - include: block - include: else-pop - while-meta: + switch-meta: - meta_include_prototype: false - - meta_scope: meta.while.js + - meta_scope: meta.switch.js - include: immediately-pop - 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 + function-name-meta: + - meta_include_prototype: false + - meta_scope: entity.name.function.js + - include: immediately-pop - class-element-modifiers: - - match: '' - pop: true - branch_point: class-element-modifier - branch: - - class-element-modifier - - class-element + regular-function: + - match: (?={{func_lookahead}}) + set: function-declaration - 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 + import-meta-expression: + - match: import{{identifier_break}} + scope: keyword.import.js + set: import-expression-end - arrow-function-expect-arrow-or-fail-async: - - match: => - scope: keyword.declaration.function.arrow.js + comma-separator: + - match: ',' + scope: punctuation.separator.comma.js + + object-property-name: + - match: '{{identifier_name}}' + scope: string.unquoted.js pop: true - - match: (?=\S) - fail: async-arrow-function - expression: - - meta_include_prototype: false - - match: '' - set: [expression-end, expression-begin] + - match: (?=\[) + set: computed-property-name - class-field-check: - - match: (?=[(<]) - fail: class-field - - include: else-pop + - include: literal-string + - include: literal-number - support-property-ecma-atomics: - - match: (?:and|add|compareExchange|exchange|isLockFree|load|or|store|sub|wait|wake|xor){{identifier_break}} - scope: support.function.builtin.js + - match: '{{identifier_name}}' pop: true - expect-parenthesized-expression: - - include: parenthesized-expression - include: else-pop - binary-operators: - - match: instanceof{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: in{{identifier_break}} - scope: keyword.operator.js - push: expression-begin - - match: =(?![=>]) - scope: keyword.operator.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 - - expression-end: - - include: flow-function-type-arguments-or-less-than - - - include: postfix-operators - - include: binary-operators - - include: ternary-operator + literal-string-template: + - include: literal-string-template-custom-comments + - include: literal-string-template-custom-tags + - include: styled-components - - include: left-expression-end + - match: '`' + scope: punctuation.definition.string.begin.js + set: + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.other.js + - match: '`' + scope: punctuation.definition.string.end.js + pop: true + - match: \$\{ + scope: punctuation.section.interpolation.begin.js + push: + - clear_scopes: 1 + - meta_scope: meta.interpolation.js + - meta_content_scope: source.js.embedded + - match: \} + scope: punctuation.section.interpolation.end.js + pop: true + - match: (?=\S) + push: expression + - include: string-content - function-declaration-expect-body: - - include: function-block - - include: else-pop + flow-type-export-type: + - match: type{{identifier_break}}(?=\s*\{) + scope: keyword.declaration.js + set: export-item + - include: flow-type-alias -scope: source.js +version: 2 variables: + jsx_identifier_break: (?!{{jsx_identifier_part}}) + dot_accessor: (?:\??\.) + function_call_lookahead: >- + (?x:(?= + {{identifier_name}} + \s* + (?: + < + .* + > + \s* + )? + (?:{{dot_accessor}})? + \( + )) + line_continuation_lookahead: >- + (?x:(?= + (?! \+\+ | -- ) + (?= + != | + [-+*/%><=&|^\[(;,.:?] | + (?:in|instanceof){{identifier_break}} + ) + )) + jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' + block_comment: (?:/\*{{block_comment_contents}}\*/) method_lookahead: |- (?x)(?= (?: get|set|async ){{identifier_break}}(?!\s*:) | \* | {{property_name}} \s* (?:\(|<) ) - dec_digit: '[0-9_]' - dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' possible_arrow_function_begin: (?:\(|{{identifier_start}}|<) - dot_accessor: (?:\??\.) - jsdoc_block_tag: \@[^\n\t\f\v *@]+ - identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) - 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}} - jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' dec_integer: (?:0|[1-9]{{dec_digit}}*) + hex_digit: '[\h_]' + dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' + dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) + either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) + constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) + dollar_only_identifier: (?:\${{identifier_break}}) + left_expression_end_lookahead: (?!\s*[.\[\(]) func_lookahead: |- (?x: (?:async{{identifier_break}}{{nothing}})? function{{identifier_break}} ) - line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) - block_comment_contents: (?:(?:[^*]|\*(?!/))*) - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) + binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) + identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + oct_digit: '[0-7_]' + bin_digit: '[01_]' arrow_func_lookahead: |- (?x)(?: \s*(async\s*)? @@ -3239,12 +3262,14 @@ variables: )? \s*=> ) - oct_digit: '[0-7_]' - jsx_identifier_break: (?!{{jsx_identifier_part}}) - identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) - modifier: (?:static{{identifier_break}}) - hex_digit: '[\h_]' - binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) + nothing: (?x:(?:\s|{{block_comment}})*) + jsx_identifier_part: (?:{{identifier_part}}|-) + line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) + function_assignment_lookahead: |- + (?x:(?= + \s* = \s* + {{either_func_lookahead}} + )) property_name: >- (?x: {{identifier_name}} @@ -3253,6 +3278,18 @@ variables: | "(?:[^\\"]|\\.)*" | \[ .* \] ) + dec_digit: '[0-9_]' + modifier: (?:static{{identifier_break}}) + identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + reserved_word: |- + (?x: + break|case|catch|class|const|continue|debugger|default|delete|do|else| + export|extends|finally|for|function|if|import|in|instanceof|new|return| + super|switch|this|throw|try|typeof|var|void|while|with|yield| + enum| + null|true|false + ){{identifier_break}} + jsdoc_block_tag: \@[^\n\t\f\v *@]+ identifier_break: (?!{{identifier_part}}) class_element_name: |- (?x: @@ -3263,51 +3300,16 @@ variables: | \#{{non_reserved_identifier}} ) ) - nothing: (?x:(?:\s|{{block_comment}})*) - line_continuation_lookahead: >- - (?x:(?= - (?! \+\+ | -- ) - (?= - != | - [-+*/%><=&|^\[(;,.:?] | - (?:in|instanceof){{identifier_break}} - ) - )) - constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) - identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) - jsx_identifier_part: (?:{{identifier_part}}|-) - dollar_only_identifier: (?:\${{identifier_break}}) - block_comment: (?:/\*{{block_comment_contents}}\*/) - either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - left_expression_end_lookahead: (?!\s*[.\[\(]) - function_call_lookahead: >- - (?x:(?= - {{identifier_name}} - \s* - (?: - < - .* - > - \s* - )? - (?:{{dot_accessor}})? - \( - )) - function_assignment_lookahead: |- - (?x:(?= - \s* = \s* - {{either_func_lookahead}} - )) - bin_digit: '[01_]' - dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) - identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) + identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) + block_comment_contents: (?:(?:[^*]|\*(?!/))*) file_extensions: - js - jsx - es6 - babel +scope: source.js first_line_match: |- (?xi: ^ \s* // .*? -\*- .*? \bjsx\b .*? -\*- # editorconfig ) -name: JavaScript (Babel) diff --git a/tests/syntax_test_flow.js b/tests/syntax_test_flow.js index 9970aaa..a3fcb1a 100644 --- a/tests/syntax_test_flow.js +++ b/tests/syntax_test_flow.js @@ -455,3 +455,7 @@ class MyClass { // ^ punctuation.separator.comma // ^ punctuation.definition.generic.end // ^^ keyword.declaration.function + + (a < b && c <= d); +// ^ keyword.operator.comparison +// ^^ keyword.operator.comparison