Official GoDaddy JavaScript styleguide. It includes dotfiles for known tools and can be used as a standard in any new project.
There are many useful features:
- Standard. No configuration. – Stop worrying about style and focus on your work.
- Modern – Uses modern linting tools like
eslint
andjscs
. - Auto-fix – Auto-fix is enabled in
jscs
. Many rules will fix themselves!
This styleguide is used by dozens of product teams at GoDaddy. Have a question or comment? Open an issue!
There are two ways to install and use this styleguide depending on your own tooling preference: directly using pre-built binaries.
- Depend on
godaddy-style
npm i godaddy-style --save-dev
- Run the
godaddy-js-style
binaries in yourpackage.json
:
{
"scripts": {
"eslint": "godaddy-js-style-eslint lib/ test/",
"jscs": "godaddy-js-style-jscs lib/ test/",
"lint": "godaddy-js-style-lint lib/ test/"
}
}
n.b. All CLI flags are exposed through fashion-show. Auto-fix will be enabled by the -f
setting.
Due to issues with the babel-eslint parser plugin, ES5 isn't directly supported (yet). However, if you're still using ES5, you can add an --es5
argument when calling the pre-built binaries, and we will switch to using the espree parser, which should allow eslint to work. The downside being that you can't use any ES6 features if you use the --es5
argument; it's all or nothing for the moment.
{
"scripts": {
"eslint": "godaddy-js-style-eslint --es5 lib/ test/",
"jscs": "godaddy-js-style-jscs --es5 lib/ test/",
"lint": "godaddy-js-style-lint --es5 lib/ test/"
}
}
This project includes dotfiles with comments under the dotfiles
directory, but you should use the distributable versions of these files under dist
.
The styleguide uses eslint
for all correctness focused linting. All strictly style related checking (i.e. whitespace) is handled by jscs
. Only the rules exclusive to eslint
have been enabled or disabled accordingly to make sure there is no overlap with jscs
.
The styleguide uses jscs
for all strictly style related checking. Many jscs
rules have auto-fixing enabled.
This section is a place for additional best practices that may be useful but are not strictly enforced by this styleguide. Have something to add here? Great! Submit a PR.
- Add a
.eslintrc
file at the root of your project:
{
"extends": "./node_modules/godaddy-style/dist/.eslintrc",
"rules": {
// Disable the 'max-params' rule
"max-params": 0
}
}
- Add a param to specify the path of your own
.eslintrc
file in yourpackage.json
:
{
"scripts": {
"eslint": "godaddy-js-style-eslint -c .eslintrc lib/ test/",
}
}
Fork this repository and submit a pull request.
Proposed modifications to the style guide should modify the files in /dotfiles
before running npm run build
when submitting a pull request. This repository utilizes the fashion-show module to generate the /dist
files to be checked in.
Great. We'd love to talk about it. Fork this repository and submit a pull-request.
No problem. Reach out to us by opening an issue
- Add more specific style guidance around React.
- Translate dotfile rules into more verbose written documentation.
- Never stop improving.
- Add support for IDE formats (IntelliJ, Webstorm, Atom, Eclipse, Sublime, etc...)