diff --git a/JavaScript (Babel).sublime-syntax b/JavaScript (Babel).sublime-syntax index 62f3158..ccefc2b 100644 --- a/JavaScript (Babel).sublime-syntax +++ b/JavaScript (Babel).sublime-syntax @@ -1,118 +1,48 @@ %YAML 1.2 --- -variables: - dot_accessor: (?:\??\.) - non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) - block_comment: (?:/\*{{block_comment_contents}}\*/) - function_call_lookahead: >- - (?x:(?= - {{identifier_name}} - \s* - (?: - < - .* - > - \s* - )? - (?:{{dot_accessor}})? - \( - )) - identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) - jsx_identifier_break: (?!{{jsx_identifier_part}}) - identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) - jsdoc_block_tag: \@[^\n\t\f\v *@]+ - line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) - hex_digit: '[\h_]' - left_expression_end_lookahead: (?!\s*[.\[\(]) - bin_digit: '[01_]' - arrow_func_lookahead: |- - (?x)(?: - \s*(async\s*)? - (?: - {{non_reserved_identifier}} - |\( (?: [^()]|\([^()]*\) )* \) - ) - (?: - \s*: - \s*{{non_reserved_identifier}} - )? - \s*=> - ) - dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) - dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' - reserved_word: |- - (?x: - break|case|catch|class|const|continue|debugger|default|delete|do|else| - export|extends|finally|for|function|if|import|in|instanceof|new|return| - super|switch|this|throw|try|typeof|var|void|while|with|yield| - enum| - null|true|false - ){{identifier_break}} - identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) - method_lookahead: |- - (?x)(?= - (?: get|set|async ){{identifier_break}}(?!\s*:) - | \* - | {{property_name}} \s* (?:\(|<) - ) - modifier: (?:static{{identifier_break}}) - either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) - func_lookahead: |- - (?x: - (?:async{{identifier_break}}{{nothing}})? - function{{identifier_break}} - ) - line_continuation_lookahead: >- - (?x:(?= - (?! \+\+ | -- ) - (?= - != | - [-+*/%><=&|^\[(;,.:?] | - (?:in|instanceof){{identifier_break}} - ) - )) - jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' - jsx_identifier_part: (?:{{identifier_part}}|-) - identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) - oct_digit: '[0-7_]' - block_comment_contents: (?:(?:[^*]|\*(?!/))*) - dec_integer: (?:0|[1-9]{{dec_digit}}*) - identifier_break: (?!{{identifier_part}}) - property_name: >- - (?x: - {{identifier_name}} - | [0-9]+ - | '(?:[^\\']|\\.)*' - | "(?:[^\\"]|\\.)*" - | \[ .* \] - ) - binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) - dollar_only_identifier: (?:\${{identifier_break}}) - function_assignment_lookahead: |- - (?x:(?= - \s* = \s* - {{either_func_lookahead}} - )) - class_element_name: |- - (?x: - \+? - (?: - \*? - {{property_name}} - | \#{{non_reserved_identifier}} - ) - ) - constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) - dec_digit: '[0-9_]' - nothing: (?x:(?:\s+|{{block_comment}})*) -scope: source.js +file_extensions: + - js + - jsx + - es6 + - babel +name: JavaScript (Babel) +version: 2 contexts: - bare-arrow-function-fallback: + flow-arrow-function-return-type-annotation: + - match: ':' + scope: punctuation.separator.type.js + set: + - flow-type-meta + - flow-type-end-no-arrow + - flow-type-begin + - match: (?!\s*(?:$|:|//|/\*)) + pop: true + + await-expression: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js + + block-comment-body: - meta_include_prototype: false - - match: '' - push: - - immediately-pop-2 - - arrow-function-declaration + - meta_scope: comment.block.js + - include: block-comment-end + + variable-binding-object-key: + - match: '{{identifier_name}}(?=\s*:)' + scope: string.unquoted.js + pop: true + - match: '{{identifier_name}}(?=\s*:)' + pop: true + - include: literal-string + - include: computed-property-name + - include: variable-binding-name + - include: else-pop + + function-declaration-expect-function-keyword: + - match: function{{identifier_break}} + scope: keyword.declaration.function.js + pop: true + - include: else-pop support-property-node-module: - match: (?:children|exports|filename|id|loaded|parent|paths){{identifier_break}} @@ -122,615 +52,583 @@ contexts: scope: support.function.node.js pop: true - variable-binding-list-top: - - match: '{{line_ending_ahead}}' + import-expression-end: + - match: (?=\() + set: function-call-arguments + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js set: - - match: '{{line_continuation_lookahead}}' - set: variable-binding-top - - include: else-pop + - match: meta{{identifier_break}} + scope: variable.language.import.js + pop: true + - include: object-property + - include: else-pop + export-list: - match: ',' scope: punctuation.separator.comma.js - push: variable-binding-top - - include: else-pop - - branch-possible-parenthesized-arrow-function: - - meta_include_prototype: false - - match: '' push: - - detect-parenthesized-arrow - - parenthesized-expression + - import-export-alias + - export-item + - include: else-pop - jsx-body: + line-comment-triple-slash-body: - meta_include_prototype: false + - meta_scope: comment.line.triple-slash.js + - include: line-comment-end + flow-type-generic-arguments: - match: < - scope: punctuation.definition.tag.begin.js + scope: punctuation.definition.generic.begin.js set: - - meta_scope: meta.tag.js + - meta_scope: meta.generic.js + - match: '>' + scope: punctuation.definition.generic.end.js + pop: true + - include: flow-type-list - - match: / - scope: punctuation.definition.tag.begin.js - set: - - jsx-expect-tag-end - - jsx-tag-name + 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 - - match: (?=\S) - set: - - jsx-body - - jsx-tag-attributes - - jsx-tag-name + regular-function: + - match: (?={{func_lookahead}}) + set: function-declaration - - include: jsx-html-escapes - - include: jsx-interpolation - expression-statement-end: - - match: '{{line_ending_ahead}}' - set: - - match: '{{line_continuation_lookahead}}' - set: expression-statement-end - - include: else-pop - - include: expression-end + function-name-meta: + - meta_include_prototype: false + - meta_scope: entity.name.function.js + - include: immediately-pop - flow-type-existential: - - match: \* - scope: constant.language.type.existential.js + flow-type-utility: + - match: |- + (?x) (?: + Class|Function| + \$(?: + Keys|Values|ReadOnly|Exact|Diff|Rest|PropertyType|ElementType| + ObjMap|TupleMap|Call|Supertype|Subtype + ) + ){{identifier_break}} + scope: support.type.utility.js pop: true - import-export-from: - - match: from{{identifier_break}} - scope: keyword.control.import-export.js - set: literal-string - - include: else-pop + flow-type-class: + - match: '{{non_reserved_identifier}}' + scope: variable.other.class.js + pop: true - expect-label: + class-meta: - meta_include_prototype: false - - match: (?={{nothing}}{{identifier_name}}) - set: - - match: '{{non_reserved_identifier}}' - scope: variable.label.js - pop: true - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js variable.label.js - pop: true - - include: else-pop + - meta_scope: meta.class.js - include: immediately-pop - function-parameter-binding-object-destructuring: - - match: \{ - scope: punctuation.section.block.begin.js - set: - - meta_scope: meta.binding.destructuring.mapping.js - - match: ',' - scope: punctuation.separator.parameter.function.js - - match: \} - scope: punctuation.section.block.end.js + 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 - - include: function-parameter-binding-spread - - match: (?={{identifier_start}}|\[|'|") - push: - - initializer - - function-parameter-binding-object-alias - - object-literal-meta-key - - function-parameter-binding-object-key - - flow-less-than: - - match: < - scope: keyword.operator.comparison.js - set: expression-begin - - styled-component-end: - - match: \. - scope: punctuation.accessor.dot.js - push: styled-component-begin - - - match: (?=`) + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + - match: '"' + scope: punctuation.definition.string.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 - - support-property-ecma-array: - - match: (?:from|isArray|of){{identifier_break}} - scope: support.function.builtin.js - pop: true + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - meta_content_scope: variable.other.readwrite.js + - match: \" + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js - import-meta: - - meta_include_prototype: false - - meta_scope: meta.import.js - - include: immediately-pop + - match: (?=\[) + push: computed-property-name - variable-binding-name: - - match: (?={{non_reserved_identifier}}) - set: - - - meta_scope: meta.binding.name.js - - include: immediately-pop - - literal-variable + - include: else-pop - support-variable-console: - # https://console.spec.whatwg.org/ - - match: console{{identifier_break}} - scope: support.type.object.console.js + regexp: + - meta_include_prototype: false + - meta_scope: meta.string.js string.regexp.js + - match: / + scope: punctuation.definition.string.end.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: builtin-console-properties - - include: else-pop + - meta_include_prototype: false + - meta_content_scope: meta.string.js string.regexp.js + - match: '[gimyus]' + scope: keyword.other.js + - match: '[A-Za-z0-9]' # Ignore unknown flags for future-compatibility + - include: immediately-pop + - match: (?=.|\n) + push: + - meta_include_prototype: false + - match: (?=/) + pop: true + - include: scope:source.regexp.js - conditional: - - match: switch{{identifier_break}} - scope: keyword.control.conditional.switch.js - set: - - switch-meta - - switch-block - - expect-parenthesized-expression + flow-type-module-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: flow-type-module-contents + - include: else-pop - - match: do{{identifier_break}} - scope: keyword.control.loop.do-while.js + jsx-tag: + - match: < + scope: punctuation.definition.tag.begin.js set: - - do-while-meta - - do-while-condition - - statement + - jsx-meta + - jsx-tag-attributes-top - - match: for{{identifier_break}} - scope: keyword.control.loop.for.js + flow-type-typeof: + - match: typeof{{identifier_break}} + scope: keyword.operator.js set: - - for-meta - - block-scope - - for-condition - - for-await + - left-expression-end + - expression-begin - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: - - while-meta - - block-scope - - expect-parenthesized-expression + variable-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: variable-binding-pattern - - match: with{{identifier_break}} - scope: keyword.control.import.with.js - set: - - with-meta - - block-scope - - expect-parenthesized-expression + block-scope: + - include: block + - include: else-pop - - match: if{{identifier_break}} - scope: keyword.control.conditional.if.js - set: - - conditional-meta - - statement - - expect-parenthesized-expression + postfix-operators: + - match: -- + scope: keyword.operator.arithmetic.js + - match: \+\+ + scope: keyword.operator.arithmetic.js - - match: else\s+if{{identifier_break}} - scope: keyword.control.conditional.elseif.js + function-parameter-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - conditional-meta - - statement - - expect-parenthesized-expression + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - include: function-parameter-binding-list - - match: else{{identifier_break}} - scope: keyword.control.conditional.else.js - set: - - conditional-meta - - statement + import-export-from: + - match: from{{identifier_break}} + scope: keyword.control.import-export.js + set: literal-string + - include: else-pop - - match: try{{identifier_break}} - scope: keyword.control.exception.try.js - set: - - try-meta - - block-scope + 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 - - match: finally{{identifier_break}} - scope: keyword.control.exception.finally.js - set: - - finally-meta - - block-scope + - 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 - - match: catch{{identifier_break}} - scope: keyword.control.exception.catch.js + function-declaration-parameters: + - match: \( + scope: punctuation.section.group.begin.js set: - - catch-meta - - block-scope - - expect-parenthesized-expression - - 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 - - jsx-tag-attributes-top: - - meta_scope: meta.tag.js - - match: / - scope: punctuation.definition.tag.begin.js - set: - - - meta_scope: invalid.illegal.unmatched-tag.js - - include: immediately-pop - - jsx-expect-tag-end - - jsx-tag-name - - - match: (?=\S) - set: - - jsx-tag-attributes - - jsx-tag-name - - import-brace: - - include: flow-type-import-type + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - include: function-parameter-binding-list - - meta_scope: meta.block.js - - include: comma-separator - - match: \} - scope: punctuation.section.block.end.js + support-property-ecma-number: + - match: (?:EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY){{identifier_break}} + scope: support.constant.builtin.js + pop: true + - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - push: import-export-alias - - match: \* - scope: constant.other.js - push: import-export-alias - - include: else-pop - decorator-expression-begin: - - include: decorator-name - - include: expression-begin + script: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js + # Don't pop or embedding could break. - switch-meta: - - meta_include_prototype: false - - meta_scope: meta.switch.js - - include: immediately-pop + - include: statements - jsx-interpolation-plain: - - match: '{' - scope: punctuation.definition.interpolation.begin.js + literal-string: + - match: "'" + scope: punctuation.definition.string.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 - - new-target: - - match: \. - scope: punctuation.accessor.dot.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.single.js + - match: \' + scope: punctuation.definition.string.end.js + pop: true + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + - match: '"' + scope: punctuation.definition.string.begin.js set: - - match: target{{identifier_break}} - scope: variable.language.target.js + - meta_include_prototype: false + - meta_scope: meta.string.js string.quoted.double.js + - match: \" + scope: punctuation.definition.string.end.js pop: true - - include: else-pop + - match: \n + scope: invalid.illegal.newline.js + pop: true + - include: string-content + flow-type-end: + - include: flow-type-operators + - include: flow-type-generic-arguments - include: else-pop - constructor-body-expect-class-end: - - include: property-access - - include: else-pop + function-meta: + - meta_include_prototype: false + - meta_scope: meta.function.js + - include: immediately-pop - import-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - import-item + flow-type-alias-initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: + - flow-type-meta + - flow-type - include: else-pop - - for-await: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js - pop: true + object-literal-property-check: + - match: (?=\() + fail: object-literal-property - include: else-pop - literal-string-template-custom-comments: [] - class-element-modifier: - - match: '{{modifier}}' - scope: storage.modifier.js + flow-type-alias: + - match: (?=type{{identifier_break}}) set: - - match: (?={{class_element_name}}|\*) - pop: true - - match: (?=\S) - fail: class-element-modifier - - detect-parenthesized-arrow: - - match: (?=:) - pop: true - branch_point: flow-arrow-function-return-type - branch: - - flow-detect-arrow-function-return-type - - immediately-pop-2 - - - match: (?==>) - fail: parenthesized-arrow-function - - match: (?=\S) - pop: 2 + - - 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 - support-property-node-process: - - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} - scope: support.constant.node.js - pop: true - - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} - scope: support.function.node.js - pop: true + - match: (?=\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-condition: - - match: \( - scope: punctuation.section.group.js + support-variable-ecma: + - match: Array{{identifier_break}} + scope: support.class.builtin.js set: - - for-condition-end - - for-condition-contents - - include: else-pop - - decorator: - - match: '@' - scope: punctuation.definition.annotation.js - push: - - decorator-meta - - decorator-expression-end - - decorator-expression-begin + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-array + - include: object-property + - include: else-pop + - include: else-pop - flow-type-tuple: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: ArrayBuffer{{identifier_break}} + scope: support.class.builtin.js set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-arraybuffer + - include: object-property + - include: else-pop + - include: else-pop - variable-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js + - match: Atomics{{identifier_break}} + scope: support.constant.builtin.js set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: variable-binding-spread - - include: variable-binding-list + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-atomics + - include: object-property + - include: else-pop + - include: else-pop - import-export-alias: - - match: as{{identifier_break}} - scope: keyword.control.import-export.js + - match: BigInt{{identifier_break}} + scope: support.class.builtin.js set: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - pop: true - - match: '{{identifier_name}}' - scope: variable.other.readwrite.js - pop: true + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-bigint + - include: object-property + - include: else-pop - include: else-pop - - include: else-pop - - literal-variable: - - include: special-identifier - - include: support - - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + - match: Date{{identifier_break}} + scope: support.class.builtin.js set: - - function-name-meta - - literal-variable-base - - - match: '{{constant_identifier}}(?=\s*(?:{{dot_accessor}}|\[))' - scope: support.class.js - pop: true - - - match: '{{function_call_lookahead}}' - set: call-function-name - - - include: literal-variable-base + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-date + - include: object-property + - include: else-pop + - include: else-pop - flow-type-object: - - match: \{\| - scope: punctuation.section.block.begin.js + - match: JSON{{identifier_break}} + scope: support.constant.builtin.js set: - - meta_scope: meta.type.object.exact.js - - match: \|\} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-json + - include: object-property + - include: else-pop + - include: else-pop - - match: \{ - scope: punctuation.section.block.begin.js + - match: Math{{identifier_break}} + scope: support.constant.builtin.js set: - - meta_scope: meta.type.object.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: flow-type-object-contents - - flow-type-end: - - include: flow-type-operators - - include: flow-type-generic-arguments - - include: else-pop - - 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 - - variable-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: variable-binding-pattern + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-math + - include: object-property + - include: else-pop + - include: else-pop - function-declaration-expect-generator-star: - - match: \* - scope: keyword.declaration.generator.js - pop: true - - 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 - for-condition-end: - - meta_scope: meta.group.js + - 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: \) - scope: punctuation.section.group.js - pop: true + - 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 - export-list: - - match: ',' - scope: punctuation.separator.comma.js - push: - - import-export-alias - - export-item - - 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 - 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 + - 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 - styled-components: - - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}}) + - match: String{{identifier_break}} + scope: support.class.builtin.js set: - - styled-component-end - - styled-component-begin - - match: (?=keyframes{{identifier_break}}) + - 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: - - styled-component-keyframes-end - - styled-component-begin - main: - - include: comments-top-level + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-symbol + - include: object-property + - include: else-pop + - include: else-pop - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js - # Don't pop or embedding could break. + - match: |- + (?x: + (?: + BigInt64| + BigUint64| + Float(?:32|64)| + Int(?:8|16|32)| + Uint(?:8|16|32|32Clamped) + ) + Array{{identifier_break}} + ) + scope: support.class.builtin.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-ecma-typedarray + - include: object-property + - include: else-pop + - include: else-pop - - include: statements + # 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 - function-declaration-expect-async: - - match: async{{identifier_break}} - scope: keyword.declaration.async.js + - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} + scope: support.function.js pop: true - - include: else-pop - function-meta: + do-while-meta: - meta_include_prototype: false - - meta_scope: meta.function.js + - meta_scope: meta.do-while.js - include: immediately-pop - class-field-check: - - match: (?=[(<]) - fail: class-field - - include: else-pop - - initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: expression-no-comma + expect-parenthesized-expression: + - include: parenthesized-expression - 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 - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: '"' - scope: punctuation.definition.string.begin.js - set: - - meta_include_prototype: false - - meta_scope: meta.string.js string.quoted.double.js - - meta_content_scope: variable.other.readwrite.js - - match: \" - scope: punctuation.definition.string.end.js - pop: true - - match: \n - scope: invalid.illegal.newline.js - pop: true - - include: string-content - - match: (#)({{identifier_name}}) + 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.definition.variable.js - 2: variable.other.readwrite.js + 1: punctuation.separator.decimal.js + 2: punctuation.separator.decimal.js + pop: true - - match: (?=\[) - push: computed-property-name + # 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 - - include: else-pop + - match: (0[Xx])({{hex_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.hexadecimal.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: true - catch-meta: - - meta_include_prototype: false - - meta_scope: meta.catch.js - - include: immediately-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 + pop: true - function-parameter-binding-array-destructuring: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.binding.destructuring.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: function-parameter-binding-list + - match: (0[Bb])({{bin_digit}}*)(n)?{{identifier_break}} + scope: meta.number.integer.binary.js + captures: + 1: constant.numeric.base.js + 2: constant.numeric.value.js + 3: constant.numeric.suffix.js + pop: true + + - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} + scope: meta.number.integer.decimal.js + captures: + 1: constant.numeric.value.js + 2: constant.numeric.suffix.js + pop: true + + # illegal numbers + - match: 0[Xx]{{identifier_part}}+ + scope: invalid.illegal.numeric.hexadecimal.js + pop: true + + - match: 0[Bb]{{identifier_part}}+ + scope: invalid.illegal.numeric.binary.js + pop: true + + - match: 0{{identifier_part}}+ + scope: invalid.illegal.numeric.octal.js + pop: true + + - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' + scope: invalid.illegal.numeric.decimal.js + pop: true literal-variable-base: - match: '{{dollar_only_identifier}}' @@ -749,182 +647,96 @@ contexts: pop: true - include: literal-private-variable - flow-type-object-indexer-type: - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: flow-type-list - - custom-templates-default: - - include: literal-string-template + 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 - class-body-contents: - - meta_scope: meta.block.js + 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 - - match: \} - scope: punctuation.section.block.end.js + flow-jsx-tag-check: + - match: (?=[:,]) + fail: arrow-function + - include: else-pop + expression-end-no-comma: + - match: (?=,) pop: true + - include: expression-end - - match: \; - scope: punctuation.terminator.statement.js - - - include: decorator - - - match: constructor{{identifier_break}} - scope: entity.name.function.constructor.js - push: - - function-meta - - function-declaration-expect-body - - function-declaration-expect-parameters - - - include: class-element-modifiers - - - match: |- - (?x)(?= - \#? {{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 + immediately-pop: + - match: '' + pop: true - object-literal: - - match: \{ - scope: punctuation.section.block.begin.js - set: object-literal-contents + conditional-meta: + - meta_include_prototype: false + - meta_scope: meta.conditional.js + - include: immediately-pop - expression-end-no-in: - - match: (?=in{{identifier_break}}) - pop: true - - include: expression-end + with-meta: + - meta_include_prototype: false + - meta_scope: meta.with.js + - include: immediately-pop - special-name: - - match: true{{identifier_break}} - scope: constant.language.boolean.true.js + object-property-base: + - match: '{{dollar_only_identifier}}' + scope: meta.property.object.dollar.only.js punctuation.dollar.js pop: true - - match: false{{identifier_break}} - scope: constant.language.boolean.false.js + - match: '{{dollar_identifier}}' + scope: meta.property.object.dollar.js + captures: + 1: punctuation.dollar.js pop: true - - match: null{{identifier_break}} - scope: constant.language.null.js + - match: '{{identifier_name}}' + scope: meta.property.object.js pop: true - - match: super{{identifier_break}} - scope: variable.language.super.js + - match: '{{identifier_part}}+{{identifier_break}}' + scope: invalid.illegal.illegal-identifier.js pop: true - - match: this{{identifier_break}} - scope: variable.language.this.js + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: meta.property.object.js pop: true - import-check-branch: - - match: (?=[.(]) # Recovery for import expressions - fail: import-statement - - include: else-pop - - function-parameter-binding-name: + function-declaration-expect-name: - match: '{{non_reserved_identifier}}' - scope: meta.binding.name.js variable.parameter.function.js - - match: '{{identifier_name}}' - scope: invalid.illegal.identifier.js meta.binding.name.js variable.parameter.function.js - - support-property-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 + scope: entity.name.function.js pop: true - - match: (?:isFinite|isInteger|isNaN|isSafeInteger|NaN|parseFloat|parseInt){{identifier_break}} - scope: support.function.builtin.js - pop: true - - immediately-pop-2: - - meta_include_prototype: false - - match: '' - pop: 2 - - support-property-ecma-promise: - - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} - scope: support.function.builtin.js - pop: true - - decorator-meta: - - meta_include_prototype: false - - meta_scope: meta.annotation.js - - include: immediately-pop - - decorator-name: - - match: '{{identifier_name}}{{left_expression_end_lookahead}}' - scope: variable.annotation.js - pop: true - - function-parameter: - - match: '' - set: - - initializer - - function-parameter-binding-pattern - - expression: - - meta_include_prototype: false - - match: '' - set: [expression-end, expression-begin] - - parenthesized-arrow-function-fallback: - - meta_include_prototype: false - - match: '' - push: - - immediately-pop-2 - - arrow-function-declaration - - flow-type-meta: - - meta_scope: meta.flow-type.js - - include: immediately-pop - - flow-type-module-body: - - match: \{ - scope: punctuation.section.block.begin.js - set: flow-type-module-contents - include: else-pop - function-declaration-expect-function-keyword: - - match: function{{identifier_break}} - scope: keyword.declaration.function.js - pop: true - - include: else-pop - - expect-semicolon: - - match: \; - scope: punctuation.terminator.statement.js - pop: true - - include: else-pop - - class-field: - - match: '' - set: - - initializer - - flow-type-annotation - - class-field-check - - field-name - - flow-type-annotation: - - match: ':' - scope: punctuation.separator.type.js - set: - - flow-type-meta - - flow-type - - match: (?!\s*(?:$|:|//|/\*)) - pop: true - constructor: - match: new{{identifier_break}} scope: keyword.operator.word.new.js @@ -938,198 +750,200 @@ contexts: - constructor-body-expect-class-end - constructor-body-expect-class-begin - function-block: - - match: \{ - scope: punctuation.section.block.begin.js + block-comment-end: + - match: \*+/ + scope: punctuation.definition.comment.end.js + pop: true + + literal-call: + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements + - call-function-meta + - function-call-arguments + - literal-variable - flow-type-object-value: - - match: (\?)?(:) - captures: - 1: storage.modifier.optional.js - 2: punctuation.separator.key-value.js - set: flow-type - - include: else-pop + - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() + set: + - call-method-meta + - function-call-arguments + - call-path + - literal-variable - restricted-production: + shebang-body: - meta_include_prototype: false - - match: '{{line_ending_ahead}}' + - 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 + + statement: + - include: flow-type-declare + - include: flow-type-alias + + - match: \; + scope: punctuation.terminator.statement.empty.js pop: true - - match: '' - set: expression-statement - variable-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: variable-binding-pattern - - include: else-pop + - include: declaration + - include: import-statement-or-import-meta + - include: export-statement + - include: conditional + - include: block + - include: label - flow-type-module-meta: - - meta_scope: meta.module.js - - include: immediately-pop + - match: break{{identifier_break}} + scope: keyword.control.flow.break.js + set: + - expect-semicolon + - expect-label - parenthesized-expression: - - match: \( - scope: punctuation.section.group.begin.js + - match: continue{{identifier_break}} + scope: keyword.control.flow.continue.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 + - expect-semicolon + - expect-label - 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 + - match: debugger{{identifier_break}} + scope: keyword.control.flow.debugger.js + set: expect-semicolon - ternary-operator-expect-colon: - - match: ':' - scope: keyword.operator.ternary.js - set: expression-no-comma - - include: else-pop + - match: return{{identifier_break}} + scope: keyword.control.flow.return.js + set: restricted-production - switch-block: - - match: \{ - scope: punctuation.section.block.begin.js - set: switch-block-contents - - include: else-pop + - match: throw{{identifier_break}} + scope: keyword.control.flow.throw.js + set: restricted-production - jsx-expect-tag-end: - - meta_content_scope: meta.tag.js - - match: '>' - scope: meta.tag.js punctuation.definition.tag.end.js - pop: true + - include: decorator + + - include: expression-statement + + arrow-function-expect-parameters: + - match: (?={{identifier_start}}) + set: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.js + - match: '{{identifier_name}}' + scope: variable.parameter.function.js + pop: true + - include: function-declaration-parameters - include: else-pop - support-property-ecma-symbol: - - match: (?:asyncIterator|hasInstance|isConcatSpreadable|iterator|match|replace|search|species|split|toPrimitive|toStringTag|unscopeables){{identifier_break}} - scope: support.constant.builtin.js + styled-component-begin: + - match: '{{non_reserved_identifier}}(?=\s*\()' + scope: variable.function.js pop: true - - match: (?:for|keyFor){{identifier_break}} - scope: support.function.builtin.js + + - match: '{{non_reserved_identifier}}(?=\s*`)' + scope: variable.function.tagged-template.js pop: true - inherited-class-name: - - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' - scope: entity.other.inherited-class.js + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.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 + - include: else-pop + jsx-tag-attributes: + - meta_scope: meta.tag.attributes.js - jsdoc-block-tag: - - match: '{{jsdoc_block_tag}}' - scope: entity.other.attribute-name.documentation.js - pop: 1 - - match: (?=\S)|$ - pop: 1 + - match: '>' + scope: punctuation.definition.tag.end.js + set: jsx-body - literal-private-variable: - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: variable.other.readwrite.js - pop: true + - match: / + scope: punctuation.definition.tag.end.js + set: jsx-expect-tag-end - flow-detect-arrow-after-return-type: - - match: (?==>) - fail: parenthesized-arrow-function - - match: (?=\S) - fail: flow-arrow-function-return-type + - include: jsx-interpolation - expect-case-colon: - - match: ':' - scope: punctuation.separator.js - pop: true - - include: else-pop + - match: '{{jsx_identifier}}' + scope: entity.other.attribute-name.js - 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 + - match: '=' + scope: punctuation.separator.key-value.js + push: jsx-attribute-value - call-function-meta: + for-meta: - meta_include_prototype: false - - meta_scope: meta.function-call.js - - include: else-pop + - meta_scope: meta.for.js + - include: immediately-pop - left-expression-end: - - include: expression-break + 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 - - match: (?=`) - push: literal-string-template + import-meta-expression: + - match: import{{identifier_break}} + scope: keyword.import.js + set: import-expression-end - - match: (?=(?:{{dot_accessor}})?\() - push: function-call-arguments + line-comment-other-body: + - meta_include_prototype: false + - meta_scope: comment.line.other.js + - include: line-comment-end - - include: property-access + 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: else-pop + - match: (?=\S) + set: + - - include: for-of-rest + - match: (?=\S) + set: for-oldstyle-rest + - expression-end-no-in + - expression-begin + + inherited-class-expression-end: + - include: flow-type-generic-arguments - 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 + push: + - include: inherited-class-name - include: object-property - - 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 + - include: left-expression-end - jsx-interpolation: - - match: (?={/\*) - branch_point: jsx-interpolation-comment - branch: - - jsx-interpolation-comment - - jsx-interpolation-plain - - match: (?={) - push: jsx-interpolation-plain + function-parameter-binding-spread: + - match: \.\.\. + scope: keyword.operator.spread.js + push: function-parameter - variable-declaration: - - match: (?:const|let|var){{identifier_break}} - scope: keyword.declaration.js - set: - - expect-semicolon - - variable-binding-list-top - - variable-binding-top + comma-separator: + - match: ',' + scope: punctuation.separator.comma.js + + support-property-ecma-array: + - match: (?:from|isArray|of){{identifier_break}} + scope: support.function.builtin.js + pop: true support-variable-dom: - match: XMLHttpRequest{{identifier_break}} @@ -1142,737 +956,1317 @@ contexts: scope: support.function.dom.js pop: true - object-literal-element: - - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' - scope: variable.other.readwrite.js + flow-type-primitive: + - match: boolean{{identifier_break}} + scope: support.type.primitive.boolean.js pop: true - - match: (?=\S) + + - match: number{{identifier_break}} + scope: support.type.primitive.number.js pop: true - branch_point: object-literal-property + + - 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 + + class-element-modifiers: + - match: '' + pop: true + branch_point: class-element-modifier branch: - - object-literal-property - - method-declaration + - class-element-modifier + - class-element - 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 + 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 - - 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 + expression-break: + - match: (?=[;})\]]) + pop: true - - match: Atomics{{identifier_break}} - scope: support.constant.builtin.js + method-declaration: + - meta_include_prototype: false + - match: '' set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-atomics - - include: object-property - - include: else-pop - - include: else-pop + - function-meta + - function-declaration-expect-body + - flow-type-annotation + - function-declaration-expect-parameters + - flow-type-generic-parameters + - method-name + - method-declaration-expect-asterisk - - match: 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 + initializer: + - match: '=' + scope: keyword.operator.assignment.js + set: expression-no-comma + - 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 + flow-type-module-meta: + - meta_scope: meta.module.js + - include: immediately-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 + string-content: + - match: \\\n + scope: constant.character.escape.newline.js + - match: \\(?:x\h\h|u\h\h\h\h|.) + scope: constant.character.escape.js - - match: 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 + class-element: + - match: '' + pop: true + branch_point: class-field + branch: + - class-field + - method-declaration - - match: Number{{identifier_break}} - scope: support.class.builtin.js + literal-variable: + - include: special-identifier + - include: support + + - match: (?={{identifier_name}}{{function_assignment_lookahead}}) + set: + - 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 + + 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 + + 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 + + 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 + + for-await: + - match: await{{identifier_break}} + scope: keyword.control.flow.await.js + pop: true + - include: else-pop + + constructor-body-expect-class-begin: + - match: (?={{non_reserved_identifier}}\s*\() + set: + - include: support + - match: '{{dollar_only_identifier}}' + scope: variable.type.dollar.only.js punctuation.dollar.js + pop: true + - match: '{{dollar_identifier}}' + scope: variable.type.dollar.js + captures: + 1: punctuation.dollar.js + pop: true + - match: '{{identifier_name}}' + scope: variable.type.js + pop: true + - include: else-pop + + - include: expression-begin + + 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: - - include: support-property-ecma-number - - include: object-property - - include: else-pop + set: builtin-console-properties - 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 + flow-type: + - match: '' + set: + - flow-type-end + - flow-type-begin + + 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 + + finally-meta: + - meta_include_prototype: false + - meta_scope: meta.finally.js + - include: immediately-pop + + class-name: + - match: '{{non_reserved_identifier}}' + scope: entity.name.class.js + set: flow-type-generic-parameters + - include: else-pop + + flow-type-import-type: + - match: type{{identifier_break}} + scope: keyword.declaration.js + + - match: typeof{{identifier_break}} + scope: keyword.operator.js + + 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 + + computed-property-name: + - match: \[ + scope: punctuation.section.brackets.begin.js + set: + - match: \] + scope: punctuation.section.brackets.end.js + pop: true + - match: (?=\S) + push: expression + + decorator-expression-end: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: + - include: decorator-name + - include: object-property + + - include: left-expression-end + + decorator-expression-begin: + - include: decorator-name + - include: expression-begin + + class: + - match: class{{identifier_break}} + scope: keyword.declaration.class.js + set: + - class-meta + - class-body + - class-extends + - class-name + + literal-string-template-custom-lookahead: [] + function-parameter: + - match: '' + set: + - initializer + - function-parameter-binding-pattern + + block-meta: + - meta_include_prototype: false + - meta_scope: meta.block.js + - include: immediately-pop + + switch-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: switch-block-contents + - include: else-pop + + jsx-html-escapes: + - match: (&)#?[[:alnum:]]+(;) + scope: constant.character.escape.js + captures: + 1: punctuation.definition.entity.js + 2: punctuation.definition.entity.js + + line-comment-end: + - match: (//+)?\n + captures: + 1: punctuation.definition.comment.js + pop: 1 + + flow-type-list: + - include: comma-separator + - match: (?=\S) + push: flow-type + + jsx-expect-tag-end: + - meta_content_scope: meta.tag.js + - match: '>' + scope: meta.tag.js punctuation.definition.tag.end.js + pop: true + - include: else-pop + + for-oldstyle-rest: + - match: (?=\)) + pop: true + - match: ; + scope: punctuation.separator.expression.js + - match: (?=\S) + push: expression + + variable-binding-list: + - include: comma-separator + - match: (?={{binding_pattern_lookahead}}) + push: + - initializer + - variable-binding-pattern + - include: else-pop + + export-brace: + - meta_scope: meta.block.js + - include: comma-separator + - match: \} + scope: punctuation.section.block.end.js + pop: true + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + push: import-export-alias + - match: \* + scope: constant.other.js + push: import-export-alias + - include: else-pop + + import-list: + - match: ',' + scope: punctuation.separator.comma.js + push: + - import-export-alias + - import-item + - include: else-pop + + object-literal-meta-key: + - meta_scope: meta.mapping.key.js + - include: else-pop + + class-field-check: + - match: (?=[(<]) + fail: class-field + - include: else-pop + + expression-statement-end: + - match: '{{line_ending_ahead}}' + set: + - match: '{{line_continuation_lookahead}}' + set: expression-statement-end + - include: else-pop + - include: expression-end + + support-property-ecma-bigint: + - match: (?:asUintN|asIntN){{identifier_break}} + scope: support.function.builtin.js + pop: true + + new-target: + - match: \. + scope: punctuation.accessor.dot.js + set: + - match: target{{identifier_break}} + scope: variable.language.target.js + pop: true + - include: else-pop + + - include: else-pop + + 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-special: + - match: any{{identifier_break}} + scope: support.type.any.js + pop: true + + - match: mixed{{identifier_break}} + scope: support.type.mixed.js + pop: true + + yield-expression: + - match: yield{{identifier_break}} + scope: keyword.control.flow.yield.js + set: + - match: $ + pop: true + - match: \* + scope: keyword.generator.asterisk.js + set: expression-begin + - match: (?=\S) + set: expression-begin + + 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 + + flow-type-object-value: + - match: (\?)?(:) + captures: + 1: storage.modifier.optional.js + 2: punctuation.separator.key-value.js + set: flow-type + - include: else-pop + + function-declaration-expect-body: + - include: function-block + - include: else-pop + + class-body: + - match: \{ + scope: punctuation.section.block.begin.js + set: class-body-contents + + - include: else-pop + + jsx-interpolation: + - match: (?={/\*) + branch_point: jsx-interpolation-comment + branch: + - jsx-interpolation-comment + - jsx-interpolation-plain + - match: (?={) + push: jsx-interpolation-plain + + parenthesized-expression: + - match: \( + scope: punctuation.section.group.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - match: (?=:) + push: flow-type-annotation + - match: (?=\S) + push: expression + + import-export-alias: + - match: as{{identifier_break}} + scope: keyword.control.import-export.js + set: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + pop: true + - match: '{{identifier_name}}' + scope: variable.other.readwrite.js + pop: true + - include: else-pop + - include: else-pop + + literal-string-template-custom-comments: [] + 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 + + - 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 + + function-declaration-expect-async: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js + pop: true + - include: else-pop + + restricted-production: + - meta_include_prototype: false + - match: '{{line_ending_ahead}}' + pop: true + - match: '' + set: expression-statement + + support-property-node-process: + - match: (?:arch|argv|argv0|channel|config|connected|debugPort|env|execArgv|execPath|exitCode|mainModule|noDeprecation|pid|platform|ppid|release|stderr|stdin|stdout|throwDeprecation|title|traceDeprecation|version|versions){{identifier_break}} + scope: support.constant.node.js + pop: true + - match: (?:abort|chdir|cpuUsage|cwd|disconnect|dlopen|emitWarning|exit|getegid|geteuid|getgit|getgroups|getuid|hasUncaughtExceptionCaptureCallback|hrtime|initGroups|kill|memoryUsage|nextTick|send|setegid|seteuid|setgid|setgroups|setuid|hasUncaughtExceptionCaptureCallback|umask|uptime){{identifier_break}} + scope: support.function.node.js + pop: true + + flow-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-object-contents: + - include: comma-separator + - match: ; + scope: punctuation.separator.semicolon.js + - match: '{{method_lookahead}}' + push: method-declaration + - match: \+ + scope: storage.modifier.variance.js + - match: '{{non_reserved_identifier}}' + scope: meta.object-literal.key.js + push: flow-type-object-value + - match: \[ + scope: punctuation.section.brackets.begin.js + push: + - flow-type-object-value + - flow-type-object-indexer-type + - flow-type-object-indexer-label + + 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 + + jsx-meta: + - meta_include_prototype: false + - meta_scope: meta.jsx.js + - include: immediately-pop + + variable-binding-object-destructuring: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.binding.destructuring.mapping.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: variable-binding-spread + - match: (?={{identifier_start}}|\[|'|") + push: + - initializer + - variable-binding-object-alias + - object-literal-meta-key + - variable-binding-object-key + - include: comma-separator + + for-of-rest: + - match: (?:of|in){{identifier_break}} + scope: keyword.operator.word.js + set: expression + + import-check-branch: + - match: (?=[.(]) # Recovery for import expressions + fail: import-statement + - include: else-pop + + branch-possible-arrow-function: + - match: (?=<) + set: jsx-tag + + - match: (?=\() + set: + - detect-arrow + - flow-detect-arrow-function-return-type + - parenthesized-expression + + - meta_include_prototype: false + - match: (?=\() + set: + - detect-arrow + - parenthesized-expression + - match: (?={{identifier_start}}) + set: + - detect-arrow + - literal-variable + + constructor-body-expect-class-end: + - include: property-access + - include: else-pop + + flow-type-module-contents: + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: main + + jsx-tag-name-component-possibly-native: + - match: '[[:lower:]]{{jsx_identifier_part}}*{{jsx_identifier_break}}(?!{{nothing}}[.:])' + scope: entity.name.tag.native.js + pop: true + - include: jsx-tag-name-component + + shebang: + - meta_include_prototype: false + - match: ^\#! + scope: punctuation.definition.comment.js + set: shebang-body + - match: ^|(?=\S) # Note: Ensure to highlight shebang if the syntax is embedded. + pop: 1 + + variable-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: variable-binding-pattern + - include: else-pop + + jsdoc-block-tag: + - match: '{{jsdoc_block_tag}}' + scope: entity.other.attribute-name.documentation.js + pop: 1 + - match: (?=\S)|$ + pop: 1 + + function-declaration-expect-parameters: + - include: function-declaration-parameters + - include: else-pop + + flow-type-operators: + - match: \|(?!\}) + scope: keyword.operator.type.union.js + push: flow-type-begin + - match: \& + scope: keyword.operator.type.intersection.js + push: flow-type-begin + - match: => + scope: keyword.declaration.function.arrow.js + push: flow-type-begin + - match: \? + scope: storage.modifier.maybe.js + push: flow-type-begin + - match: \. + scope: punctuation.separator.accessor.js + push: flow-type-begin + + - match: \[\] + scope: storage.modifier.array.js + - match: '%checks{{identifier_break}}' + scope: storage.modifier.checks.js + + ternary-operator: + - match: \?(?=[^.]|\.[0-9]) + scope: keyword.operator.ternary.js + set: + - ternary-operator-expect-colon + - expression-no-comma + + function-parameter-binding-object-alias: + - match: ':' + scope: punctuation.separator.key-value.js + set: function-parameter-binding-pattern + - include: else-pop + + function-parameter-binding-list: + - match: ',' + scope: punctuation.separator.parameter.function.js + - include: function-parameter-binding-spread + - match: (?={{binding_pattern_lookahead}}) + push: function-parameter + - include: else-pop + + 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 + + label: + - match: ({{identifier_name}})\s*(:) + captures: + 1: entity.name.label.js + 2: punctuation.separator.js + + binary-operators: + - match: instanceof{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: in{{identifier_break}} + scope: keyword.operator.js + push: expression-begin + - match: =(?![=>]) + scope: keyword.operator.assignment.js + push: expression-begin + - match: |- + (?x) + %= | # assignment right-to-left both + &= | # assignment right-to-left both + \*= | # assignment right-to-left both + \+= | # assignment right-to-left both + -= | # assignment right-to-left both + /= | # assignment right-to-left both + \^= | # assignment right-to-left both + \|= | # assignment right-to-left both + <<= | # assignment right-to-left both + >>= | # assignment right-to-left both + >>>= | # assignment right-to-left both + &&= | + \|\|= | + \?\?= + scope: keyword.operator.assignment.augmented.js + push: expression-begin + - match: '&&|\|\||\?\?' + scope: keyword.operator.logical.js + push: expression-begin + - match: |- + (?x) + << | # bitwise-shift left-to-right both + >>> | # bitwise-shift left-to-right both + >> | # bitwise-shift left-to-right both + & | # bitwise-and left-to-right both + \^ | # bitwise-xor left-to-right both + \| # bitwise-or left-to-right both + scope: keyword.operator.bitwise.js + push: expression-begin + - match: |- + (?x) + <= | # comparison left-to-right both + >= | # comparison left-to-right both + < | # comparison left-to-right both + > # comparison left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + === | # equality left-to-right both + !== | # equality left-to-right both + == | # equality left-to-right both + != # equality left-to-right both + scope: keyword.operator.comparison.js + push: expression-begin + - match: |- + (?x) + / | # division left-to-right both + % | # modulus left-to-right both + \* | # multiplication left-to-right both + \+ | # addition left-to-right both + - # subtraction left-to-right both + scope: keyword.operator.arithmetic.js + push: expression-begin + - match: ',' + scope: keyword.operator.comma.js # Comma operator, not punctuation. + push: expression-begin + + export-extended: + - include: flow-type-export-type - - 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 + - include: declaration - - match: Proxy{{identifier_break}} - scope: support.class.builtin.js + - match: default{{identifier_break}} + scope: keyword.control.import-export.js set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-proxy - - include: object-property - - include: else-pop - - include: else-pop + - include: declaration + - match: (?=\S) + set: expression-statement - - match: Reflect{{identifier_break}} - scope: support.constant.builtin.js + - match: (?=\S) set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-reflect - - include: object-property - - include: else-pop - - include: else-pop + - expect-semicolon + - import-export-from + - export-list + - import-export-alias + - export-item - - 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 + jsx-tag-name-meta: + - clear_scopes: 1 + - meta_include_prototype: false + - meta_scope: meta.tag.name.js + - include: immediately-pop - - match: Symbol{{identifier_break}} - scope: support.class.builtin.js + expression-statement: + - match: (?=\S) set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-symbol - - include: object-property - - include: else-pop - - include: else-pop + - expect-semicolon + - expression-statement-end + - expression-begin - - match: |- - (?x: - (?: - BigInt64| - BigUint64| - Float(?:32|64)| - Int(?:8|16|32)| - Uint(?:8|16|32|32Clamped) - ) - Array{{identifier_break}} - ) - scope: support.class.builtin.js + variable-binding-name: + - match: (?={{non_reserved_identifier}}) set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-ecma-typedarray - - include: object-property - - include: else-pop - - include: else-pop - - # Classes with no constructor properties - - match: (?:Boolean|DataView|Function|Map|RegExp|Set|WeakMap|WeakSet){{identifier_break}} - scope: support.class.builtin.js - pop: true - - match: (?:Eval|Range|Reference|Syntax|Type|URI)?Error{{identifier_break}} - scope: support.class.builtin.js - pop: true - - - match: (?:eval|isFinite|isNaN|parseFloat|parseInt|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent){{identifier_break}} - scope: support.function.js - pop: true - - support-property-ecma-date: - - match: (?:now|parse|UTC){{identifier_break}} - scope: support.function.builtin.js - pop: true - - literal-string-template-custom-lookahead: [] - object-literal-meta-key: - - meta_scope: meta.mapping.key.js - - include: else-pop - - support-property: - - include: support-property-ecma + - - meta_scope: meta.binding.name.js + - include: immediately-pop + - literal-variable - 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 + ternary-operator-expect-colon: + - match: ':' + scope: keyword.operator.ternary.js + set: expression-no-comma - include: else-pop - object-property-name: - - match: '{{identifier_name}}' - scope: string.unquoted.js - pop: true - - - match: (?=\[) - set: computed-property-name - - - include: literal-string - - include: literal-number - - - match: '{{identifier_name}}' + jsx-tag-name-component: + - match: '{{jsx_identifier}}' + scope: entity.name.tag.js pop: true - - include: else-pop - expect-parenthesized-expression: - - include: parenthesized-expression + class-extends: + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - inherited-class-expression-end + - inherited-class-expression-begin - include: else-pop - regular-function: - - match: (?={{func_lookahead}}) - set: function-declaration - - variable-binding-top: - - match: (?={{binding_pattern_lookahead}}) + async-arrow-function: + - match: async{{identifier_break}} + scope: keyword.declaration.async.js set: - - initializer - - variable-binding-pattern - - include: else-pop + - function-meta + - arrow-function-expect-body + - arrow-function-expect-arrow-or-fail-async + - arrow-function-expect-parameters - 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 + expect-case-colon: + - match: ':' + scope: punctuation.separator.js pop: true - - flow-type-annotation-optional: - - match: \?(?=:) - scope: storage.modifier.optional.js - - include: flow-type-annotation - - variable-binding-list: - - include: comma-separator - - match: (?={{binding_pattern_lookahead}}) - push: - - initializer - - variable-binding-pattern - include: else-pop - object-literal-contents: - - meta_scope: meta.mapping.js - - - match: \} - scope: punctuation.section.block.end.js - pop: true - - - match: \.\.\. - scope: keyword.operator.spread.js - push: expression-no-comma - - - match: >- - (?x)(?= - {{property_name}}\s*:\s* - {{either_func_lookahead}} - ) - push: + object-literal-property: + - match: '' + set: + - object-literal-property-check - 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 + - object-property-name - - match: ':' - scope: punctuation.separator.key-value.js - push: expression-no-comma + line-comment-double-slash-body: + - meta_include_prototype: false + - meta_scope: comment.line.double-slash.js + - include: line-comment-end - # If there's any garbage, parse it as an expression - # so that close braces won't break things. - - match: (?=\S) - push: expression-no-comma + 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 - jsx-tag-name-component: - - match: '{{jsx_identifier}}' - scope: entity.name.tag.js + prototype: + - include: comments + + jsx-interpolation-plain: + - match: '{' + scope: punctuation.definition.interpolation.begin.js set: - - match: '[:.]' - scope: punctuation.accessor.js - set: jsx-tag-name - - include: else-pop - - 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 - constructor-body-expect-class-begin: - - match: (?={{non_reserved_identifier}}\s*\() + variable-binding-array-destructuring: + - match: \[ + scope: punctuation.section.brackets.begin.js set: - - include: support - - match: '{{dollar_only_identifier}}' - scope: variable.type.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: variable.type.dollar.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: variable.type.js + - meta_scope: meta.binding.destructuring.sequence.js + - match: \] + scope: punctuation.section.brackets.end.js pop: true - - include: else-pop + - include: variable-binding-spread + - include: variable-binding-list - - include: expression-begin + conditional: + - match: switch{{identifier_break}} + scope: keyword.control.conditional.switch.js + set: + - switch-meta + - switch-block + - expect-parenthesized-expression - support-property-ecma-string: - - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} - scope: support.function.builtin.js - pop: true + - match: do{{identifier_break}} + scope: keyword.control.loop.do-while.js + set: + - do-while-meta + - do-while-condition + - statement - flow-arrow-function-return-type-annotation: - - match: ':' - scope: punctuation.separator.type.js + - match: for{{identifier_break}} + scope: keyword.control.loop.for.js set: - - flow-type-meta - - flow-type-end-no-arrow - - flow-type-begin - - match: (?!\s*(?:$|:|//|/\*)) - pop: true + - for-meta + - block-scope + - for-condition + - for-await - arrow-function-expect-arrow-or-fail-async: - - match: => - scope: keyword.declaration.function.arrow.js - pop: true - - match: (?=\S) - fail: async-arrow-function + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: + - while-meta + - block-scope + - expect-parenthesized-expression - call-method-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.method.js - - include: else-pop + - match: with{{identifier_break}} + scope: keyword.control.import.with.js + set: + - with-meta + - block-scope + - expect-parenthesized-expression - jsx-tag-name: - - meta_include_prototype: false - - match: '' + - match: if{{identifier_break}} + scope: keyword.control.conditional.if.js set: - - - clear_scopes: 1 - - meta_scope: meta.tag.name.js - - include: immediately-pop - - jsx-tag-name-component + - conditional-meta + - statement + - expect-parenthesized-expression - ternary-operator: - - match: \?(?=[^.]|\.[0-9]) - scope: keyword.operator.ternary.js + - match: else\s+if{{identifier_break}} + scope: keyword.control.conditional.elseif.js set: - - ternary-operator-expect-colon - - expression-no-comma + - conditional-meta + - statement + - expect-parenthesized-expression - tagged-template: - - include: literal-string-template-custom-comments - - include: literal-string-template-custom-tags - - include: styled-components + - match: else{{identifier_break}} + scope: keyword.control.conditional.else.js + set: + - conditional-meta + - statement - - match: '{{identifier_name}}(?=\s*`)' - scope: variable.function.tagged-template.js - pop: true + - match: try{{identifier_break}} + scope: keyword.control.exception.try.js + set: + - try-meta + - block-scope - arrow-function-expect-arrow: - - match: => - scope: keyword.declaration.function.arrow.js - pop: true - - include: else-pop + - match: finally{{identifier_break}} + scope: keyword.control.exception.finally.js + set: + - finally-meta + - block-scope - literal-string-template-custom-tags: [] - flow-type-typeof: - - match: typeof{{identifier_break}} - scope: keyword.operator.js + - match: catch{{identifier_break}} + scope: keyword.control.exception.catch.js set: - - left-expression-end - - expression-begin + - catch-meta + - block-scope + - expect-parenthesized-expression - flow-detect-arrow-function-return-type: - - match: '' - push: - - flow-detect-arrow-after-return-type - - flow-arrow-function-return-type-annotation + object-literal: + - match: \{ + scope: punctuation.section.block.begin.js + set: object-literal-contents - statements: - - match: \)|\}|\] - scope: invalid.illegal.stray-bracket-end.js + regexp-complete: + - match: / + scope: punctuation.definition.string.begin.js + set: regexp + + support-property-ecma-arraybuffer: + - match: isView{{identifier_break}} + scope: support.function.builtin.js pop: true - - match: (?=\S) - push: statement + 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 - 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 + else-pop: + - match: (?=\S) pop: true - - match: (?=\d) - set: - - - match: '{{identifier_part}}+' - scope: invalid.illegal.js - - include: immediately-pop - - literal-number - - match: (?=['"]) - set: literal-string - detect-bare-arrow: - - match: (?==>) - fail: bare-arrow-function - - match: (?=\S) - pop: 2 + decorator-name: + - match: '{{identifier_name}}{{left_expression_end_lookahead}}' + scope: variable.annotation.js + pop: true - flow-type-object-indexer-label: - - match: ({{non_reserved_identifier}})\s*(:) - captures: - 1: meta.object-literal.key.js - 2: punctuation.separator.key-value.js + support-property-ecma-object: + - match: (?:assign|create|defineProperties|defineProperty|entries|freeze|fromEntries|getOwnPropertyDescriptors?|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values){{identifier_break}} + scope: support.function.builtin.js pop: true - - include: else-pop - jsx-tag: - - match: < - scope: punctuation.definition.tag.begin.js - set: - - jsx-meta - - jsx-tag-attributes-top + block-comments: + # empty block comments + - match: /\*\*+/ + scope: comment.block.empty.js punctuation.definition.comment.js + # documentation block comments + - match: /\*\*+ + scope: punctuation.definition.comment.begin.js + push: + - jsdoc-comment-body + - jsdoc-block-tag + # normal block comments + - match: /\* + scope: punctuation.definition.comment.begin.js + push: block-comment-body - function-declaration: - - 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 + try-meta: + - meta_include_prototype: false + - meta_scope: meta.try.js + - include: immediately-pop - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop + comments: + - include: line-comments + - include: block-comments - support-property-ecma-typedarray: - - match: (?:BYTES_PER_ELEMENT){{identifier_break}} - scope: support.constant.builtin.js + decorator-meta: + - meta_include_prototype: false + - meta_scope: meta.annotation.js + - include: immediately-pop + + support-property-ecma: + - match: constructor{{identifier_break}} + scope: variable.language.constructor.js + pop: true + - match: prototype{{identifier_break}} + scope: support.constant.prototype.js pop: true - support-property-ecma-bigint: - - match: (?:asUintN|asIntN){{identifier_break}} - scope: support.function.builtin.js + - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} + scope: support.function.js pop: true - export-item: - - match: \{ - scope: punctuation.section.block.begin.js - set: export-brace - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js + # Annex B + - match: __proto__{{identifier_break}} + scope: invalid.deprecated.js variable.language.prototype.js pop: true - - match: \* - scope: constant.other.js + - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} + scope: invalid.deprecated.js support.function.js pop: true - - include: else-pop - literal-string: - - match: "'" - scope: punctuation.definition.string.begin.js + inherited-class-expression-begin: + - include: inherited-class-name + - include: expression-begin + + static-block: + - match: static{{identifier_break}} + scope: storage.modifier.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: '"' + - match: \{ + scope: punctuation.section.block.begin.js + set: static-block-body + - match: (?=\S) + fail: static-block + + 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.double.js - - match: \" + - meta_scope: meta.string.js string.quoted.other.js + - match: '`' scope: punctuation.definition.string.end.js pop: true - - match: \n - scope: invalid.illegal.newline.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 - flow-type-list: - - include: comma-separator + flow-type-declare-export: + - match: default{{identifier_break}} + scope: keyword.control.import-export.js + set: flow-type - match: (?=\S) - push: flow-type - - immediately-pop: - - match: '' pop: true - export-meta: - - meta_include_prototype: false - - meta_scope: meta.export.js - - include: immediately-pop - - for-meta: + expect-label: - meta_include_prototype: false - - meta_scope: meta.for.js - - include: immediately-pop - - jsx-attribute-value: - - include: jsx-tag - - include: jsx-interpolation - - - match: "'" - scope: punctuation.definition.string.begin.js + - match: (?={{nothing}}{{identifier_name}}) set: - - meta_include_prototype: false - - meta_scope: string.quoted.single.js - - match: \' - scope: punctuation.definition.string.end.js + - match: '{{non_reserved_identifier}}' + scope: variable.label.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 + - match: '{{identifier_name}}' + scope: invalid.illegal.identifier.js variable.label.js pop: true - - include: jsx-html-escapes - - - include: else-pop - - 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 + - include: immediately-pop - block-scope: - - include: block - - include: else-pop + jsx-tag-name: + - meta_include_prototype: false + - match: '' + set: + - jsx-tag-name-meta + - jsx-tag-name-end + - jsx-tag-name-component-possibly-native - styled-component-begin: - - match: '{{non_reserved_identifier}}(?=\s*\()' - scope: variable.function.js + special-name: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js pop: true - - - match: '{{non_reserved_identifier}}(?=\s*`)' - scope: variable.function.tagged-template.js + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js pop: true - - - match: '{{non_reserved_identifier}}' - scope: variable.other.readwrite.js + - match: null{{identifier_break}} + scope: constant.language.null.js pop: true - - - include: else-pop - statement: - - include: flow-type-declare - - include: flow-type-alias - - - match: \; - scope: punctuation.terminator.statement.empty.js + - match: super{{identifier_break}} + scope: variable.language.super.js + pop: true + - match: this{{identifier_break}} + scope: variable.language.this.js pop: true - - include: import-statement-or-import-meta - - include: export-statement - - include: conditional - - include: block - - include: label - - include: variable-declaration - - - match: break{{identifier_break}} - scope: keyword.control.flow.break.js - set: - - expect-semicolon - - expect-label - - - match: continue{{identifier_break}} - scope: keyword.control.flow.continue.js - set: - - expect-semicolon - - expect-label - - - match: debugger{{identifier_break}} - scope: keyword.control.flow.debugger.js - set: expect-semicolon + support-property-ecma-json: + - match: (?:parse|stringify){{identifier_break}} + scope: support.function.builtin.js + pop: true - - match: return{{identifier_break}} - scope: keyword.control.flow.return.js - set: restricted-production + flow-detect-arrow-after-return-type: + - match: (?==>) + fail: arrow-function + - match: (?=\S) + fail: flow-arrow-function-return-type - - match: throw{{identifier_break}} - scope: keyword.control.flow.throw.js - set: restricted-production + detect-arrow: + - match: (?==>) + fail: arrow-function + - include: else-pop - - include: class - - include: regular-function + 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 - - include: decorator + catch-meta: + - meta_include_prototype: false + - meta_scope: meta.catch.js + - include: immediately-pop - - include: expression-statement + expression-no-comma: + - meta_include_prototype: false + - match: '' + set: [expression-end-no-comma, expression-begin] - prototype: - - include: comments + 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 - flow-type-primitive: - - match: boolean{{identifier_break}} - scope: support.type.primitive.boolean.js - pop: true + - match: extends{{identifier_break}} + scope: storage.modifier.extends.js + set: + - inherited-class-expression-end + - inherited-class-expression-begin + - include: else-pop - - match: number{{identifier_break}} - scope: support.type.primitive.number.js + support-property-ecma-proxy: + - match: revocable{{identifier_break}} + scope: support.function.builtin.js pop: true - - match: string{{identifier_break}} - scope: support.type.primitive.string.js + support-property-ecma-string: + - match: (?:fromCharCode|fromCodePoint|raw){{identifier_break}} + scope: support.function.builtin.js pop: true - - match: null{{identifier_break}} - scope: support.type.primitive.null.js - pop: true + constructor-body-expect-arguments: + - include: function-call-arguments + - include: else-pop - - match: void{{identifier_break}} - scope: support.type.primitive.void.js + statements: + - match: \)|\}|\] + scope: invalid.illegal.stray-bracket-end.js pop: true - with-meta: - - meta_include_prototype: false - - meta_scope: meta.with.js - - include: immediately-pop - - array-literal: - - match: \[ - scope: punctuation.section.brackets.begin.js - set: - - meta_scope: meta.sequence.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - include: expression-list + - match: (?=\S) + push: statement - flow-type-import-type: - - match: type{{identifier_break}} - scope: keyword.declaration.js + flow-type-existential: + - match: \* + scope: constant.language.type.existential.js + pop: true - - match: typeof{{identifier_break}} - scope: keyword.operator.js + line-comments: + - match: /{4,} + scope: punctuation.definition.comment.js + push: line-comment-other-body + - match: /{3} + scope: punctuation.definition.comment.js + push: line-comment-triple-slash-body + - match: /{2} + scope: punctuation.definition.comment.js + push: line-comment-double-slash-body method-name: - match: '{{dollar_identifier}}' @@ -1920,223 +2314,96 @@ contexts: - include: else-pop - expression-end-no-comma: - - match: (?=,) + 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 - - include: expression-end - - function-declaration-expect-parameters: - - include: function-declaration-parameters - - 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_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-json: - - match: (?:parse|stringify){{identifier_break}} + - match: (?:for|keyFor){{identifier_break}} scope: support.function.builtin.js pop: true - flow-type-object-contents: - - include: comma-separator - - match: ; - scope: punctuation.separator.semicolon.js - - match: '{{method_lookahead}}' - push: method-declaration - - match: \+ - scope: storage.modifier.variance.js - - match: '{{non_reserved_identifier}}' - scope: meta.object-literal.key.js - push: flow-type-object-value - - match: \[ - scope: punctuation.section.brackets.begin.js - push: - - flow-type-object-value - - flow-type-object-indexer-type - - flow-type-object-indexer-label - - string-content: - - match: \\\n - scope: constant.character.escape.newline.js - - match: \\(?:x\h\h|u\h\h\h\h|.) - scope: constant.character.escape.js - - expression-statement: - - match: (?=\S) - set: - - expect-semicolon - - expression-statement-end - - expression-begin - - object-property: - - include: support-property - - - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) - set: - - function-name-meta - - object-property-base - - - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: call-method-name - - - include: object-property-base - - include: else-pop + custom-templates-default: + - include: literal-string-template - 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 + flow-type-end-no-arrow: + - match: (?==>) pop: true - - include: else-pop - - comments: - - match: /\*\*(?!/) - scope: punctuation.definition.comment.begin.js - push: - - jsdoc-comment - - jsdoc-block-tag - - match: /\* - scope: punctuation.definition.comment.begin.js - push: - - meta_include_prototype: false - - meta_scope: comment.block.js - - match: \*/ - scope: punctuation.definition.comment.end.js - pop: true - - match: // - scope: punctuation.definition.comment.js - push: - - meta_include_prototype: false - - meta_scope: comment.line.double-slash.js - - match: \n - pop: true - - export-extended: - - include: flow-type-export-type - - - include: variable-declaration - - include: class - - include: regular-function - - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: - - include: class - - include: regular-function - - match: (?=\S) - set: expression-statement + - include: flow-type-end + expression-list: + - include: expression-break + - include: comma-separator - match: (?=\S) - set: - - expect-semicolon - - import-export-from - - export-list - - import-export-alias - - export-item - - 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 - - comma-separator: - - match: ',' - scope: punctuation.separator.comma.js - - 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 - - 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 + push: expression-no-comma - regexp-complete: - - match: / - scope: punctuation.definition.string.begin.js - set: regexp + support-property: + - include: support-property-ecma - finally-meta: + expression: - meta_include_prototype: false - - meta_scope: meta.finally.js - - include: immediately-pop + - match: '' + set: [expression-end, expression-begin] - constructor-body-expect-arguments: - - include: function-call-arguments - - include: else-pop + main: + - meta_include_prototype: false # don't match comments before shebang + - match: '' + push: [script, shebang] - conditional-meta: + import-statement-or-import-meta: + - match: (?=import{{identifier_break}}) + branch_point: import-statement + branch: + - import-statement + - expression-statement + + decorator: + - match: '@' + scope: punctuation.definition.annotation.js + push: + - decorator-meta + - decorator-expression-end + - decorator-expression-begin + + import-meta: - meta_include_prototype: false - - meta_scope: meta.conditional.js + - meta_scope: meta.import.js - include: immediately-pop - function-declaration-parameters: - - match: \( - scope: punctuation.section.group.begin.js + method-declaration-expect-asterisk: + - match: \* + scope: keyword.generator.asterisk.js + - include: else-pop + + export-statement: + - match: export{{identifier_break}} + scope: keyword.control.import-export.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 + - export-meta + - export-extended - while-meta: - - meta_include_prototype: false - - meta_scope: meta.while.js - - include: immediately-pop + arrow-function-expect-arrow-or-fail-async: + - match: => + scope: keyword.declaration.function.arrow.js + pop: true + - match: (?=\S) + fail: async-arrow-function - class-body: + export-item: - match: \{ scope: punctuation.section.block.begin.js - set: class-body-contents + set: export-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js + pop: true + - match: \* + scope: constant.other.js + pop: true + - include: else-pop + do-while-condition: + - match: while{{identifier_break}} + scope: keyword.control.loop.while.js + set: parenthesized-expression - include: else-pop expression-end: @@ -2148,426 +2415,334 @@ contexts: - include: left-expression-end - branch-possible-bare-arrow-function: + arrow-function-declaration: - meta_include_prototype: false - match: '' - push: - - detect-bare-arrow - - literal-variable - - flow-type-operators: - - match: \|(?!\}) - scope: keyword.operator.type.union.js - push: flow-type-begin - - match: \& - scope: keyword.operator.type.intersection.js - push: flow-type-begin - - match: => - scope: keyword.declaration.function.arrow.js - push: flow-type-begin - - match: \? - scope: storage.modifier.maybe.js - push: flow-type-begin - - match: \. - scope: punctuation.separator.accessor.js - push: flow-type-begin - - - match: \[\] - scope: storage.modifier.array.js - - match: '%checks{{identifier_break}}' - scope: storage.modifier.checks.js - - class-element: - - match: '' - pop: true - branch_point: class-field - branch: - - class-field - - method-declaration - - 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 - - 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 + 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 - - match: ({{dec_integer}})(n|(?!\.)){{identifier_break}} - scope: meta.number.integer.decimal.js - captures: - 1: constant.numeric.value.js - 2: constant.numeric.suffix.js + support-variable-node: + - match: global{{identifier_break}} + scope: support.type.object.node.js pop: true - # illegal numbers - - match: 0[Xx]{{identifier_part}}+ - scope: invalid.illegal.numeric.hexadecimal.js + - match: Buffer{{identifier_break}} + scope: support.class.node.js pop: true - - match: 0[Bb]{{identifier_part}}+ - scope: invalid.illegal.numeric.binary.js - pop: true + - match: process{{identifier_break}} + scope: support.constant.node.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-process + - include: object-property + - include: else-pop + - include: else-pop - - match: 0{{identifier_part}}+ - scope: invalid.illegal.numeric.octal.js + # Module-level variables + - match: (?:__dirname|__filename|exports){{identifier_break}} + scope: support.constant.node.js pop: true - - - match: '[1-9]{{identifier_part}}+(?:\.{{identifier_part}}*)?' - scope: invalid.illegal.numeric.decimal.js + - match: module{{identifier_break}} + scope: support.constant.node.js + set: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + set: + - include: support-property-node-module + - include: object-property + - include: else-pop + - include: else-pop + - match: require{{identifier_break}} + scope: support.function.node.js pop: true - function-parameter-binding-list: - - match: ',' - scope: punctuation.separator.parameter.function.js - - include: function-parameter-binding-spread - - match: (?={{binding_pattern_lookahead}}) - push: function-parameter - - include: else-pop - - support-property-ecma-arraybuffer: - - match: isView{{identifier_break}} - scope: support.function.builtin.js - pop: true + while-meta: + - meta_include_prototype: false + - meta_scope: meta.while.js + - include: immediately-pop - support-property-ecma-proxy: - - match: revocable{{identifier_break}} - scope: support.function.builtin.js - pop: true + import-string-or-items: + - include: literal-string + - match: (?=\S) + set: + - import-export-from + - import-list + - import-export-alias + - import-item - flow-function-type-arguments-or-less-than: - - match: (?=<(?![<=])) - branch_point: flow-function-type-arguments - branch: - - flow-function-type-arguments - - flow-less-than + flow-type-meta: + - meta_scope: meta.flow-type.js + - include: immediately-pop - function-parameter-binding-pattern: + immediately-pop-2: + - meta_include_prototype: false - 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 + pop: 2 - method-declaration: - - meta_include_prototype: false + support: + - include: support-variable-ecma + - include: support-variable-console + - include: support-variable-dom + - include: support-variable-node + + flow-arrow-return-type: - match: '' + push: + - flow-detect-arrow-after-return-type + - flow-arrow-function-return-type-annotation + + class-element-modifier: + - match: '{{modifier}}' + scope: storage.modifier.js set: - - function-meta - - function-declaration-expect-body - - flow-type-annotation - - function-declaration-expect-parameters - - flow-type-generic-parameters - - method-name - - method-declaration-expect-asterisk + - match: (?={{class_element_name}}|\*) + pop: true + - match: (?=\S) + fail: class-element-modifier - flow-type-export-type: - - match: type{{identifier_break}}(?=\s*\{) - scope: keyword.declaration.js - set: export-item - - include: flow-type-alias + object-property: + - include: support-property - class-element-modifiers: - - match: (?={{modifier}}) - branch_point: class-element-modifier - branch: - - class-element-modifier - - class-element + - match: (?=\#?{{identifier_name}}{{function_assignment_lookahead}}) + set: + - function-name-meta + - object-property-base - expression-list: - - include: expression-break - - include: comma-separator - - match: (?=\S) - push: expression-no-comma + - match: (?=#?{{identifier_name}}\s*(?:{{dot_accessor}})?\() + set: call-method-name - jsx-tag-attributes: - - meta_scope: meta.tag.attributes.js + - match: '{{identifier_name}}(?={{nothing}}`)' + scope: variable.function.tagged-template.js + pop: true - - match: '>' - scope: punctuation.definition.tag.end.js - set: jsx-body + - include: object-property-base + - include: else-pop - - match: / - scope: punctuation.definition.tag.end.js - set: jsx-expect-tag-end + function-block: + - match: \{ + scope: punctuation.section.block.begin.js + set: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js + pop: true + - include: statements - - include: jsx-interpolation + jsx-body: + - meta_include_prototype: false - - match: '{{jsx_identifier}}' - scope: entity.other.attribute-name.js + - match: < + scope: punctuation.definition.tag.begin.js + set: + - meta_scope: meta.tag.js - - match: '=' - scope: punctuation.separator.key-value.js - push: jsx-attribute-value + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-expect-tag-end + - jsx-tag-name - expression-break: - - match: (?=[;})\]]) - pop: true + - match: (?=\S) + set: + - jsx-body + - jsx-tag-attributes + - jsx-tag-name - arrow-function-expect-body: - - include: function-block - - match: (?=\S) + - include: jsx-html-escapes + - include: jsx-interpolation + variable-binding-top: + - match: (?={{binding_pattern_lookahead}}) set: - - block-meta - - expression-no-comma + - initializer + - variable-binding-pattern + - include: else-pop - support: - - include: support-variable-ecma - - include: support-variable-console - - include: support-variable-dom - - include: support-variable-node + support-property-ecma-promise: + - match: (?:all|race|reject|resolve|allSettled|any){{identifier_break}} + scope: support.function.builtin.js + pop: true - constructor-meta: - - meta_include_prototype: false - - meta_scope: meta.function-call.constructor.js - - include: immediately-pop + support-property-ecma-reflect: + - match: (?:apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf){{identifier_break}} + scope: support.function.builtin.js + pop: true - support-property-ecma-math: - - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} + support-property-ecma-typedarray: + - match: (?:BYTES_PER_ELEMENT){{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 + + static-block-body: + - meta_scope: meta.block.js + - match: \} + scope: punctuation.section.block.end.js pop: true + - include: statements - call-method-name: - - include: support-property + object-property-name: - match: '{{identifier_name}}' - scope: variable.function.js + scope: string.unquoted.js pop: true - - match: (#){{identifier_name}} - scope: variable.function.js - captures: - 1: punctuation.definition.js + + - match: (?=\[) + set: computed-property-name + + - include: literal-string + - include: literal-number + + - match: '{{identifier_name}}' pop: true + - include: else-pop - switch-block-contents: + expect-semicolon: + - match: \; + scope: punctuation.terminator.statement.js + pop: true + - include: else-pop + + arrow-function-expect-arrow: + - match: => + scope: keyword.declaration.function.arrow.js + pop: true + - include: else-pop + + class-body-contents: - meta_scope: meta.block.js - match: \} scope: punctuation.section.block.end.js pop: true - - match: case{{identifier_break}} - scope: keyword.control.conditional.case.js - push: - - expect-case-colon - - expression + - match: \; + scope: punctuation.terminator.statement.js - - match: default{{identifier_break}} - scope: keyword.control.conditional.default.js - push: - - expect-case-colon + - include: decorator - - include: statements + - match: constructor{{identifier_break}} + scope: entity.name.function.constructor.js + push: + - function-meta + - function-declaration-expect-body + - function-declaration-expect-parameters - jsx-meta: - - meta_include_prototype: false - - meta_scope: meta.jsx.js - - include: immediately-pop + - match: (?=static{{identifier_break}}) + branch_point: static-block + branch: + - static-block + - class-element-modifiers - class-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.class.js - set: flow-type-generic-parameters - - include: else-pop + - match: (?={{modifier}}) + push: class-element-modifiers - 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 - - literal-call: - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}})?\() - set: - - call-function-meta - - function-call-arguments - - literal-variable + (?x)(?= + \#? {{identifier_name}} + \s* = \s* + {{either_func_lookahead}} + ) + push: + - initializer + - function-name-meta + - literal-variable-base - - match: (?={{identifier_name}}\s*(?:{{dot_accessor}}\s*#?{{identifier_name}}\s*)+(?:{{dot_accessor}})?\() - set: - - call-method-meta - - function-call-arguments - - call-path - - literal-variable + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-method + branch: + - prefixed-method + - class-element - function-declaration-expect-body: - - include: function-block - - include: else-pop + - match: (?=\*) + push: method-declaration - function-declaration-expect-name: - - match: '{{non_reserved_identifier}}' - scope: entity.name.function.js - pop: true - - include: else-pop + - match: (?={{class_element_name}}) + push: class-element - try-meta: + constructor-meta: - meta_include_prototype: false - - meta_scope: meta.try.js + - meta_scope: meta.function-call.constructor.js - include: immediately-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 + object-literal-contents: + - meta_scope: meta.mapping.js - inherited-class-expression-begin: - - include: inherited-class-name - - include: expression-begin + - match: \} + scope: punctuation.section.block.end.js + pop: true - object-literal-property: - - match: '' - set: - - object-literal-property-check + - match: \.\.\. + scope: keyword.operator.spread.js + push: expression-no-comma + + - match: >- + (?x)(?= + {{property_name}}\s*:\s* + {{either_func_lookahead}} + ) + push: - object-literal-meta-key - - object-property-name + - method-name - flow-type-generic-arguments: - - match: < - scope: punctuation.definition.generic.begin.js - set: - - meta_scope: meta.generic.js - - match: '>' - scope: punctuation.definition.generic.end.js - pop: true - - include: flow-type-list + - match: (?=\*) + push: method-declaration - do-while-meta: - - meta_include_prototype: false - - meta_scope: meta.do-while.js - - include: immediately-pop + - match: (?=(?:get|set|async){{identifier_break}}) + branch_point: prefixed-object-literal-method + branch: + - prefixed-object-literal-method + - object-literal-element - label: - - match: ({{identifier_name}})\s*(:) - captures: - 1: entity.name.label.js - 2: punctuation.separator.js + - match: (?={{property_name}}) + push: object-literal-element - 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 + - include: comma-separator - object-literal-property-check: - - match: (?=\() - fail: object-literal-property - - include: else-pop + - match: ':' + scope: punctuation.separator.key-value.js + push: expression-no-comma - 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 + # If there's any garbage, parse it as an expression + # so that close braces won't break things. + - match: (?=\S) + push: expression-no-comma - flow-type-alias: - - match: (?=type{{identifier_break}}) + flow-type-annotation: + - match: ':' + scope: punctuation.separator.type.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 + - flow-type-meta + - flow-type + - match: (?!\s*(?:$|:|//|/\*)) + pop: true - - match: (?=\S) - set: [expression-statement, expression-end] - - - match: type{{identifier_break}}(?=\s*(?:$|{{non_reserved_identifier}})) - scope: keyword.declaration.js - set: - - meta_scope: meta.declaration.type.js - - include: else-pop - - include: expression-begin + function-call-arguments: + - match: ({{dot_accessor}})?(\() + captures: + 1: punctuation.accessor.js + 2: punctuation.section.group.begin.js + set: + - meta_scope: meta.group.js + - match: \) + scope: punctuation.section.group.end.js + pop: true + - include: expression-list - await-expression: - - match: await{{identifier_break}} - scope: keyword.control.flow.await.js + expression-end-no-in: + - match: (?=in{{identifier_break}}) + pop: true + - include: expression-end - class-extends: - - match: extends{{identifier_break}} - scope: storage.modifier.extends.js - set: - - inherited-class-expression-end - - inherited-class-expression-begin - - include: else-pop + import-brace: + - include: flow-type-import-type - export-brace: - meta_scope: meta.block.js - include: comma-separator - match: \} @@ -2581,124 +2756,58 @@ contexts: push: import-export-alias - include: else-pop - support-variable-node: - - match: global{{identifier_break}} - scope: support.type.object.node.js - pop: true - - - match: Buffer{{identifier_break}} - scope: support.class.node.js - pop: true - - - match: process{{identifier_break}} - scope: support.constant.node.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-process - - include: object-property - - include: else-pop - - include: else-pop - - # Module-level variables - - match: (?:__dirname|__filename|exports){{identifier_break}} - scope: support.constant.node.js - pop: true - - match: module{{identifier_break}} - scope: support.constant.node.js - set: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - set: - - include: support-property-node-module - - include: object-property - - include: else-pop - - include: else-pop - - match: require{{identifier_break}} - scope: support.function.node.js + flow-type-literal: + - match: true{{identifier_break}} + scope: constant.language.boolean.true.js pop: true - - flow-type-declare-export: - - match: default{{identifier_break}} - scope: keyword.control.import-export.js - set: flow-type - - match: (?=\S) + - match: false{{identifier_break}} + scope: constant.language.boolean.false.js pop: true - - export-statement: - - match: export{{identifier_break}} - scope: keyword.control.import-export.js + - match: (?=\d) set: - - export-meta - - export-extended - - jsx-html-escapes: - - match: (&)#?[[:alnum:]]+(;) - scope: constant.character.escape.js - captures: - 1: punctuation.definition.entity.js - 2: punctuation.definition.entity.js - - else-pop: - - match: (?=\S) - pop: true - - jsdoc-comment: - - meta_include_prototype: false - - meta_scope: comment.block.documentation.js - - match: \*/ - scope: punctuation.definition.comment.end.js - pop: 1 - # JSDoc "block" tags (i.e. @param) are only accepted at the beginning of the documentation - # line so directly after the '/**' or after the '*' marker on the next lines. - - match: ^\s*(\*)(?!/) - captures: - 1: punctuation.definition.comment.js - push: jsdoc-block-tag - - import-meta-expression: - - match: import{{identifier_break}} - scope: keyword.import.js - set: import-expression-end - - import-item: - - include: flow-type-import-type - - - 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 + - - match: '{{identifier_part}}+' + scope: invalid.illegal.js + - include: immediately-pop + - literal-number + - match: (?=['"]) + set: literal-string + + jsx-tag-attributes-top: + - meta_scope: meta.tag.js + - match: / + scope: punctuation.definition.tag.begin.js + set: + - jsx-meta-unmatched-tag + - jsx-expect-tag-end + - jsx-tag-name - import-string-or-items: - - include: literal-string - match: (?=\S) set: - - import-export-from - - import-list - - import-export-alias - - import-item + - jsx-tag-attributes + - flow-jsx-tag-check + - jsx-tag-name + - flow-jsx-tag-check-name - block: - - match: \{ - scope: punctuation.section.block.begin.js + variable-declaration: + - match: (?:const|let|var){{identifier_break}} + scope: keyword.declaration.js set: - - meta_scope: meta.block.js - - match: \} - scope: punctuation.section.block.end.js - pop: true - - include: statements + - expect-semicolon + - variable-binding-list-top + - variable-binding-top + + flow-type-begin: + - include: flow-type-existential + - include: flow-type-literal + - include: flow-type-special + - include: flow-type-primitive + - include: flow-type-utility + - include: flow-type-typeof + - include: flow-type-class + - include: flow-type-function + - include: flow-type-tuple + - include: flow-type-object - call-path: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: object-property - include: else-pop flow-type-function: @@ -2711,26 +2820,48 @@ contexts: pop: true - include: flow-type-list - support-property-ecma: - - match: constructor{{identifier_break}} - scope: variable.language.constructor.js + import-item: + - include: flow-type-import-type + + - match: \{ + scope: punctuation.section.block.begin.js + set: import-brace + - match: '{{non_reserved_identifier}}' + scope: variable.other.readwrite.js pop: true - - match: prototype{{identifier_break}} - scope: support.constant.prototype.js + - match: \* + scope: constant.other.js pop: true + - include: else-pop - - match: (?:hasOwnProperty|isPrototypeOf|propertyIsEnumerable|toLocaleString|toString|valueOf){{identifier_break}} - scope: support.function.js + switch-meta: + - meta_include_prototype: false + - meta_scope: meta.switch.js + - include: immediately-pop + + function-declaration-expect-generator-star: + - match: \* + scope: keyword.declaration.generator.js pop: true + - include: else-pop - # Annex B - - match: __proto__{{identifier_break}} - scope: invalid.deprecated.js variable.language.prototype.js + support-property-ecma-math: + - match: (?:E|LN10|LN2|LOG10E|LOG2E|PI|SQRT1_2|SQRT2){{identifier_break}} + scope: support.constant.builtin.js pop: true - - match: (?:__defineGetter__|__defineSetter__|__lookupGetter__){{identifier_break}} - scope: invalid.deprecated.js support.function.js + - match: (?:abs|acos|acosh|asin|asin|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc){{identifier_break}} + scope: support.function.builtin.js pop: true + import-statement: + - match: import{{identifier_break}} + scope: keyword.control.import-export.js + set: + - import-meta + - expect-semicolon + - import-string-or-items + - import-check-branch + flow-type-module-name: - include: literal-string - match: '{{non_reserved_identifier}}' @@ -2738,157 +2869,94 @@ contexts: pop: true - include: else-pop - for-oldstyle-rest: - - match: (?=\)) - pop: true - - match: ; - scope: punctuation.separator.expression.js - - match: (?=\S) - push: expression - - postfix-operators: - - match: -- - scope: keyword.operator.arithmetic.js - - match: \+\+ - scope: keyword.operator.arithmetic.js - - function-parameter-binding-spread: - - match: \.\.\. - scope: keyword.operator.spread.js - push: function-parameter - - flow-type: - - match: '' - set: - - flow-type-end - - flow-type-begin - - flow-type-class: - - match: '{{non_reserved_identifier}}' - scope: variable.other.class.js - pop: true + flow-function-type-arguments-or-less-than: + - match: (?=<(?![<=])) + branch_point: flow-function-type-arguments + branch: + - flow-function-type-arguments + - flow-less-than - expression-no-comma: + call-function-meta: - meta_include_prototype: false - - match: '' - set: [expression-end-no-comma, expression-begin] + - meta_scope: meta.function-call.js + - include: else-pop - 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 + flow-type-object-indexer-type: + - match: \] + scope: punctuation.section.brackets.end.js pop: true + - include: flow-type-list - variable-binding-pattern: - - match: '' + flow-type-declare: + - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) + scope: keyword.declaration.js set: - - - include: flow-type-annotation - - - include: variable-binding-name - - include: variable-binding-array-destructuring - - include: variable-binding-object-destructuring - - include: else-pop + - 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 - comments-top-level: - - match: ^(#!).*$\n? - scope: comment.line.shebang.js - captures: - 1: punctuation.definition.comment.js + flow-type-export-type: + - match: type{{identifier_break}}(?=\s*\{) + scope: keyword.declaration.js + set: export-item + - include: flow-type-alias - object-property-base: - - match: '{{dollar_only_identifier}}' - scope: meta.property.object.dollar.only.js punctuation.dollar.js - pop: true - - match: '{{dollar_identifier}}' - scope: meta.property.object.dollar.js - captures: - 1: punctuation.dollar.js - pop: true - - match: '{{identifier_name}}' - scope: meta.property.object.js - pop: true - - match: '{{identifier_part}}+{{identifier_break}}' - scope: invalid.illegal.illegal-identifier.js - pop: true - - match: (#)({{identifier_name}}) - captures: - 1: punctuation.definition.variable.js - 2: meta.property.object.js - pop: true + flow-less-than: + - match: < + scope: keyword.operator.comparison.js + set: expression-begin - function-call-arguments: - - match: ({{dot_accessor}})?(\() - captures: - 1: punctuation.accessor.js - 2: punctuation.section.group.begin.js + styled-components: + - match: (?=(?:styled|css|createGlobalStyle|injectGlobal){{identifier_break}}) set: - - meta_scope: meta.group.js - - match: \) - scope: punctuation.section.group.end.js - pop: true - - include: expression-list - - arrow-function-declaration: - - meta_include_prototype: false - - match: '' + - styled-component-end + - styled-component-begin + - match: (?=keyframes{{identifier_break}}) set: - - function-meta - - arrow-function-expect-body - - arrow-function-expect-arrow - - flow-arrow-function-return-type-annotation - - arrow-function-expect-parameters - - jsx-interpolation-comment: - - match: ({)(/\*) + - styled-component-keyframes-end + - styled-component-begin + jsx-tag-hack: [] + flow-arrow-function-declaration-with-type-parameters: [] + call-method-name: + - include: support-property + - match: '{{identifier_name}}' + scope: variable.function.js + pop: true + - match: (#){{identifier_name}} + scope: variable.function.js 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 - - class-meta: - - meta_include_prototype: false - - meta_scope: meta.class.js - - include: immediately-pop + 1: punctuation.definition.js + pop: true + - include: else-pop - import-statement-or-import-meta: - - match: (?=import{{identifier_break}}) - branch_point: import-statement - branch: - - import-statement - - expression-statement + call-path: + - match: '{{dot_accessor}}' + scope: punctuation.accessor.js + push: object-property + - include: else-pop - flow-type-declare: - - match: declare{{identifier_break}}(?=\s*(?:type|class|function|var|let|const|opaque|export|module){{identifier_break}}) - scope: keyword.declaration.js + for-condition: + - match: \( + scope: punctuation.section.group.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 - - for-of-rest: - - match: (?:of|in){{identifier_break}} - scope: keyword.operator.word.js - set: expression + - for-condition-end + - for-condition-contents + - include: else-pop expression-begin: - - include: jsx-tag + - include: jsx-tag-hack + + - include: flow-arrow-function-declaration-with-type-parameters - match: (?=`) set: @@ -2903,7 +2971,6 @@ contexts: - include: regexp-complete - include: literal-string - - include: tagged-template - include: literal-string-template - include: constructor - include: literal-number @@ -2926,7 +2993,7 @@ contexts: - include: object-literal # Newline not allowed between `async` and parameters. - - match: (?=async{{identifier_break}}{{nothing}}(?:\(|{{identifier_start}})) + - match: (?=async{{identifier_break}}{{nothing}}{{possible_arrow_function_begin}}) pop: true branch_point: async-arrow-function branch: @@ -2935,19 +3002,12 @@ contexts: - include: literal-call - - match: (?={{identifier_start}}) - pop: true - branch_point: bare-arrow-function - branch: - - branch-possible-bare-arrow-function - - bare-arrow-function-fallback - - - match: (?=\() + - match: (?={{possible_arrow_function_begin}}) pop: true - branch_point: parenthesized-arrow-function + branch_point: arrow-function branch: - - branch-possible-parenthesized-arrow-function - - parenthesized-arrow-function-fallback + - branch-possible-arrow-function + - arrow-function-declaration - include: array-literal @@ -2955,265 +3015,296 @@ contexts: - include: else-pop - property-access: - - match: ({{dot_accessor}})?(\[) + 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.accessor.js - 2: punctuation.section.brackets.begin.js - push: - - meta_scope: meta.brackets.js - - match: \] - scope: punctuation.section.brackets.end.js - pop: true - - match: (?=\S) - push: expression - - - match: '{{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 - - 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-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 - - do-while-condition: - - match: while{{identifier_break}} - scope: keyword.control.loop.while.js - set: parenthesized-expression - - include: else-pop + 1: punctuation.definition.comment.js + push: jsdoc-block-tag - literal-string-template: - - match: '`' - scope: punctuation.definition.string.begin.js + 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.string.js string.quoted.other.js - - match: '`' - scope: punctuation.definition.string.end.js + - 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: \$\{ - 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 + - match: (?=\*/) + fail: jsx-interpolation-comment - method-declaration-expect-asterisk: - - match: \* - scope: keyword.generator.asterisk.js - - include: else-pop + declaration: + - include: variable-declaration + - include: class + - include: regular-function - inherited-class-expression-end: - - include: flow-type-generic-arguments + literal-private-variable: + - match: (#)({{identifier_name}}) + captures: + 1: punctuation.definition.variable.js + 2: variable.other.readwrite.js + pop: true - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: inherited-class-name - - include: object-property + literal-string-template-custom-tags: [] + arrow-function-expect-body: + - include: function-block + - match: (?=\S) + set: + - block-meta + - expression-no-comma - - include: left-expression-end + class-field: + - match: '' + set: + - initializer + - flow-type-annotation + - class-field-check + - field-name - 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 + 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 - function-parameter-binding-object-alias: - - match: ':' - scope: punctuation.separator.key-value.js - set: function-parameter-binding-pattern + export-meta: + - meta_include_prototype: false + - meta_scope: meta.export.js + - include: immediately-pop + + function-parameter-binding-pattern: + - match: '' + set: + - - include: flow-type-annotation-optional + - - include: function-parameter-binding-name + - include: function-parameter-binding-array-destructuring + - include: function-parameter-binding-object-destructuring + - include: else-pop + + flow-jsx-tag-check-name: + - match: (?=(?:(?:{{jsx_identifier_part}})|\.):) + fail: arrow-function - include: else-pop - flow-type-module-contents: - - match: \} - scope: punctuation.section.block.end.js + support-property-ecma-date: + - match: (?:now|parse|UTC){{identifier_break}} + scope: support.function.builtin.js pop: true - - include: main - computed-property-name: + call-method-meta: + - meta_include_prototype: false + - meta_scope: meta.function-call.method.js + - include: else-pop + + object-literal-element: + - match: '{{identifier_name}}(?=\s*(?:[},]|$|//|/\*))' + scope: variable.other.readwrite.js + pop: true + - match: (?=\S) + pop: true + branch_point: object-literal-property + branch: + - object-literal-property + - method-declaration + + inherited-class-name: + - match: '{{non_reserved_identifier}}{{left_expression_end_lookahead}}' + scope: entity.other.inherited-class.js + pop: true + + 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 - - match: (?=\S) - push: expression + - include: flow-type-list - flow-type-alias-initializer: - - match: '=' - scope: keyword.operator.assignment.js - set: - - flow-type-meta - - flow-type - - include: else-pop - decorator-expression-end: - - match: '{{dot_accessor}}' - scope: punctuation.accessor.js - push: - - include: decorator-name - - include: object-property + 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 - - include: left-expression-end + jsx-tag-name-end: + - match: '[:.]' + scope: punctuation.accessor.js + push: jsx-tag-name-component + - include: else-pop - class: - - match: class{{identifier_break}} - scope: keyword.declaration.class.js + prefixed-method: + - match: (?:get|set){{identifier_break}} + scope: storage.type.accessor.js set: - - class-meta - - class-body - - class-extends - - class-name + - 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 - block-meta: + jsx-meta-unmatched-tag: - meta_include_prototype: false - - meta_scope: meta.block.js + - meta_scope: invalid.illegal.unmatched-tag.js - include: immediately-pop - function-name-meta: - - meta_include_prototype: false - - meta_scope: entity.name.function.js - - include: immediately-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 - flow-type-end-no-arrow: - - match: (?==>) - pop: true - - include: flow-type-end + left-expression-end: + - include: expression-break - flow-type-begin: - - include: flow-type-existential - - include: flow-type-literal - - include: flow-type-special - - include: flow-type-primitive - - include: flow-type-utility - - include: flow-type-typeof - - include: flow-type-class - - include: flow-type-function - - include: flow-type-tuple - - include: flow-type-object + - match: (?=`) + push: literal-string-template + + - match: (?=(?:{{dot_accessor}})?\() + push: function-call-arguments + + - include: property-access - include: else-pop -version: 2 -name: JavaScript (Babel) -file_extensions: - - js - - jsx - - es6 - - babel + for-condition-end: + - meta_scope: meta.group.js + + - match: \) + scope: punctuation.section.group.js + pop: true + +scope: source.js first_line_match: ^#!\s*/.*\b(node|js)\b +variables: + identifier_escape: (?:\\u(?:\h{4}|\{\h+\})) + property_name: >- + (?x: + {{identifier_name}} + | [0-9]+ + | '(?:[^\\']|\\.)*' + | "(?:[^\\"]|\\.)*" + | \[ .* \] + ) + identifier_break: (?!{{identifier_part}}) + left_expression_end_lookahead: (?!\s*[.\[\(]) + function_assignment_lookahead: |- + (?x:(?= + \s* = \s* + {{either_func_lookahead}} + )) + line_ending_ahead: (?={{nothing}}(?:/\*{{block_comment_contents}})?$) + constant_identifier: (?:[[:upper:]]{{identifier_part}}*{{identifier_break}}) + identifier_part: (?:[_$\p{L}\p{Nl}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]|{{identifier_escape}}) + dollar_only_identifier: (?:\${{identifier_break}}) + identifier_name: (?:{{identifier_start}}{{identifier_part}}*{{identifier_break}}) + dec_exponent: '[Ee](?:[-+]|(?![-+])){{dec_digit}}*' + dec_integer: (?:0|[1-9]{{dec_digit}}*) + bin_digit: '[01_]' + jsx_identifier: '{{identifier_start}}{{jsx_identifier_part}}*{{jsx_identifier_break}}' + dollar_identifier: (?:(\$){{identifier_part}}*{{identifier_break}}) + block_comment_contents: (?:(?:[^*]|\*(?!/))*) + binding_pattern_lookahead: (?:{{identifier_name}}|\[|\{) + jsx_identifier_part: (?:{{identifier_part}}|-) + method_lookahead: |- + (?x)(?= + (?: get|set|async ){{identifier_break}}(?!\s*:) + | \* + | {{property_name}} \s* (?:\(|<) + ) + func_lookahead: |- + (?x: + (?:async{{identifier_break}}{{nothing}})? + function{{identifier_break}} + ) + oct_digit: '[0-7_]' + either_func_lookahead: (?:{{func_lookahead}}|{{arrow_func_lookahead}}) + line_continuation_lookahead: >- + (?x:(?= + (?! \+\+ | -- ) + (?= + != | + [-+*/%><=&|^\[(;,.:?] | + (?:in|instanceof){{identifier_break}} + ) + )) + jsdoc_block_tag: \@[^\n\t\f\v *@]+ + jsx_identifier_break: (?!{{jsx_identifier_part}}) + identifier_start: (?:[_$\p{L}\p{Nl}]|{{identifier_escape}}) + class_element_name: |- + (?x: + \+? + (?: + \*? + {{property_name}} + | \#{{non_reserved_identifier}} + ) + ) + modifier: (?:static{{identifier_break}}) + hex_digit: '[\h_]' + reserved_word: |- + (?x: + break|case|catch|class|const|continue|debugger|default|delete|do|else| + export|extends|finally|for|function|if|import|in|instanceof|new|return| + super|switch|this|throw|try|typeof|var|void|while|with|yield| + enum| + null|true|false + ){{identifier_break}} + nothing: (?x:(?:\s|{{block_comment}})*) + possible_arrow_function_begin: (?:\(|{{identifier_start}}|<) + arrow_func_lookahead: |- + (?x)(?: + \s*(async\s*)? + (?: + {{non_reserved_identifier}} + |\( (?: [^()]|\([^()]*\) )* \) + ) + (?: + \s*: + \s*{{non_reserved_identifier}} + )? + \s*=> + ) + dec_digit: '[0-9_]' + function_call_lookahead: >- + (?x:(?= + {{identifier_name}} + \s* + (?: + < + .* + > + \s* + )? + (?:{{dot_accessor}})? + \( + )) + block_comment: (?:/\*{{block_comment_contents}}\*/) + non_reserved_identifier: (?:(?!{{reserved_word}}){{identifier_name}}) + dot_accessor: (?:\??\.) diff --git a/tests/syntax_test_flow.js b/tests/syntax_test_flow.js index dd91413..9970aaa 100644 --- a/tests/syntax_test_flow.js +++ b/tests/syntax_test_flow.js @@ -446,3 +446,12 @@ class MyClass { const C = (props: any): React.Node => {}; // ^^ keyword.declaration.function + + () => {}; +// ^^^^^^^^^^^^ meta.function +// ^^^^ meta.generic.declaration +// ^ punctuation.definition.generic.begin +// ^ variable.parameter.type +// ^ punctuation.separator.comma +// ^ punctuation.definition.generic.end +// ^^ keyword.declaration.function diff --git a/tests/syntax_test_js.js b/tests/syntax_test_js.js index 1484563..73e67b5 100644 --- a/tests/syntax_test_js.js +++ b/tests/syntax_test_js.js @@ -1,5 +1,86 @@ // SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// comment +// <- comment.line.double-slash.js punctuation.definition.comment.js +//^^^^^^^^^ comment.line.double-slash.js + +// comment // +// <- comment.line.double-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js + +/// comment +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^ comment.line.triple-slash.js + +/// comment /// +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^ comment.line.triple-slash.js +// ^^^ punctuation.definition.comment.js + +///////////////////////////////////////////////////////////////// +// <- comment.line.other.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.other.js punctuation.definition.comment.js +// ^ comment.line.other.js - punctuation + +/* */ +// <- comment.block.js punctuation.definition.comment.begin.js +//^^^ comment.block.js +// ^ - comment + + /**/ /***/ +// ^ - comment +// ^^^^ comment.block.empty.js punctuation.definition.comment.js +// ^ - comment +// ^^^^^ comment.block.empty.js punctuation.definition.comment.js +// ^ - comment + + /** @todo **/ +// ^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^ punctuation.definition.comment.begin.js +// ^^^^^ entity.other.attribute-name.documentation.js +// ^^^ punctuation.definition.comment.end.js + + /** +// ^ - comment +// ^^^ comment.block.documentation.js punctuation.definition.comment.begin.js +// ^ comment.block.documentation.js - punctuation + * @todo test it +// ^ comment.block.documentation.js punctuation.definition.comment.js +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^^ entity.other.attribute-name.documentation.js + **/ +//^^^ comment.block.documentation.js - punctuation +// ^^^ comment.block.documentation.js +// ^ - comment + + /*** @todo ***/ +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^ punctuation.definition.comment.begin.js +// ^^^^^ entity.other.attribute-name.documentation.js +// ^^^^ punctuation.definition.comment.end.js + + /*** +// ^ - comment +// ^^^^ comment.block.documentation.js punctuation.definition.comment.begin.js +// ^ comment.block.documentation.js - punctuation + * @todo test it +// ^ comment.block.documentation.js punctuation.definition.comment.js +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^^ entity.other.attribute-name.documentation.js + ***/ +//^^^ comment.block.documentation.js - punctuation +// ^^^^ comment.block.documentation.js +// ^ - comment + +/// +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor + +//// +// <- comment.line.other.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^^ comment.line.other.js - meta.preprocessor + // This object literal is technically broken since foo() does not have a // method body, but we include it here to ensure that highlighting is not // broken as the user is typing @@ -73,10 +154,7 @@ x --> y; // ^ keyword.operator.comparison.js #! /usr/bin/env node -// <- comment.line.shebang punctuation.definition.comment - - #! /usr/bin/env node -//^^^^^^^^^^^^^^^^^^^ - comment.line.shebang +//^^^^^^^^^^^^^^^^^^ - comment.line.shebang /*@if /*/ // ^^ punctuation.definition.comment.end @@ -193,6 +271,9 @@ tag `template`; // <- variable.function.tagged-template // ^^^^^^^^^^ meta.string string.quoted.other +tag/**/`template`; +// <- variable.function.tagged-template + x ? y // y is a template tag! `template` : z; // ^ keyword.operator.ternary @@ -885,6 +966,15 @@ sources.DOM // ^ punctuation.definition.js // ^^ meta.group.js +foo + .tag``; +// ^ punctuation.accessor +// ^^^ variable.function.tagged-template +// ^^ meta.string string.quoted.other punctuation.definition.string + +foo.tag/**/``; +// ^^^ variable.function.tagged-template + return new Promise(resolve => preferenceObject.set({value}, resolve)); // ^ meta.function-call.constructor punctuation.section.group.end @@ -1548,4 +1638,4 @@ debugger a.b?.(); // ^^^^^^^ meta.function-call.method // ^ variable.function -// +// diff --git a/tests/syntax_test_js_class.js b/tests/syntax_test_js_class.js index 8a6a47a..7f741a8 100644 --- a/tests/syntax_test_js_class.js +++ b/tests/syntax_test_js_class.js @@ -97,6 +97,19 @@ class MyClass extends TheirClass { // ^ entity.name.function variable.other.readwrite // ^^^^^^^^^^^^^ meta.function + static { +// ^^^^^^ storage.modifier +// ^ meta.block punctuation.section.block.begin + this.#foo = 42; +// ^^^^ variable.language.this +// ^ punctuation.accessor +// ^ punctuation.definition.variable +// ^^^ meta.property.object +// ^ keyword.operator.assignment +// ^^ meta.number.integer.decimal constant.numeric.value + } +// ^ meta.block punctuation.section.block.end + static = 42; // ^^^^^^ variable.other.readwrite diff --git a/tests/syntax_test_jsx.jsx b/tests/syntax_test_jsx.jsx index 43733ab..f454b70 100644 --- a/tests/syntax_test_jsx.jsx +++ b/tests/syntax_test_jsx.jsx @@ -1,33 +1,114 @@ // SYNTAX TEST "Packages/Babel/JavaScript (Babel).sublime-syntax" +// comment +// <- comment.line.double-slash.js punctuation.definition.comment.js +//^^^^^^^^^ comment.line.double-slash.js + +// comment // +// <- comment.line.double-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^ comment.line.double-slash.js +// ^^ punctuation.definition.comment.js + +/// comment +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^ comment.line.triple-slash.js + +/// comment /// +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^ comment.line.triple-slash.js +// ^^^ punctuation.definition.comment.js + +///////////////////////////////////////////////////////////////// +// <- comment.line.other.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.other.js punctuation.definition.comment.js +// ^ comment.line.other.js - punctuation + +/* */ +// <- comment.block.js punctuation.definition.comment.begin.js +//^^^ comment.block.js +// ^ - comment + + /**/ /***/ +// ^ - comment +// ^^^^ comment.block.empty.js punctuation.definition.comment.js +// ^ - comment +// ^^^^^ comment.block.empty.js punctuation.definition.comment.js +// ^ - comment + + /** @todo **/ +// ^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^ punctuation.definition.comment.begin.js +// ^^^^^ entity.other.attribute-name.documentation.js +// ^^^ punctuation.definition.comment.end.js + + /** +// ^ - comment +// ^^^ comment.block.documentation.js punctuation.definition.comment.begin.js +// ^ comment.block.documentation.js - punctuation + * @todo test it +// ^ comment.block.documentation.js punctuation.definition.comment.js +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^^ entity.other.attribute-name.documentation.js + **/ +//^^^ comment.block.documentation.js - punctuation +// ^^^ comment.block.documentation.js +// ^ - comment + + /*** @todo ***/ +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^ punctuation.definition.comment.begin.js +// ^^^^^ entity.other.attribute-name.documentation.js +// ^^^^ punctuation.definition.comment.end.js + + /*** +// ^ - comment +// ^^^^ comment.block.documentation.js punctuation.definition.comment.begin.js +// ^ comment.block.documentation.js - punctuation + * @todo test it +// ^ comment.block.documentation.js punctuation.definition.comment.js +// ^^^^^^^^^^^^^^^ comment.block.documentation.js +// ^^^^^ entity.other.attribute-name.documentation.js + ***/ +//^^^ comment.block.documentation.js - punctuation +// ^^^^ comment.block.documentation.js +// ^ - comment + +/// +// <- comment.line.triple-slash.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^ comment.line.triple-slash.js - meta.preprocessor + +//// +// <- comment.line.other.js punctuation.definition.comment.js +//^^^^^^^^^^^^^^^^^^^^ comment.line.other.js - meta.preprocessor + ; // ^^^^^^^ meta.jsx meta.tag // ^ punctuation.definition.tag.begin -// ^^^ meta.tag.name entity.name.tag +// ^^^ meta.tag.name entity.name.tag.native // ^^ punctuation.definition.tag.end Hello!; // ^^^^^^^^^^^^^^^^^ meta.jsx // ^^^^^ meta.tag // ^ punctuation.definition.tag.begin -// ^^^ meta.tag.name entity.name.tag +// ^^^ meta.tag.name entity.name.tag.native // ^ punctuation.definition.tag.end // ^^^^^^ - meta.tag // ^^^^^^ meta.tag // ^^ punctuation.definition.tag.begin -// ^^^ meta.tag.name entity.name.tag +// ^^^ meta.tag.name entity.name.tag.native // ^ punctuation.definition.tag.end Hello!; // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.jsx // ^^^^^^^^^^^^^ meta.tag -// ^^^^^^^^^^^ meta.tag.name +// ^^^^^^^^^^^ meta.tag.name - entity.name.tag.native // ^ punctuation.accessor // ^ punctuation.accessor // ^^^ entity.name.tag // ^^^^^^ - meta.tag // ^^^^^^^^^^^^^^ meta.tag -// ^^^^^^^^^^^ meta.tag.name +// ^^^^^^^^^^^ meta.tag.name - entity.name.tag.native // ^ punctuation.accessor // ^ punctuation.accessor // ^^^ entity.name.tag @@ -201,5 +282,5 @@ ; - ; -// ^^^^^ entity.name.tag + ; +// ^^^^^ entity.name.tag - entity.name.tag.native