From 0cc8c56ac122b50ae633d02328a47d51d4ce8317 Mon Sep 17 00:00:00 2001 From: Rex Zeng Date: Mon, 3 Dec 2018 20:52:13 +0800 Subject: [PATCH] Identify JavaScript function parameters (#1446) Support parameters for these types of functions: ```javascript // es6 class method foo(x, y) {} // es6 arrow function (x, y) => x x => x // es5 function function foo(x, y) {} // es5 anonymous function function (x, y) {} ``` --- components/prism-flow.js | 3 +- components/prism-flow.min.js | 2 +- components/prism-javascript.js | 23 +++- components/prism-javascript.min.js | 2 +- prism.js | 23 +++- .../javascript/class-method_feature.test | 59 ++++++++++ .../javascript/function-variable_feature.test | 107 +++++++++++++++--- .../javascript/function_feature.test | 4 +- tests/languages/javascript/issue1526.test | 70 ++++++------ tests/languages/jsx/issue1294.test | 6 +- tests/languages/jsx/issue1335.test | 4 +- tests/languages/jsx/issue1421.test | 2 +- 12 files changed, 245 insertions(+), 60 deletions(-) create mode 100644 tests/languages/javascript/class-method_feature.test diff --git a/components/prism-flow.js b/components/prism-flow.js index 4c239d2b3a..95d034084b 100644 --- a/components/prism-flow.js +++ b/components/prism-flow.js @@ -10,6 +10,7 @@ ] }); Prism.languages.flow['function-variable'].pattern = /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i; + delete Prism.languages.flow['parameter']; Prism.languages.insertBefore('flow', 'operator', { 'flow-punctuation': { @@ -31,4 +32,4 @@ lookbehind: true } ); -}(Prism)); \ No newline at end of file +}(Prism)); diff --git a/components/prism-flow.min.js b/components/prism-flow.min.js index a2527bde41..a2c24633c7 100644 --- a/components/prism-flow.min.js +++ b/components/prism-flow.min.js @@ -1 +1 @@ -!function(a){a.languages.flow=a.languages.extend("javascript",{}),a.languages.insertBefore("flow","keyword",{type:[{pattern:/\b(?:[Nn]umber|[Ss]tring|[Bb]oolean|Function|any|mixed|null|void)\b/,alias:"tag"}]}),a.languages.flow["function-variable"].pattern=/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,a.languages.insertBefore("flow","operator",{"flow-punctuation":{pattern:/\{\||\|\}/,alias:"punctuation"}}),"Array"!==a.util.type(a.languages.flow.keyword)&&(a.languages.flow.keyword=[a.languages.flow.keyword]),a.languages.flow.keyword.unshift({pattern:/(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/,lookbehind:!0},{pattern:/(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/,lookbehind:!0})}(Prism); \ No newline at end of file +!function(e){e.languages.flow=e.languages.extend("javascript",{}),e.languages.insertBefore("flow","keyword",{type:[{pattern:/\b(?:[Nn]umber|[Ss]tring|[Bb]oolean|Function|any|mixed|null|void)\b/,alias:"tag"}]}),e.languages.flow["function-variable"].pattern=/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,delete e.languages.flow.parameter,e.languages.insertBefore("flow","operator",{"flow-punctuation":{pattern:/\{\||\|\}/,alias:"punctuation"}}),"Array"!==e.util.type(e.languages.flow.keyword)&&(e.languages.flow.keyword=[e.languages.flow.keyword]),e.languages.flow.keyword.unshift({pattern:/(^|[^$]\b)(?:type|opaque|declare|Class)\b(?!\$)/,lookbehind:!0},{pattern:/(^|[^$]\B)\$(?:await|Diff|Exact|Keys|ObjMap|PropertyType|Shape|Record|Supertype|Subtype|Enum)\b(?!\$)/,lookbehind:!0})}(Prism); \ No newline at end of file diff --git a/components/prism-javascript.js b/components/prism-javascript.js index c2ffa36754..f2cb936581 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -29,9 +29,30 @@ Prism.languages.insertBefore('javascript', 'keyword', { }, // This must be declared before keyword because we use "function" inside the look-forward 'function-variable': { - pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, alias: 'function' }, + 'parameter': [ + { + pattern: /(function(?:\s+[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)[^\s()][^()]*?(?=\s*\))/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/, + inside: Prism.languages.javascript + }, + { + pattern: /(\(\s*)[^\s()][^()]*?(?=\s*\)\s*=>)/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)[^\s()][^()]*?(?=\s*\)\s*\{)/, + lookbehind: true, + inside: Prism.languages.javascript + } + ], 'constant': /\b[A-Z][A-Z\d_]*\b/ }); diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index a0042da32f..d111f5035b 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,"function":/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\(|\.(?:apply|bind|call)\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,alias:"function"},constant:/\b[A-Z][A-Z\d_]*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/()[\s\S]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript",greedy:!0}}),Prism.languages.js=Prism.languages.javascript; \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},/\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/],number:/\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,"function":/[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\(|\.(?:apply|bind|call)\()/,operator:/-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^\/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)[^\s()][^()]*?(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/,inside:Prism.languages.javascript},{pattern:/(\(\s*)[^\s()][^()]*?(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)[^\s()][^()]*?(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z][A-Z\d_]*\b/}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,greedy:!0,inside:{interpolation:{pattern:/\${[^}]+}/,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/()[\s\S]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript",greedy:!0}}),Prism.languages.js=Prism.languages.javascript; \ No newline at end of file diff --git a/prism.js b/prism.js index 9e8aa53833..0acb158333 100644 --- a/prism.js +++ b/prism.js @@ -744,9 +744,30 @@ Prism.languages.insertBefore('javascript', 'keyword', { }, // This must be declared before keyword because we use "function" inside the look-forward 'function-variable': { - pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, alias: 'function' }, + 'parameter': [ + { + pattern: /(function(?:\s+[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)[^\s()][^()]*?(?=\s*\))/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/, + inside: Prism.languages.javascript + }, + { + pattern: /(\(\s*)[^\s()][^()]*?(?=\s*\)\s*=>)/, + lookbehind: true, + inside: Prism.languages.javascript + }, + { + pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)[^\s()][^()]*?(?=\s*\)\s*\{)/, + lookbehind: true, + inside: Prism.languages.javascript + } + ], 'constant': /\b[A-Z][A-Z\d_]*\b/ }); diff --git a/tests/languages/javascript/class-method_feature.test b/tests/languages/javascript/class-method_feature.test new file mode 100644 index 0000000000..303f481f95 --- /dev/null +++ b/tests/languages/javascript/class-method_feature.test @@ -0,0 +1,59 @@ +class Test { + foo( x, y = 0) {} + async bar(x, y = 0 ) {} + $ ( ) {} + awaitFoo(){} +} + +---------------------------------------------------- + +[ + ["keyword", "class"], + ["class-name", ["Test"]], + ["punctuation", "{"], + + ["function", "foo"], + ["punctuation", "("], + ["parameter", [ + "x", + ["punctuation", ","], + " y ", + ["operator", "="], + ["number", "0"] + ]], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["keyword", "async"], + ["function", "bar"], + ["punctuation", "("], + ["parameter", [ + "x", + ["punctuation", ","], + " y ", + ["operator", "="], + ["number", "0"] + ]], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["function", "$"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["function", "awaitFoo"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["punctuation", "}"] +] + +---------------------------------------------------- + +Checks for class methods. diff --git a/tests/languages/javascript/function-variable_feature.test b/tests/languages/javascript/function-variable_feature.test index 689fb4e923..f3916f71cd 100644 --- a/tests/languages/javascript/function-variable_feature.test +++ b/tests/languages/javascript/function-variable_feature.test @@ -1,25 +1,102 @@ -foo = function () {} +foo = function ( x, y) {} {foo: function () {}} -bar = function baz () {} +bar = async function baz (x ) {} +baz = async(x) => x fooBar = x => x +fooBar = ( x, y ) => x ಠ_ಠ = () => {} -Ƞȡ_҇ = (ಠ, Ƞ = 2) => {} +Ƞȡ_҇ = async (ಠ, Ƞ = 2) => {} ---------------------------------------------------- [ - ["function-variable", "foo"], ["operator", "="], ["keyword", "function"], - ["punctuation", "("], ["punctuation", ")"], ["punctuation", "{"], ["punctuation", "}"], - ["punctuation", "{"], ["function-variable", "foo"], ["punctuation", ":"], ["keyword", "function"], - ["punctuation", "("], ["punctuation", ")"], ["punctuation", "{"],["punctuation","}"],["punctuation","}"], - ["function-variable", "bar"], ["operator", "="], ["keyword", "function"], ["function", "baz"], - ["punctuation", "("], ["punctuation", ")"], ["punctuation", "{"], ["punctuation", "}"], - ["function-variable", "fooBar"], ["operator", "="], " x ", ["operator", "=>"], " x\r\n", - ["function-variable", "ಠ_ಠ"], ["operator", "="], ["punctuation", "("], ["punctuation", ")"], - ["operator", "=>"], ["punctuation", "{"], ["punctuation", "}"], - ["function-variable", "Ƞȡ_҇"], ["operator", "="], - ["punctuation", "("], "ಠ", ["punctuation", ","], " Ƞ ", ["operator", "="], ["number", "2"], ["punctuation", ")"], - ["operator", "=>"], ["punctuation", "{"], ["punctuation", "}"] + ["function-variable", "foo"], + ["operator", "="], + ["keyword", "function"], + ["punctuation", "("], + ["parameter", [ + "x", + ["punctuation", ","], + " y" + ]], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["punctuation", "{"], + ["function-variable", "foo"], + ["punctuation", ":"], + ["keyword", "function"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation","}"], + ["punctuation","}"], + + ["function-variable", "bar"], + ["operator", "="], + ["keyword", "async"], + ["keyword", "function"], + ["function", "baz"], + ["punctuation", "("], + ["parameter", [ + "x" + ]], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["function-variable", "baz"], + ["operator", "="], + ["keyword", "async"], + ["punctuation", "("], + ["parameter", [ + "x" + ]], + ["punctuation", ")"], + ["operator", "=>"], " x\r\n", + + ["function-variable", "fooBar"], + ["operator", "="], + ["parameter", [ + "x" + ]], + ["operator", "=>"], " x\r\n", + + ["function-variable", "fooBar"], + ["operator", "="], + ["punctuation", "("], + ["parameter", [ + "x", + ["punctuation", ","], + " y" + ]], + ["punctuation", ")"], + ["operator", "=>"], " x\r\n", + + ["function-variable", "ಠ_ಠ"], + ["operator", "="], + ["punctuation", "("], + ["punctuation", ")"], + ["operator", "=>"], + ["punctuation", "{"], + ["punctuation", "}"], + + ["function-variable", "Ƞȡ_҇"], + ["operator", "="], + ["keyword", "async"], + ["punctuation", "("], + ["parameter", [ + "ಠ", + ["punctuation", ","], + " Ƞ ", + ["operator", "="], + ["number", "2"] + ]], + ["punctuation", ")"], + ["operator", "=>"], + ["punctuation", "{"], + ["punctuation", "}"] ] ---------------------------------------------------- diff --git a/tests/languages/javascript/function_feature.test b/tests/languages/javascript/function_feature.test index fb0df40ad8..35fa9e929a 100644 --- a/tests/languages/javascript/function_feature.test +++ b/tests/languages/javascript/function_feature.test @@ -7,6 +7,7 @@ _() $() ಠ_ಠ() Ƞȡ_҇() +if(notAFunction) ---------------------------------------------------- @@ -19,7 +20,8 @@ $() ["function", "_"], ["punctuation", "("], ["punctuation", ")"], ["function", "$"], ["punctuation", "("], ["punctuation", ")"], ["function", "ಠ_ಠ"], ["punctuation", "("], ["punctuation", ")"], - ["function", "Ƞȡ_҇"], ["punctuation", "("], ["punctuation", ")"] + ["function", "Ƞȡ_҇"], ["punctuation", "("], ["punctuation", ")"], + ["keyword", "if"], ["punctuation", "("], "notAFunction", ["punctuation", ")"] ] ---------------------------------------------------- diff --git a/tests/languages/javascript/issue1526.test b/tests/languages/javascript/issue1526.test index d361155e41..320219cbc9 100644 --- a/tests/languages/javascript/issue1526.test +++ b/tests/languages/javascript/issue1526.test @@ -1,35 +1,35 @@ -fetch('some-resource.json') - .then(response => response.json()) - .catch(console.error); - ----------------------------------------------------- - -[ - ["function", "fetch"], - ["punctuation", "("], - ["string", "'some-resource.json'"], - ["punctuation", ")"], - ["punctuation", "."], - ["function", "then"], - ["punctuation", "("], - "response ", - ["operator", "=>"], - " response", - ["punctuation", "."], - ["function", "json"], - ["punctuation", "("], - ["punctuation", ")"], - ["punctuation", ")"], - ["punctuation", "."], - ["function", "catch"], - ["punctuation", "("], - "console", - ["punctuation", "."], - "error", - ["punctuation", ")"], - ["punctuation", ";"] -] - ----------------------------------------------------- - -Checks for catch function which is not a keyword. See #1526 +fetch('some-resource.json') + .then(response => response.json()) + .catch(console.error); + +---------------------------------------------------- + +[ + ["function", "fetch"], + ["punctuation", "("], + ["string", "'some-resource.json'"], + ["punctuation", ")"], + ["punctuation", "."], + ["function", "then"], + ["punctuation", "("], + ["parameter", ["response"]], + ["operator", "=>"], + " response", + ["punctuation", "."], + ["function", "json"], + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", ")"], + ["punctuation", "."], + ["function", "catch"], + ["punctuation", "("], + "console", + ["punctuation", "."], + "error", + ["punctuation", ")"], + ["punctuation", ";"] +] + +---------------------------------------------------- + +Checks for catch function which is not a keyword. See #1526 diff --git a/tests/languages/jsx/issue1294.test b/tests/languages/jsx/issue1294.test index 997f335124..4d167f146c 100644 --- a/tests/languages/jsx/issue1294.test +++ b/tests/languages/jsx/issue1294.test @@ -13,7 +13,9 @@ export default () => ( [ ["keyword", "export"], ["keyword", "default"], - ["punctuation", "("], ["punctuation", ")"], ["operator", "=>"], ["punctuation", "("], + ["punctuation", "("], + ["punctuation", ")"], + ["operator", "=>"], ["punctuation", "("], ["tag", [ ["tag", [ ["punctuation", "<"], @@ -66,4 +68,4 @@ export default () => ( ---------------------------------------------------- -See #1294. \ No newline at end of file +See #1294. diff --git a/tests/languages/jsx/issue1335.test b/tests/languages/jsx/issue1335.test index b34880d5af..35c2704ebf 100644 --- a/tests/languages/jsx/issue1335.test +++ b/tests/languages/jsx/issue1335.test @@ -21,7 +21,9 @@ ["script-punctuation", "="], ["punctuation", "{"], ["punctuation", "("], - "e", + ["parameter", [ + "e" + ]], ["punctuation", ")"], ["operator", "=>"], ["keyword", "this"], diff --git a/tests/languages/jsx/issue1421.test b/tests/languages/jsx/issue1421.test index f34147c94a..e74f14b002 100644 --- a/tests/languages/jsx/issue1421.test +++ b/tests/languages/jsx/issue1421.test @@ -55,4 +55,4 @@ class Columns extends React.Component { ] ---------------------------------------------------- -Checks for fragments short syntax. See #1421 \ No newline at end of file +Checks for fragments short syntax. See #1421