How could you LINT your LESS and SCSS files in Node JS WITHOUT using grunt or gulp? - node.js

So the thing is I went through the internet and checked for available linters. Mostly all the the LESS linters available provide a command line interface or a plugin for grunt or gulp. What I really want is a simple Node Plugin which is configurable and usable with NODEJS through Code and not through CLI.
Also due to unavailability of the tags such as LESSLINT and SCSSLINT could not add those tags to the questions.
Is there any node plugin available to do this?
If not, How can I use CLI through NodeJS and also get the callbacks?
I need the callbacks since that's the most powerful feature of NodeJS and besides my code is dependent on the callbacks..
P.S.: I do not need any code, all I need is directions.
Thanks for the support

A Node port of scss-lint was recently released, you can get it here: https://github.com/FWeinb/scsslint
It can be used either in Grunt or just as a normal Node module.
LESS has built-in linting, but it doesn't seem to be accessible through Node. You can use spawn or exec and the LESS CLI with the --lint flag. See the LESS docs here: http://lesscss.org/usage/#command-line-usage-options

Related

Is Node.js just used for dev-tooling on the front-end?

For my understanding, node.js is a javascript-engine which is running javascript-code without using a browser(window-global). You can use javascript on a server. But I saw now a lot of tutorials(react, angular, vue etc.). In every tutorial, I have to install something with npm. I can follow there are several dev-tools which I can use on my local machine to minimize my javscript-files or compile sass to css. But in the end, when I put my files on a webserver, I just have normal javascript-files, css-files etc. No node.js code in it, right?
My question is: React, angular, vue.js etc. are written in just normal javascript without node.js right? The reason why I use npm ist just to install every dependencies with one command, right?
A question more: Is there an any recommended order to learn all these frontend-development stuff? There are so much words I have to google it: angular.js, react, vue.js, vanilla.js, typescript, backbone.js, bower, grunt, webpack, yarn etc... I dont know where I start, so I look into few tutorials, but everytime I go through these tutorials, there is a new word(technology) I have to research.
I think you're getting your terminology a little muddled.
Node.js is a JavaScript runtime, built on Google Chrome’s V8 JavaScript engine. However, that is not to say that Node programs are executed in a browser. They aren’t. Rather, the creator of Node (Ryan Dahl) took the V8 engine and enhanced it with various features (such as a file system API and an HTTP library) to create a program we can use to execute JavaScript on our computers.
Node comes bundled with a package manager called npm which you can use to install packages (such as React and Angular) from the npm registry. These packages are indeed written in normal JavaScript (or a language that compiles to JavaScript, such as TypeScript).
The reason why I use npm is just to install every dependencies with one command, right?
Kinda. You can certainly use npm to install dependencies. However, it does a lot more that that. For example you can use npm scripts to carry out various build tasks, or you can create a package yourself and use npm to publish it to the registry.
A question more: Is there an any recommended order to learn all these frontend-development stuff?
As with everything, it depends. What are you trying to build? It's relatively pointless to learn about Node, npm, React and Angular if you are attempting to build a simple static website. If I were you, I'd define a clear goal and set about learning the technologies you'll need to reach that goal. Saying that, if you are doing anything with front-end development, learning about npm will be a good use of your time.
Here's an article by way of further reading that explains things a little more: https://www.sitepoint.com/an-introduction-to-node-js/

WebStorm remote interpreter not working with TSLint

I followed this link to setup a remote interpreter with Docker in WebStorm, now I would like to use it as the interpreter for the TSLint plugin, I get this in the upper window:
But when I try to configure the interpreter I only get the option for a local interpreter.
Is there any way to configure it to use the remote one?
This is what I see:
Not possible ATM. Here is official explanation: https://youtrack.jetbrains.com/issue/WEB-25411#comment=27-1906237
This is the correct behavior described in Help (https://www.jetbrains.com/help/webstorm/2016.3/node-js.html)
The reason is that the project Node.js interpreter is used in many places - to run TypeScript service/compiler, external linters, etc. And all these services require local Node.js interpreter, they can't be run remotely. The only place where remote interpreters are supported is Node.js running/debugging. That's why setting up remote interpreter is only possible from Node.js Run configuration
There are requests to add support for remote execution for Karma/Mocha/ESLint -- see those tickets -- maybe you will find and answer there (or create new Feature Request ticket if these tickets below do not have clear answer/not suitable for your needs):
https://youtrack.jetbrains.com/issue/WEB-20824
https://youtrack.jetbrains.com/issue/WEB-14665
https://youtrack.jetbrains.com/issue/WEB-22179
On related note (this comment and around):
https://youtrack.jetbrains.com/issue/WEB-22572#comment=27-1836383
If so...our Docker integration isn't currently for that use case. Everything to do with the development – linters, build tools, test runners, ts language service, angular language service, angular cli, react project generator, react native, etc. – runs against a local NodeJS and node_modules.

Run jest with electron instead of node

To make a long story short, I'd like to run my jest tests (using CLI) with electron instead of node.
It's relevant when using native module, because you need to build them using electron header while jest run them using plain node.
So I must either build my native modules for my app (at least in dev mode) or my tests, I can't have both to work.
In this thread they propose to use mocha, but I want to use jest, which is far more advanced and interact well with React.
Note that I don't want to mock the native module, since I write integration tests.
I opened an issue about the zmq github repo. One proposed solution is "to target your tests using ELECTRON_RUN_AS_NODE=true electron as your node runtime".
This is a very good solution, since using electron will both make the test environment closer to the execution environment and solve my specific issue with native modules.
I'd like to apply that, but I do no seem to be able to setup the jest CLI to use electron instead of node, and I have no idea where to start. Maybe I should run jest programmatically without the CLI ? But I might lose the nice test filtering features of the CLI.
Has anyone solved this already?
"ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/.bin/jest works fine
If you're on Windows, then Eric Burel's excellent discovery might need a bit of a tweak to use the environment variable, and call the right version of Jest:
cross-env ELECTRON_RUN_AS_NODE=true ./node_modules/.bin/electron ./node_modules/jest-cli/bin/jest.js
Sadly, the colouring of the text in the results is lost.

How to test NodeJs CLI javascript

I need to put some tests around a nodejs command line utilities\modules. No browser involved and I'm using a lot of the "fs" module to work the file system, so i'm not sure a browser based test mechanism would work (sandboxing).
any modules that would help here?
Check out Vorpal.js. This lets you create an interactive CLI in node, in which you can then run custom commands to test the various things you want to test.
Disclaimer: I am its author.

Is it possible to use JSDoc on CoffeeScript files without compiling them?

I want to start formally documenting my NodeJS project written in CoffeeScript. After investigating most of the documentation options I've decided to (attempt to) go with JSDoc.
Given that I've installed this globally with NodeJS, is there any way I can get JSDoc to recognize my .coffee files the way Mocha and Node itself do? (Both support compiler flags, eliminating the need for build tools like Grunt or Gulp)
Since JSDoc uses espree(JavaScript AST parser), you can't do that. But some alternatives like Codo or Docco exist.

Resources