Skip to content

gonimbly/javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Nimbly Javascript Styleguide

ESLint Configs

ESLint shareable configs for Go Nimbly

Exported configs both support ES2017 and formatting with Prettier.

Extend these configs in your ESLint configurations to use. If you have a monorepo, only exend the @gonimbly/eslint-config-base in your root and then extend @gonimbly (ie: @gonimbly/eslint-config) inside inidividual packages that use React and Babel.

Note that the ESLint configurations' "extends" field allows you to ommit the eslint-config- prefix (unless it is both a scoped package, like @gonimbly, and there is text after the @scoped/estlint-config- part).

Heroku and private packages

To deploy to Heroku, you'll need to add the following engines parameter to your package.json

{
  "engines": {
    "node": ">=7.10.1",
    "yarn": "0.27.5 || >=1.0.2"
  }
}

Run eslint/prettier pre-commit

Set up your project to automatically run eslint --fix on changed *.js files and/or prettier on *.{json|css|scss} files before commits are made. Changes made by eslint will be re-staged, and if there are no errors, will allow the commit. If any eslint errors are found, the commit will be aborted so that they can be fixed manually.

  1. yarn add -D lint-staged husky prettier
  2. Update your project's root package.json, like this:
{
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "*.js": ["eslint --fix", "git add"],
    "*.{json,css,scss}": ["prettier --write", "git add"]
  },
}
  1. Now change a few files, git add some of them and try to git commit.

via okonet/lint-staged

ESLint and Prettier in your IDE

VSCode

You can easily enable automatic code formatting by installing the ESLint and Prettier extensions via VSCode's extension manager.

After installation you'll want to enable the following setting to allow prettier to respect the eslint settings:

"prettier.eslintIntegration": true

Development

  1. Clone this repo, cd to it, then run yarn
  2. Create branch off master
  3. ...commit stuff...
  4. Push branch and open PR

Publishing a release to NPM

  1. Merge approved PR(s) to master using "squash" option
  2. Checkout master
  3. Run npm login (only need to do this once per machine)
  4. Check your ~/.npmrc and make sure it isn't overriding the default registry. Comment the line out if it does.
  5. Run lerna publish and increment version according to semver