stylelint-config-cuemby
v0.0.1
Published
Style linting and rules for the Cuemby Team.
Downloads
3
Maintainers
Readme
stylelint-config-cuemby
This package includes a framework-less way to work with any EcmaScript 6 project in the Cuemby Team, you can add it to your .eslintrc
file as an extendable configuration.
Table of contents
Installation
CLI Installation
Required to have installed Node 8+ and NPM 5+ and ESLint as a global package. Run in the command line:
npm install -g eslint
npm install -D @cuemby/eslint-config-cuemby
Afterwards you can check errors and warnings with:
eslint path/to/file.js
or npm run lint
Text Editors Installation
There're many plugins available that allows you to have live linting while working on a project and can throw errors, warnings and auto-corrections on the go. It requires you to have installed the CLI version. Some are listed here:
- Visual Studio Code ESLint
- Sublime Linter
- Atom eslint-linter
- WebStorm ESLint
- Brackets NPM Registry ESLint
Usage
Project Usage
Add to your .eslintrc
file on the root of the project.
{
"extends": "@cuemby/cuemby"
}
Global Usage
In case you want to follow this ruleset for all of the projects in your machine or don't want to set up a .eslintrc
file for each project, you can create a root machine file, and ESLint will throw errors based on such a file when it doesn't find one in your project.
In any bash or unix based CLI:
npm install -g @cuemby/eslint-config-cuemby
touch ~/.eslinrc
echo '{"extends": "@cuemby/cuemby"}' >> ~/.eslinrc
ESLint Approved Code
Git Hook
Only allow eslint-compliant code into the commits, this ensures only great-quality code to be present in the repository.
- Get inside the
.git
folder for the project - Go to
hooks/
and renamecommit-msg.sample
tocommit-msg
- Inside
commit-msg
, add the following code
#!/bin/bash
files=$(git diff --cached --name-only | grep '\.jsx\?$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
failed=0
for file in ${files}; do
git show :$file | eslint $file
if [[ $? != 0 ]] ; then
failed=1
fi
done;
if [[ $failed != 0 ]] ; then
echo "ESLint failed, improve your code to commit!"
exit $failed
fi
Try to committing a file with ESLint errors, you should receive a message and being unable to commit.
You can also run "npm run eslint-commit" locally or "@cuemby/eslint-config-cuemby eslint-commit" globally to test the Git Hook.
Disable ESLint
If for some given reason, you need to disable ESLint for a code snippet, you can do it this way wrapping the desired code, but allowing to be parsed all across the document:
/* eslint-disable */
var test = function(){}
/* eslint-enable */
In case you need to commit not eslint-compliant code for a strong reason, disable only what you need and add a comment explaining why the ESLint was disabled or that instance is not indicated to have it prevent you from committing your code.
License
(The MIT License)
Copyright © 2015-2018 Cuemby LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The software is provided 'as is', without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.