Tern Autocomplete with Express - express

I'm using the tern_for_vim plugin for developing node applications. Currently various functions aren't displaying and I'm unsure why. For example: none of the html verb functions appear in the autocompletion list app.get (after assigning var app = express()) however app.listen does and I'm unsure why. I have searched around but can't find anywhere documenting usage of tern with express. Does anyone have a solution?
I have the following configuration file:
.tern-project:
{
"libs": [
"browser",
"jquery",
"express"
],
"plugins": {
"node" : {}
}
}

libs declaration is used for tern JSON type definitions. Today it doesn't exists express tern JSON type definitions, that's why you cannot use it inside your .tern-project
I have created and initialized tern-express project to support express with tern. Any contribution are welcome!

Related

Referencing assets in data property or in method in vue 3 with vite

I am just starting out with Vue 3 and vite and everything is working well in development. However, when I build the app for production, the assets declared in the data property are ignored and throw a 404 in the production build. Here is what the data object looks like...
data() {
return {
testimonials: [
{
customer_name: "John Doe.",
comment: "Some customer comment here...",
image: "/src/assets/img/awesome_customer.png",
},
...
]
}
}
Referencing the asset as "/src/assets/img/awesome_customer.png" works in the template tag and production bundles it properly but not if it is used in the data property or in a method.
With the vue-cli we'd use the require() but I've not managed to get it to work in vite any ideas on how I can achieve this?
UPDATE:
I set up a sample repo here demonstrating what am referring to. The readme contains the steps to reproduce.
Upgrading to vite 2.0 and importing the images instead of referencing them directly in the data object solved the issue. Though am wondering if there is a better approach.
You can follow the discussion here

WebStorm Vue-i18n, anyway to get editor autocompletion support?

I'm localizing a webapp using vue-i18n. Is there anyway to get WebStorm to recognize strings in a function prefixed with $t as a dot notation path reference?
$t('messages.some.key')
in my en.js file which looks like:
exports defaults {
messages: {
some: {
key: "Foo"
}
}
}
It would be nice if it provided me with autocomplete and also syntax highlighting if the key doesn't exist.
Old question but still unanswered... For those who have been looking for it and ended up here (like me), meanwhile there is a plugin: https://plugins.jetbrains.com/plugin/12981-i18n-support (https://github.com/nyavro/i18nPlugin)
See https://kazupon.github.io/vue-i18n/guide/tooling.html#i18nplugin-intellij-platform for more information how to configure the plugin.

absolute paths with react-native raise eslint errors

in my React Native app, within my package.json I've set the name to rpms. This allows me to do:
import Component from 'rpms/App/common/Component'
Flow gets on well with this type of imports, however eslint-plugin-import raises import/no-extraneous-dependencies, and import/no-unresolved. I've added to my rules:
"import/no-unresolved": [2, { "ignore": ["rpms"] }],
And that way I disconnect import/no-unresolved. To disable the other I've tried with:
"settings": {
"import/ignore": ["rpms"]
},
However it's not working. However, I have the feeling, that maybe ignoring these errors is not the right way to go.
Published a package to solve this issue
https://www.npmjs.com/package/eslint-import-resolver-reactnative
Let me know how it goes.

How do I make a build profile reference modules that are within a "black box" library layer?

The tutorials got me going with the Dojo build system. However I'm left with a question that'll make or break the possibility of deploying a fully built release in my case. It is possible that the tutorial explains it, but that I didn't get it. Apologies if that was the case !
I use a library that lives inside an AMD layer ; let's call it blackboxLayer.js. There are several packages inside that layer, but I suppose the question would be the same if there was only one. So let's say that blackboxLayer.js contains a single package called blackbox, with modules blackbox/A and blackbox/B. To be sure that things are fun, that layer is bootable. And of course it's closed source stuff.
My app modules reference blackbox/A or blackbox/B. How do I make my build profile go look for the blackbox package inside that blackboxLayer.js file, rather than in a directory ?
Thanks for any input. :)
If built file blackboxLayer.js is in relative path /release/blackbox/layers, there is a separate dojo layer
<script type="text/javascript" src="path to dojoLayer.js"></script>
and
var dojoConfig = {
packages: [
{ name: 'blackbox', location: 'release/blackbox' }
]
};
then code inside this function can reference modules A and B,
require(['blackbox/layers/blackboxLayer'],
function () {
require(['dojo/parser', 'dojo/ready'],
function (parser, ready) {
ready(function () {
require(['blackbox/A', 'blackbox/B'],
function (blackboxA, blackboxB) {
// call blackboxA and blackboxB
});
});
});
});
If there is no separate dojo layer, you can reference blackboxLayer.js in the script tag, and omit the package def and requiring blackboxLayer.
The interim solution I've been using since this question has been posted is NOT to use dojo's builder... Instead I use a lightweight grunt pattern that concatenates AMD sources into a layer, and then I reference the layer from dojoConfig's deps property. The concatenation process is visible here : https://github.com/gruntjs-updater/grunt-amd-concat

How to include legacy module in Dojo AMD

I'm trying to migrate an application from dojo 1.6 to version 1.9.1, and I've a legacy module that I didn't want to migrate yet (it's pretty complex and will take me some time to understand). The Dojo docs indicate you can load legacy modules along with AMD modules, but when I try, I'm getting a "dojo.provide is not a function" when the loader tries to load the legacy module.
My script:
require([..., "agsjs/dijit/TOC","dojo/domReady!"],
function(..., TOC) {
on(map,'layers-add-result',function(results){
//Add Legend
var toc = new TOC({
map: map,
layerInfos:legendLayers
}, 'legendDiv');
toc.startup();
});
});
The first line of code of the module:
dojo.provide('agsjs.dijit.TOC');
Everything works until the loader tries to load the agsjs/dijit/TOC module, where I get a "dojo.provide is not a function" error. How do I solve this without having to refactor the entire module to AMD? Thanks
In order for legacy modules to load, you need to run the loader in legacy mode, which means you cannot set async: true. As long as you are running with async: false (the default), you will be able to load and use legacy modules from AMD modules, and vice-versa.
A good point of AMD is that you don't have to use "dojo" and "dijit" global variables now. If you don't want change all those dojo.xxx calls in your old modules, you may try to wrap you old module in a
define([
"dojo/_base/declare",
"dojo", "dijit",
...
], function(declare, dojo, dijit) {
return declare([/*your parent widgets*/], {
//your old module content at here, maybe you need make little modifications of your old module
});
});
So that those dojo.xxx functions may still works.
This link may provide everything you need:
http://dojotoolkit.org/reference-guide/1.9/releasenotes/migration-17.html