Think of integrating https://github.com/markstory/lint-review
wget --no-cache --cache=off -O ~/lint_install.sh https://raw.githubusercontent.com/vovanmix/linters-formatters-analyzers/master/install.sh
chmod +x ~/lint_install.sh
~/lint_install.sh
rm ~/lint_install.sh
echo 'alias lint="~/lint"' >> ~/.zshrc
source ~/.zshrc
OR
echo 'alias lint="~/lint"' >> ~/.bash_profile
source ~/.bash_profile
it will lint only changed files
lint
We need to look up the path to global packages. Use these paths later in configurations later.
The example shows setup using nvm.
> which node
/Users/xxx/.nvm/versions/node/v5.5.0/bin/node
> which rubocop
/Users/xxx/.rbenv/shims/rubocop
Also, replace xxx with your user name.
Eslint is used generally for formatting. Tslint - for Typescript-specific settings.
Settings -> Languages And Frameworks -> JavaScript -> Code Quality Tools -> JSHint
Enable
Use Config Files
Custom configuration file: /Users/xxx/.jshintrc.lint
Settings -> Languages And Frameworks -> JavaScript -> Code Quality Tools -> ESLint
Disable (the built in linter)
Install the ESLint
plugin.
Settings -> Other Settings -> ESLint
Node Interpreter: /Users/xxx/.nvm/versions/node/v5.5.0/bin/node
ESLint bin: /Users/xxx/.nvm/versions/node/v5.5.0/bin/eslint
Custom configuration file: /Users/xxx/.eslintrc.lint.json
Extensions: .ts,.js
Settings -> Languages And Frameworks -> TypeScript -> TSLint
Enable
Node Interpreter: /Users/xxx/.nvm/versions/node/v5.5.0/bin/node
TSLint package: /Users/xxx/.nvm/versions/node/v5.5.0/lib/node_modules/tslint
Configuration file: /Users/xxx/tslint.lint.json
I wasn't able to make it work with config file out of the project directory. The only way for now is to temporary copy the config file from the user dir to the project dir and reset it afterwards.
cp ~/.rubocop.lint.yml ~/project-dir/.rubocop.yml
And enable RubyMine built in rubocop linting.
Do not commit this rubocop file, keep it unstaged for now!
We need some tweaks because linter libs are currently installed globally and we don't want to mess with the existing config:
Here we need to look up the path to global packages and use it. The example shows setup using nvm.
> which node
/Users/xxx/.nvm/versions/node/v5.5.0/bin/node
> /Users/xxx/.nvm/versions/node/v5.5.0/bin/eslint -c ~/.eslintrc.lint.json --fix path-to-file.js
> /Users/xxx/.nvm/versions/node/v5.5.0/bin/tslint -c ~/tslint.lint.json --fix path-to-file.js
Here we need to use global set up of Rubocop
> which rubocop
/Users/xxx/.rbenv/shims/rubocop
> /Users/xxx/.rbenv/shims/rubocop --config ~/.rubocop.lint.yml -a path-to-file.rb
Set up them in settings -> Tools -> External Tools using settings described below to fill in Name
, Program
, Parameters
, Working dir
fields respectively.
Uncheck Open Console
in each of them.
Be careful, Eslint formatter can break code (remove parts of it, or duplicate it) in big complex files due to unknown bug, especially if there's a lot of function -> arrow function fixes and object reformatting involved. To avoid it, fix these errors manually and call format then.
It will be great if somebody could find out the solid way to reproduce this bug, and file an issue on Eslint github repo!
Run them with cmd + shift + A
and typing the first chars of the name.
/Users/xxx/.nvm/versions/node/v5.5.0/bin/eslint
-c /Users/xxx/.eslintrc.lint.json --fix $FilePath$
$ProjectFileDir$
/Users/xxx/.rbenv/shims/rubocop
--config /Users/xxx/.rubocop.lint.yml -a $FilePath$
$ProjectFileDir$
/Users/xxx/.nvm/versions/node/v5.5.0/bin/tslint
-c /Users/xxx/tslint.lint.json --fix $FilePath$
$ProjectFileDir$
There's a way to disable/change special ESlint rules in certain files. For the issues that you told me about, with line length and params count, add this at the beginning of a file:
/* eslint max-len: ["error", 120] */
/* eslint max-params: ["error", 6], */
It will change the rules just for this file.
Using File Watchers
plugin.
Similar to manual running formatting scripts described above, we need to specify the correct path to the executable.
~/.nvm/versions/node/v5.5.0/bin/eslint
--fix $FilePath$ -c ~/.eslintrc.lint.json
~/.nvm/versions/node/v5.5.0/bin/eslint
--fix $FilePath$ -c /Users/xxx/.eslintrc.lint.json
~/.rbenv/shims/rubocop
-a $FilePath$ --config ~/.rubocop.lint.yml
git config pre-commit.checks "[whitespace, jshint, debugger, rubocop]"
fork https://github.com/jish/pre-commit
and add tslint and htmlhint plugins there
or customize this:
https://gist.github.com/skanev/9d4bec97d5a6825eaaf6
rubocop -a file_name.rb
http://lloiser.github.io/esformatter-visualize/
eslint -c config --fix js/*
or
node_modules/.bin/jsfmt ./js/*.js -w
or
npm run format
or
jsfmt -w ./js/*.js
eslint -c config --fix js/*
or
node_modules/.bin/tsfmt ./js/*.ts -r
or
npm run format
./node_modules/.bin/js-beautify html/*.html -r
beautified html/example.html
node_modules/.bin/htmlhint --config htmlhint.conf
Jshint for code quality, eslint for code style
./node_modules/.bin/eslint -c <path-to-config> --fix <path-to-current-file>
./node_modules/.bin/eslint --fix js/*