I am using EJS as my view engine on a node and express setup. I want to use ejs-lint to help get the line for errors. I haven't use a linter before, but from reading through the documentation here: https://github.com/RyanZim/EJS-Lint
I'm assuming you can just check errors on a specified file in command line like this: ejslint
Are my assumptions right and what am I doing wrong? I've already installed using npm install ejs-lint --save-dev
Also, if I plan to add ESlint to my project I'm guessing I can have it work alongside EJSlint?
Short answer
Run it directly from the terminal:
./node_modules/.bin/ejslint src/templates/some-template.ejs
Or with npm script:
// package.json
{
...
"scripts": {
"lint:ejs": "ejslint src/templates/some-template.ejs"
}
}
// terminal
npm run lint:ejs
ESLint and EJSlint are different, exclusive processes. What is analysed by ESLint should not be analysed by EJSLint and vice versa. Having both installed will not cause any issues.
Extended answer
For what I have tested, you have to use the ejs linter CLI per file. Which is not as useful as eslint which can process multiple files, exclusions etc.
If you had some src/templates directory, you could lint all the EJS files by doing something like this:
find src/templates -type f -iname '*.ejs' -exec bash -c "./node_modules/.bin/ejslint '{}'" \;
Which would work for Unix but not for Windows. You could prepare some node script to do it cross system with the ejslint API.
There is also a grunt plugin for it.
If you want to have both ESLint and EJSLint, you should have different npm scripts for them, e.g:
// package.json
{
...
"scripts": {
"lint": "npm run lint:js && npm run lint:ejs",
"lint:js": "eslint src --ignore-path src/templates",
"lint:ejs": "find src/templates -type f -iname '*.ejs' -exec bash -c \"./node_modules/.bin/ejslint '{}'\" \\;"
}
}
If you are using grunt, you can create different tasks for eslint and ejslint and then create a group task:
grunt.registerTask('lint', ['eslint', 'ejslint']);
Actually, the following way is the easiest and by far the fastest execution time. It also has better error logging because it doesn't pass through the find command.
ejslint $(find ./ -type f -iname '*.ejs')
You can run npx ejslint **/*.ejs from the command-line in your project root to check all the ejs files in your project.
the npx is needed because you used --save-dev (or -D) if you used --global (or -g) then you can call ejs lint directly using ejslint **/*.ejs
**/*.ejs will select any file ending in .ejs in any folder.
they is no definitve instructions on usage ejslint on cmd. try and debug your lines of code yourself with a debug in your editor ,as it says its something to do with syntax error within your code. worked for me.!
Ohh ya and good news is that you can still run ESlint aswell to debug your Js files .
Related
When running a lint like Eslint, I can use the command npm run check-lint to check all the code on my project. The same goes with npm run check-types from typescript. Is there a similar command with stylelint? I didn't find anything on their docs about it. I know there is a --fix flag, but that's not exactly what I want.
These are npm run scripts, and unrelated to Stylelint itself. You can use run scripts to run any arbitrary command from a package's "scripts" object.
For example, to add a check-styles command to your project you should edit your package.json file and add:
{
"scripts": {
"check-styles": "stylelint \"**/*.css\""
}
}
You'll then be able to use npm run check-styles.
I am trying to set up PhpStorm to work with Babel instead of UglifyJS. I need the minifed output file to be written with a different extension to the same directory where the source script is located.
I changed argument line in the File Watchers settings for Babel to the following: $FilePathRelativeToProjectRoot$ --out-dir dist --out-file-extension .min.js --source-maps --presets minify
This is works, but output file is saved to /dist directory (without specifying --out-dir dist everything stops working) and --out-file-extension option is completely ignored. I suspect this is due to the old version of Babel 6.2, which I can't manage to update.
This "Output paths to refresh" field changes also don't work: $FileNameWithoutExtension$.min.js
Please explain how to change the arguments to solve this problem.
For me this solution works, which saves the output files .min.js at the same location, as the original file:
Install Babel global sudo npm install --save-dev -g #babel/core
Install Babel Minify global sudo npm install babel-preset-minify --save-dev -g
Setup PhpStorm Watcher with the following parameters:
Programm:
/usr/local/lib/node_modules/#babel/cli/bin/babel.js
Arguments:
$FilePathRelativeToProjectRoot$ --out-file $FileDir$/$FileNameWithoutExtension$.min.js --presets /usr/local/lib/node_modules/babel-preset-minify
PhpStorm Watcher Setup
Last time I've followed recommended src layout (https://hynek.me/articles/testing-packaging/) with using tox with great success.
However VSCODE tests discovery fails because src package cannot be imported. That is expected as we want to test installed package.
But how to debug my tests in vscode?
(Q author here: I've done research on that before posting the question, so sharing what I found)
Not solution
You could modify your PYTHONPATH to point to your src directory, but it breaks the main benefit from having separate src directory (read the link from OP).
Solution
Use pip install -e path/to/your/package (usually pip install -e .) to enable development mode and test versus your codebase as it would be installed.
After that your tests should be discovered properly. Otherwise it is different issue - read vs code OUTPUT console.
Note: this requires setup.py as a build backend
workaround for poetry
pyproject.toml
[build-system]
requires = [
"poetry-core>=1.0.0",
"setuptools" # to support local installations
]
then
poetry build --format sdist && tar --wildcards -xvf dist/*.tar.gz -O '*/setup.py' > setup.py
pip install -e .
Source: https://github.com/python-poetry/poetry/issues/34
TLDR: proper solution is outside of poetry scope, links to python-list discussions: https://github.com/python-poetry/poetry/issues/34#issuecomment-732478605
In a GitHub module, it is possible to symlink to another file within the same module. But is it possible to have this symlink survive / work in the NPM package of same module?
I'm using a Mac and so far I've done
ln -s [filename-1.0.4.js] [filename.js]
This works great for github.io-pages, but the file disappears when published to NPM.
After some rounds with NPM support it seems that only folders can be linked with npm link
So the answer to my question is no. Here's the documentation for npm link
And here is the answer from support:
[...]
To create a symlink in a package.json, we recommend using the scripts field.
For example:
"scripts": {
"postinstall": "npm link ../somelocallib",
"postupdate": "npm link ../somelocallib"
}
[...]
I've recently switched over from using the Bash command prompt to Zsh on Mac OSX.
Problem I have using Zsh is that the command I would use to watch Sass files no longer works.
The script file I have is sass.sh and the content is...
#!/bin/sh
sass --style expanded --watch Assets/Styles/Sass:Assets/Styles --debug-info
exit 0
...but every time I run sh sass.sh I get the error...
/Users/<home-directory>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find sass (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /Users/<home-directory>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /Users/<home-directory>/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1230:in `gem'
from /Users/<home-directory>/.rvm/gems/ruby-1.9.3-p125/bin/sass:18:in `<main>'
from /Users/<home-directory>/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/<home-directory>/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'
...and I don't know how to resolve this problem.
It looks like it just can't locate the Sass gem, but if I run gem list --local I can see sass (3.2.3, 3.2.1, 3.1.20, 3.1.17, 3.1.15) in the list of gems. BUT I do also get an error again displayed first...
Error loading RubyGems plugin "/Users/<home-directory>/.rvm/gems/ruby-1.9.3-p125/gems/rubygems-bundler-0.2.8/lib/rubygems_plugin.rb": cannot load such file -- rubygems_bundler/rubygems_bundler_installer (LoadError)
I've looked around on Google and SO and found miscellaneous references to similar issues but none that helped me and my specific issue.
Can any one tell me what I need to do to resolve this issue so I can continue to use Zsh and run my Sass script.
Well, seems the answer is very simple. When using Zsh you no longer use the sh command but the zsh command.
So instead of sh sass.sh I just needed to do zsh sass.sh