How can I have multiple imports in multiple lines? - eslint

This is how it is currently:
import {
t1,
t2,
t3,
t4,
t5,
t6,
t7,
t8,
t9,
....
t20,
} from someModule;
How I want it :
import {
t1,t2,t3,t4,t5,t6,
t7,t8,t9,..
..,t20,
} from someModule;
I am using eslint and prettier following airbnb style guide. I am wondering whether it would be possible with eslint and prettier combination or should I look at alternatives.
Thanks in advance. Lmk if I need to share my .eslintrc & .prettierrc.js file here.

Related

Select or Highlight all instances of a word type or color in Sublime Text 4

Note: I am not trying to select all instances of a single word.
I can not find a way to select all instances of a word type, similarly how different words are colored according to the format rules from the file type you have.
Here is an image of some sample code of a SQL file.
For example, I would like to Highlight all instances of this reddish pink color, or the baby blue colored words in the whole file. So that way I can capitalize them or copy them or what have you.
From the Tools menu -> Developer -> New Plugin...
Replace the template with the following:
import sublime
import sublime_plugin
class SelectByScopeSelectorCommand(sublime_plugin.TextCommand):
def run(self, edit, scope_selector=None, last_scope_only=True, auto_select=False):
if not scope_selector:
scope_at_first_caret = self.view.scope_name(self.view.sel()[0].a)
if last_scope_only:
scope_at_first_caret = scope_at_first_caret.split()[-1]
if auto_select:
scope_selector = scope_at_first_caret
else:
self.view.window().show_input_panel('Scope Selector', scope_at_first_caret, lambda value: self.view.run_command('select_by_scope_selector', { 'scope_selector': value }), None, None)
return
regions = self.view.find_by_selector(scope_selector)
if regions:
self.view.sel().clear()
self.view.sel().add_all(regions)
self.view.show_at_center(self.view.sel()[0])
else:
self.view.window().status_message('Unable to find anything matching selector "' + scope_selector + '"')
Save it, in the folder ST recommends, as something like select_by_selector.py (the filename doesn't matter too much, but the extension is important).
Then, in your User keybindings, you can add something like:
{ "keys": ["alt+;"], "command": "select_by_scope_selector", "args": { "last_scope_only": true, "auto_select": true } },
Then, pressing Alt+; with the selection caret somewhere in SELECT, it will automatically select all other words in the buffer with the same scope, like DELETE, UPDATE, INSERT etc. Or on INT, it could select all INT, CHAR etc.
You may notice that the "types" you referred to in your question are called scopes in ST parlance. Note that colors don't necessarily have a one to one mapping with scopes depending on your color scheme, so it may select more or less than you expect it to.
You can play around with the keybinding, by removing all arguments for example, to see what effect it has and customize which scopes are being searched for. You can also add it to a menu or the command palette, if that is more to your liking. I suggest to read the ST docs for more info.

Is there extension or function to know bracket declaration when focued close bracket

I want to know declaration of open bracket when focused close bracket.(ex. if (...) ).
I know emacs, vscode, vim are has goto declaration function. But, they needs 1 action(type M-.(emacs),F12(vscode),%(vim)). I don't want to type some key each time. So, I want to know declaration of bracket with 0-action.
I don't care how displays in declaration(pop-up, mini buffer, status bar)
Background:
I'm in fixing legacy code. The code is too much nested with ifs and fors and whiles.
By much nested, end of code are many continus close bracket(}) like below.
for (var item in list){
if (cond1) {
...
while( cond2 ) {
...
if (cond3) {
...
} else {
...
}
}
}
list.append(item)
}
}
I usually mistake cond2 and cond3, created bugs, don't show log messages, and spent much time.
This question was translated by google translator. so, if you couldn't recognise this, please comment.
When your cursor is on a bracket, the other one is highlighted automatically if you have :help matchparen enabled.
When your cursor is on a bracket, you can jump to the opening one with :help %.
To quote Mass:
Yes- the plugin match-up has this feature:
https://github.com/andymass/vim-matchup
Using the option
let g:matchup_matchparen_offscreen = { 'method': 'popup' }
There is also the ability to show the match in the statusline (the
default):
let g:matchup_matchparen_offscreen = { 'method': 'status' }`

Are there better interface to add Highcharts support to Zeppelin

Apache Zeppelin has good support for AngularJS. While there is a gap between Scala and Javascript.
I am trying to add Highcharts support to Zeppelin to fill in this gap. The main goal is to plot it simply directly from Spark DataFrame.
After couple round refactor, I come up with the following interface.
github.com/knockdata/zeppelin-highcharts
Here are two options. Which option is better?
Option A
This is an example to plot highcharts.
highcharts(bank,
"marital",
List("name" -> "age", "y" -> avg(col("balance")), "orderBy" -> col("age")),
new Title("Marital Job Average Balance").x(-20),
new Subtitle("Source: Zeppelin Tutorial").x(-20),
new XAxis("Age").typ("category"),
new YAxis("Balance(¥)").plotLines(Map("value"->0, "width"->1)),
new Tooltip().valueSuffix("¥"),
new Legend().layout("vertical").align("right").verticalAlign("middle")
)
Here is the code without extra option.
highcharts(bank,
"marital",
List("name" -> "age",
"y" -> avg(col("balance")),
"orderBy" -> col("age")))
Option B
I come up this option with inspiring by #honnix's answer. It has more syntactic sugar.
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.title(Title("Marital Job Average Balance").x(-20))
.subtitle(Subtitle("Source: Zeppelin Tutorial").x(-20))
.xAxis(XAxis("Age").typ("category"))
.yAxis(YAxis("Balance(¥)").plotLines("value"->0, "width"->1))
.tooltip(Tooltip().valueSuffix("¥"))
.legend(Legend().layout("vertical").align("right").verticalAlign("middle"))
.plot
A simple plot without option will be
highcharts(bank).series("marital")
.data("name" -> "age", "y" -> avg(col("balance")))
.orderBy(col("age"))
.plot
It will generate a chart here.
It would be good to have some kind of chaining methods to pass in those parameters, because putting a few lists together in one apply() method is a little bit hard to read.

Any method for finding the combination of a word?

I want to find the all possible combination of a given word. For example say, the given word is "the" then I need "t,h,e,teh..". I have to find this in groovy, is there is any method? Or please say me the outline of the algorithm.
If you need subsets as well, you could do something like this:
("word" as List).subsequences()*.permutations().inject( [] ) { list, set ->
list.addAll( set )
list
}*.join().sort { it.length() }
which gives you the following output:
[o, d, r, w, dw, wd, do, od, dr, rd,
wr, rw, ow, wo, ro, or, owd, wod, wdo,
odw, dwo, dow, orw, owr, wor, wro,
rwo, row, dor, ord, odr, rdo, rod,
dro, wdr, rwd, drw, rdw, wrd, dwr,
wrdo, orwd, wrod, wodr, ordw, wdor,
rwod, wdro, word, owdr, rdow, drow,
drwo, rdwo, odwr, dorw, odrw, dowr,
dwro, rodw, dwor, owrd, rowd, rwdo]
edit: changed the set.each to a list.addAll as it should be faster (and reads a lot easier)
("word" as List).permutations()*.join() will generate all permutations, not including subsets. Permutations of every possible subset could use this.
Update: After reading Tim's answer, I could come up with this:
("word" as List).subsequences()*.permutations().collect{ it*.join() }.flatten().sort{ it.length() } (could go without .sort{...})

ReSharper: formatting of delegates

I like my code formatted like this:
WithDataContext.Execute(
delegate(DataContext dataContext)
{
// code goes here.
});
ReSharper wants to auto-format it like this:
WithDataContext.Execute(
delegate(DataContext dataContext)
{
// code goes here.
});
What options do I need to tweak to get what I want?
ReSharper -> Options -> C# -> Formatting Style -> Braces Layout -> Anonymous method declaration
Set to "At next line (BSD style)"
ReSharper -> Options -> C# -> Formatting Style -> Other -> Align Multiline Constructs
Uncheck "Call Arguments" and you'll get what you're looking for.
There isn't an option to format quite like that that I can find, but take a look at ReSharper|Options: Languages|C#|Formatting Style|Braces Layout. It has a number of options like anonymous type format.

Resources