Skip to content

Commit f0fa07b

Browse files
fix #21, fix #22, try to manage #20
1 parent 2d9608f commit f0fa07b

File tree

8 files changed

+140
-14
lines changed

8 files changed

+140
-14
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
{
2-
"enable_can_i_use_menu_option": true,
32
"PATH": "",
43
"node_js_custom_path": "node",
54
"npm_custom_path": "npm",
65
"yarn_custom_path": "yarn",
6+
77
"cordova_custom_path": "cordova",
88
"ionicv1_custom_path": "ionic",
99
"ionicv2_custom_path": "ionic",
1010
"angularv1_custom_path": "yo",
1111
"angularv2_custom_path": "ng",
1212
"react_custom_path": "create-react-app",
1313
"express_custom_path": "express",
14-
"yeoman_custom_path": "yo"
14+
"yeoman_custom_path": "yo",
15+
16+
"enable_can_i_use_menu_option": true,
17+
"enable_unused_variables_feature": true
1518
}

_generated_2018_01_23_at_00_15_41.py renamed to _generated_2018_01_23_at_15_18_32.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from shutil import copyfile
44
from threading import Timer
55

6-
PLUGIN_VERSION = "0.13.13"
6+
PLUGIN_VERSION = "0.13.14"
77

88
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
99
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)
@@ -243,7 +243,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
243243
output = subprocess.check_output(
244244
args, shell=True, stderr=subprocess.STDOUT, timeout=10
245245
)
246-
246+
247247
if sublime.platform() == "windows" and use_fp_temp:
248248
os.remove(fp.name)
249249

@@ -5469,9 +5469,14 @@ def on_modified_async(self):
54695469
super(unused_variablesViewEventListener, self).on_modified_async()
54705470

54715471
def on_selection_modified_async(self):
5472+
54725473
view = self.view
54735474

5474-
if view.find_by_selector('source.js.embedded.html'):
5475+
if not javascriptCompletions.get("enable_unused_variables_feature"):
5476+
view.erase_status("unused_variables")
5477+
view.erase_regions("unused_variables")
5478+
return
5479+
elif view.find_by_selector('source.js.embedded.html'):
54755480
pass
54765481
elif not Util.selection_in_js_scope(view):
54775482
view.erase_status("unused_variables")
@@ -5495,7 +5500,11 @@ def on_modified_async_with_thread(self, recheck=True):
54955500

54965501
view = self.view
54975502

5498-
if view.find_by_selector('source.js.embedded.html'):
5503+
if not javascriptCompletions.get("enable_unused_variables_feature"):
5504+
view.erase_status("unused_variables")
5505+
view.erase_regions("unused_variables")
5506+
return
5507+
elif view.find_by_selector('source.js.embedded.html'):
54995508
pass
55005509
elif not Util.selection_in_js_scope(view):
55015510
view.erase_status("unused_variables")
@@ -5594,7 +5603,7 @@ def on_modified_async_with_thread(self, recheck=True):
55945603

55955604
repetitions[variableName] = [variableRegion]
55965605

5597-
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration"], body)
5606+
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement"], body)
55985607
for item in items:
55995608

56005609
if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
@@ -5613,6 +5622,10 @@ def on_modified_async_with_thread(self, recheck=True):
56135622
for argument in item["arguments"]:
56145623
if isinstance(argument,dict) and "name" in argument and argument["type"] == "Identifier":
56155624
items += [argument]
5625+
elif "expressions" in argument and argument["expressions"]:
5626+
for expression in argument["expressions"]:
5627+
if isinstance(expression,dict) and "name" in expression and expression["type"] == "Identifier":
5628+
items += [expression]
56165629

56175630
item = item["callee"]
56185631

changelog/0.13.14.txt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
v0.13.14
2+
3+
## Fixes
4+
5+
- Fixed "Unused variable shows up in React project" #20
6+
- Fixed Unused variable is shown when it's used with "new" #21
7+
- Fixed Unused variable is shown when it's used with "return" or in a template string #22
8+
9+
## Improvements
10+
11+
- Added "enable_unused_variables_feature" option to the plugin settings.
12+
13+
14+
15+
=================================================================
16+
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **
17+
=================================================================
18+
19+
If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements
20+
21+
** USAGE **
22+
===========
23+
24+
See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈
25+
26+
27+
** WHAT IS THIS? **
28+
===================
29+
30+
This plugin uses Flow (javascript static type checker from Facebook) under the hood.
31+
32+
It offers better javascript autocomplete and a lot of features about creating,
33+
developing and managing javascript projects, such as:
34+
35+
- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!)
36+
- Ionic v1 and v2 projects (same as Cordova projects!)
37+
- Angular v1 and v2 projects
38+
- React projects (only about the creation at this moment)
39+
- React Native projects (only about the creation at this moment. I will add also NativeScript support)
40+
- Express projects (only about the creation at this moment)
41+
- Yeoman generators
42+
- Local bookmarks project
43+
- JavaScript real-time errors
44+
- etc.
45+
46+
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project)!
47+
48+
It turns Sublime Text into a JavaScript IDE like!
49+
50+
This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions)
51+
52+
** NOTE **
53+
If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed.
54+
55+
** OS SUPPORTED NOW **
56+
======================
57+
58+
👉 Linux (64-bit)
59+
👉 Mac OS X
60+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
61+
62+
❗❗ Dependencies ❗❗
63+
=======================
64+
65+
In order to work properly, this plugin has some dependencies:
66+
67+
👉 Sublime Text 3 (build 3124 or newer)
68+
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
69+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
70+
71+
Not required, but useful for typescript files (Flow wont work on this type of files):
72+
73+
👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin)
74+
75+
** Flow Requirements **
76+
=======================
77+
78+
It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions.
79+
80+
👉 Mac OS X
81+
👉 Linux (64-bit)
82+
👉 Windows (64-bit)
83+
84+
Email me for any questions or doubts about this new project on: [email protected]
85+
86+
** Donation **
87+
==============
88+
89+
If this project help you reduce time to develop and also you like it, please support it with a donation 😄👍. Thanks!
90+
91+
Open Collective: https://opencollective.com/javascriptenhancements/donate
92+
PayPal: https://www.paypal.me/LorenzoPichilli
93+
94+
Thanks anyway for your support! 😄😄
95+
96+
MIT License

helper/can_i_use/can_i_use_data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

helper/node/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
112112
output = subprocess.check_output(
113113
args, shell=True, stderr=subprocess.STDOUT, timeout=10
114114
)
115-
115+
116116
if sublime.platform() == "windows" and use_fp_temp:
117117
os.remove(fp.name)
118118

helper/unused_variables_view_event_listener.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ def on_modified_async(self):
1717
super(unused_variablesViewEventListener, self).on_modified_async()
1818

1919
def on_selection_modified_async(self):
20+
2021
view = self.view
2122

22-
if view.find_by_selector('source.js.embedded.html'):
23+
if not javascriptCompletions.get("enable_unused_variables_feature"):
24+
view.erase_status("unused_variables")
25+
view.erase_regions("unused_variables")
26+
return
27+
elif view.find_by_selector('source.js.embedded.html'):
2328
pass
2429
elif not Util.selection_in_js_scope(view):
2530
view.erase_status("unused_variables")
@@ -43,7 +48,11 @@ def on_modified_async_with_thread(self, recheck=True):
4348

4449
view = self.view
4550

46-
if view.find_by_selector('source.js.embedded.html'):
51+
if not javascriptCompletions.get("enable_unused_variables_feature"):
52+
view.erase_status("unused_variables")
53+
view.erase_regions("unused_variables")
54+
return
55+
elif view.find_by_selector('source.js.embedded.html'):
4756
pass
4857
elif not Util.selection_in_js_scope(view):
4958
view.erase_status("unused_variables")
@@ -142,7 +151,7 @@ def on_modified_async_with_thread(self, recheck=True):
142151

143152
repetitions[variableName] = [variableRegion]
144153

145-
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration"], body)
154+
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement"], body)
146155
for item in items:
147156

148157
if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
@@ -161,6 +170,10 @@ def on_modified_async_with_thread(self, recheck=True):
161170
for argument in item["arguments"]:
162171
if isinstance(argument,dict) and "name" in argument and argument["type"] == "Identifier":
163172
items += [argument]
173+
elif "expressions" in argument and argument["expressions"]:
174+
for expression in argument["expressions"]:
175+
if isinstance(expression,dict) and "name" in expression and expression["type"] == "Identifier":
176+
items += [expression]
164177

165178
item = item["callee"]
166179

make/_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from shutil import copyfile
44
from threading import Timer
55

6-
PLUGIN_VERSION = "0.13.13"
6+
PLUGIN_VERSION = "0.13.14"
77

88
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
99
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"0.13.1": "changelog/0.13.1.txt",
1414
"0.13.11": "changelog/0.13.11.txt",
1515
"0.13.12": "changelog/0.13.12.txt",
16-
"0.13.13": "changelog/0.13.13.txt"
16+
"0.13.13": "changelog/0.13.13.txt",
17+
"0.13.14": "changelog/0.13.14.txt"
1718
}

0 commit comments

Comments
 (0)