• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

godaddy/javascript: The official GoDaddy JavaScript styleguide.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

godaddy/javascript

开源软件地址:

https://github.com/godaddy/javascript

开源编程语言:

JavaScript 100.0%

开源软件介绍:

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

From there the bootstrap script will setup the packages and hoist the node_modules

Publishing

If you are lucky enough to get to publish a new version of a package you are in luck. This monorepo is setup to independently publish packages based on changes commited. Just make sure to run:

npm run publish

This runs lerna publish under the hood and will run you through a cli driven experience to help you determine the next version. To learn more about it see lerna publish

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

  • Consider other rules in an eslint only implementation:
    • computed-property-spacing
    • generator-star-spacing
    • semi-spacing
    • block-spacing
  • Continue to modularize the eslint rules.
  • Translate configuration files into more verbose written documentation.
  • Add support for IDE formats (IntelliJ, Webstorm, Atom, Eclipse, Sublime, etc...)



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap