Skip to content

Latest commit

 

History

History
205 lines (144 loc) · 6.12 KB

README.md

File metadata and controls

205 lines (144 loc) · 6.12 KB

godaddy-style

Official GoDaddy JavaScript styleguide. It includes eslint packages for various use-cases 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.
  • Auto-fix – Auto-fix is enabled by-default through in eslint. Many rules will fix themselves!

This styleguide is used by dozens of product teams at GoDaddy. Have a question or comment? Open an issue!

Installation

Install one of the provided packages depending on the kind of application you are developing:

# Default with ES6
npm i eslint-config-godaddy --save-dev

# OR (ES6 with React rules)
npm i eslint-config-godaddy-react --save-dev

# OR (legacy ES5 with React rules)
npm i eslint-config-godaddy-es5 --save-dev

# OR (ES6 with TypeScript rules)
npm i eslint-config-godaddy-typescript --save-dev

# OR (ES6 with React and TypeScript rules)
npm i eslint-config-godaddy-react-typescript --save-dev

# OR (ES6 with Flow rules)
npm i eslint-config-godaddy-flow --save-dev

# OR (ES6 with React and Flow rules)
npm i eslint-config-godaddy-react-flow --save-dev

Usage

There are two ways to use this styleguide depending on your own tooling preference: directly using pre-included binaries or running eslint yourself with a custom .eslintrc config.

1. Use the pre-included binaries

These use exactly the configuration defined in the individual eslint-config-godaddy* package with auto-fix enabled automatically.

{
  "scripts": {
    "lint": "eslint-godaddy files/ you/ want-to/ lint/"
  }
}

2. Define your local .eslintrc.js and run eslint yourself

module.exports = {
  extends: 'godaddy',
  rules: {
    //
    // Put any rules you wish to override here.
    //
  }
}

The --fix option in eslint is only available as a CLI option. Auto-fix will NOT be enabled unless you run eslint --fix in your package.json.

{
  "scripts": {
    "lint": "eslint --fix files/ you/ want-to/ lint/"
  }
}

Additional Best Practices

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.

React

FAQ

How do I override a specific rule ?

1. Add a .eslintrc file at the root of your project:

{
  "extends": "godaddy",
  "rules": {
    // Disable the 'max-params' rule
    "max-params": 0
  }
}

2. Add a param to specify the path of your own .eslintrc file in your package.json

{
  "scripts": {
    "eslint": "eslint-godaddy -c .eslintrc lib/ test/",
  }
}

How do I disable auto fix

You may wish to disable auto fix so when you run eslint in ci it will error if it catches anything unlinted.

{
  "scripts": {
    "eslint:ci": "eslint-godaddy --fix=false --max-warnings=0 lib/ test/",
  }
}

How do I contribute?

Fork this repository and submit a pull request.

Local setup

For a first time setup make sure to run from the root of the monorepo

npm install

Since this repository uses npm workspaces it will install and hoist all node_modules to the root of the monorepo.

Submit a changeset

This repository utilizes changesets to handle versioning and publishing as you submit a pull-request. A changeset should be included with your pull-request to help the maintainers understand the changes and to help with the release process.

To initiate a changeset run:

npm run changeset

After which follow the command prompts to select which packages and which version each package should receive.

Commit and push the changeset to your branch to be included with your pull-request.

Publishing

When a pull-request is merged into the main, the changeset will be used to determine the next version of the package.

A "Version Packages" pull-request will be automatically created to bump the versions. If multiple PRs with changesets are merged, this PR will automatically update to include all changesets.

When all changes are ready to be published, repo admins can force squash merge the "Version Packages" PR to main (CI worflows do not run on this automated branch). This will trigger the CI to publish the packages to npm.

I disagree with a specific rule

Great. We'd love to talk about it. Fork this repository and submit a pull-request.

Help! It's not working for me

No problem. Reach out to us by opening an issue

Roadmap

  • ESLint v9 support (guide)