Align statements on specific word in WebStorm - webstorm

I want to align statements in WebStorm based on specific word/part of line.
Like this:
import React from 'react';
import { browserHistory, Router, Route } from 'react-router';
I know i can turn on assignment align in WebStorm but this is different, i need to choose manually where to split.
I saw that you can do this with Tabular plugin for vim but i need it in WS.

No, it's not possible currently. Similar feature request: https://youtrack.jetbrains.com/issue/IDEABKL-7033

Related

issue when trying to implement chartjs-plugin-datalabels in vue-chartjs charts

I am attempting to install chartjs-plugin-datalabels. I am using vue-chartjs and need to include the plugin for datalabels (if anyone can recommend anything else itd be much appreciated.)
my current versions for everything is
chart.js#3.8.0
vue-chartjs#3.5.1
vue#2.6.14
he is my code for reference:
<script>
import { Bar, mixins } from "vue-chartjs";
import ChartDataLabels from 'chartjs-plugin-datalabels';
Chart.register(ChartDataLabels);
export default {
extends: Bar,
props: ["options"],
mixins: [mixins.reactiveProp],
mounted() {
this.renderChart(this.chartData, this.options);
},
};
</script>
My issue:
after downloading chartjs-plugin-datalabels, none of my charts work anymore. I'm now getting these errors when I load my page:
I have a feeling the issue is likely due to the versions and version requirements not aligning at the moment. Is there any way to solve this?
Additionally, If there is an alternative way to have something similar to datalabels that does not require plugins Id must prefer avoiding the headache of this plugin.
my required look is to have a doughnut chart with 2 datasets where one is presented as a number and the other as a %
i.e:
You are using incopatible versions of chart.js and vue-chart.js.
Vue-chart.js v3 only works with Chart.js V2.
For Chart.js V3 you need vue-chart.js V4.
Make sure that if you decide to update vue-chart.js to V4 to import everything from the 'vue-chartjs/legacy' package since you are using Vue V2 and not V3.
So then your import will look like this:
import { Bar } from 'vue-chartjs/legacy'

import node js module in ember js framework

I am trying to import a simple node js module into Ember js. I followed the quick start at https://guides.emberjs.com/v3.8.0/getting-started/quick-start/ and got the People List working.
Then I added the simple upper-case module using npm install upper-case and added app.import('node_modules/upper-case/upper-case.js'); to ember-cli-build.js as mentioned in https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/.
After that, I opened scientists.js and added import to upper-case as follows:
import Route from '#ember/routing/route';
//import uc from 'upper-case';
export default Route.extend({
model() {
var arr = new Array();
arr[0] = 'Marie Curie'; // uc('Marie Curie');
arr[1] = 'Mae Jemison';
arr[2] = 'Albert Hofmann';
return arr;
}
});
If I remove the comments, it shows me a blank screen. If I use 'Marie Curie'.toUpperCase() it works, but I want to be able to import such node modules. How can I achieve this?
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
PS: I could make upper-case work in other JS frameworks such as React and Vue, so the module itself doesn't have any issues.
if you install ember-auto-import, you'll be able to use any npm package like how the particular npm package's documentation says to use it (provided the particular npm package is configured correctly on build).
https://github.com/ef4/ember-auto-import
This'll be a default soon (and is recommended over using app.import)
The reason ember-auto-import is recommended over app.import is because there are ~ 5 different module formats JS can exist in, and you need to worry about those when using app.import. ember-auto-import, powered by webpack, abstracts all that away from you.
fwiw, JS has .toUpperCase() built in: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
so you don't need that particular module.
Edit
I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.
did you get any errors with this?

Ember error:Ember is not defined no-undef

Hi I am following through with Plural sight course "Getting started with Ember 2"; I am stuck with this error: 'Ember' is not defined no-undef;
my code looks like this ember dot dollar sign dot get json two brackets; this is inside route ; the code works fine with static data. I am sorry the editor would not allow me to paste my code
Update:
Right way and best practice is to import Ember like this import Ember from "ember";
This is just lint error. you can add an exception for Ember. In .eslintrc.js file you can add
"globals": { "Ember": true }
Or if you dont want this rule be enabled then you can turn it off
rules: {
"no-unused-vars": "off"
}

Ember v. 2.x: watch vendor folder

I'm developing an Ember-JS application with a lot of JavaScript that performs of all kind of UX and styling tasks.
Because these tasks fall out of the scope the MVC-logic, I've put them into modules that I put in the vendor map.
Putting them into the Vendor folder doesn't mean I'm done tweaking these files, but to test them, I'm required to re-start the ember-server over and over again.
How can I make Ember watch these JS-files in my vendor folder and re-compile them when I change them?
The following page answers for Ember v. 1, but doesn't apply to Ember 2.0: https://discuss.emberjs.com/t/solved-watch-addon-directory-for-changes/6410/4
I also tried creating an addon, but ember (cli) answers with: “You cannot use the addon command inside an ember-cli project.”
It took me a while to connect all the pieces of information scattered over internet, but using #Lux 's anwers, this is what I found out.
1) Using the ember-cli, I generate a 'utility' (hence the utils folder):
ember g util grid-layout
This gives you a JS-file “app/utils/grid-layout.js” template to fill in. In my case, it was a matter of…
2) copy-paste the body of the function I created earlier, into the body of the function that ember-cli came up with:
export default function gridLayout(tree) {
…
return tree
}
3) Importing the function in the controller, in my case controllers/index.js. I found different examples on how to do this, with and without curly braces and using different paths to the module file, but this is what made it work for me:
import Ember from "ember";
import gridLayout from "../utils/grid-layout";
export default Ember.Controller.extend({…
Links:
https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Statements/export
https://blog.abuiles.com/blog/2014/10/03/working-with-javascript-plugins-in-ember-cli/
In ember-cli version 2.11.0 by default its watching vendor foler.
https://github.com/ember-cli/ember-cli/pull/6436

How does import statements work in ember-cli?

Am quite new to emberjs and ember-cli.
And I have always been wondering how a statement like this works:
import Ember from 'ember'
Does 'ember build' look up for 'ember' in node_modules?
I understand statements like this with relative paths:
import ENV from './config/environment'
but not the ones referred without a path.
This question raises in connection with Could not find module ember-validations, in an effort to find its root cause.
The sort answer is that Ember-CLI registers the global objects directly with the module system. Take a look at the code here. While it's wrapped in a little helper code, they essentially do this:
define('ember', [], function() {
return {
'default': window.Ember,
};
});
Then, Ember-CLI converts your import statement during compilation:
import Ember from 'ember';
Gets converted to:
var Ember = require('ember')['default'];
Keep in mind that this is how it's done when using a transpiler to use AMD modules. I'm not 100% sure how that code would work if we were using a native ES6 implementation, although I know that the syntax supports this kind of thing.