From 8b7957250f6903757ffbf6d6b2073f73919e7356 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Mon, 31 Jul 2017 12:36:29 +0100 Subject: [PATCH] feat: add javascript_not_expression switch --- README.md | 9 +++++++++ doc/switch.txt | 9 +++++++++ plugin/switch.vim | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 5cc71c3..15121da 100644 --- a/README.md +++ b/README.md @@ -454,6 +454,15 @@ Object* foo = bar->baz; ``` Switching to var from const or let is unsupported, since it's assumed to be an unlikely case. +* Comparison to false vs negation operator + ``` javascript + if (foo == false) { } + if (!foo) {} + + if (foo.has(bar) === false) {} + if (!foo.has(bar)) {} + ``` + ### Coffeescript arrows ``` coffeescript diff --git a/doc/switch.txt b/doc/switch.txt index 806823a..fa28b46 100644 --- a/doc/switch.txt +++ b/doc/switch.txt @@ -526,6 +526,15 @@ ES6-style variable declaraions (g:switch_builtins.javascript_es6_declarations) < Switching to var from const or let is unsupported, since it's assumed to be an unlikely case. +Comparison to false vs negation operator (g:switch_builtins.javascript_not_expression) +> + if (foo == false) { } + if (!foo) {} + + if (foo.has(bar) === false) {} + if (!foo.has(bar)) {} +< + Coffeescript ~ Arrows (g:switch_builtins.coffee_arrow): diff --git a/plugin/switch.vim b/plugin/switch.vim index 64812ea..439926f 100644 --- a/plugin/switch.vim +++ b/plugin/switch.vim @@ -121,6 +121,10 @@ let g:switch_builtins = \ '\': '\1=>', \ '^\(.*\)=>': '\1->', @@ -205,6 +209,7 @@ autocmd FileType javascript let b:switch_definitions = \ g:switch_builtins.javascript_function, \ g:switch_builtins.javascript_arrow_function, \ g:switch_builtins.javascript_es6_declarations, + \ g:switch_builtins.javascript_not_expression, \ ] autocmd FileType coffee let b:switch_definitions =