Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds react-flow package #47

Merged
merged 3 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Official GoDaddy JavaScript styleguide. It includes `eslint` packages for three

- [`eslint-config-godaddy`]: Base configuration for _non-React_, ES6 JavaScript applications
- [`eslint-config-godaddy-react`]: Configuration for ES6 React JavaScript applications
- [`eslint-config-godaddy-es5`]: Configuration for React _and_ non-React ES5 JavaScript applications.
- [`eslint-config-godaddy-es5`]: Configuration for React _and_ non-React ES5 JavaScript applications
- [`eslint-config-godaddy-react-flow`]: Configuration for ES6 React JavaScript applications using Flow

There are many useful features:

Expand Down Expand Up @@ -138,3 +139,4 @@ No problem. Reach out to us by [opening an issue]
[`eslint-config-godaddy`]: /packages/eslint-config-godaddy
[`eslint-config-godaddy-react`]: /packages/eslint-config-godaddy-react
[`eslint-config-godaddy-es5`]: /packages/eslint-config-godaddy-es5
[`eslint-config-godaddy-react-flow`]: /packages/eslint-config-godaddy-react-flow
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"description": "The approach to JavaScript at GoDaddy. We think it's pretty decent.",
"scripts": {
"lint": "eslint -c .eslintrc.js packages/**/*.js",
"postinstall": "run-p install:config install:config:es5 install:config:react",
"postinstall": "run-p install:config install:config:es5 install:config:react install:config:react-flow",
"install:config": "cd packages/eslint-config-godaddy && npm install",
"install:config:es5": "cd packages/eslint-config-godaddy-es5 && npm install",
"install:config:react": "cd packages/eslint-config-godaddy-react && npm install",
"test": "run-p lint test:config test:config:es5 test:config:react",
"install:config:react-flow": "cd packages/eslint-config-godaddy-react-flow && npm install",
"test": "run-p lint test:config test:config:es5 test:config:react test:config:react-flow",
"test:config": "cd packages/eslint-config-godaddy && npm test",
"test:config:es5": "cd packages/eslint-config-godaddy-es5 && npm test",
"test:config:react": "cd packages/eslint-config-godaddy-react && npm test"
"test:config:react": "cd packages/eslint-config-godaddy-react && npm test",
"test:config:react-flow": "cd packages/eslint-config-godaddy-react-flow && npm test"
},
"repository": {
"type": "git",
Expand All @@ -27,7 +29,8 @@
"es6",
"es2015",
"react",
"jsx"
"jsx",
"flow"
],
"license": "MIT",
"author": "GoDaddy.com Operating Company, LLC",
Expand All @@ -41,7 +44,10 @@
"godaddy-js-style-eslint": "./bin/eslint"
},
"devDependencies": {
"babel-eslint": "^7.2.1",
"eslint": "^3.15.0",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-find-rules": "^1.14.3",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^4.8.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-config-godaddy-react-flow/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./index.js"
}
55 changes: 55 additions & 0 deletions packages/eslint-config-godaddy-react-flow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# eslint-config-godaddy-react-flow

Configuration for ES6 React JavaScript applications using Flow, officially used at GoDaddy. 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!](https://github.com/godaddy/javascript/issues/new)

## Installation

``` sh
# ES6 (including React 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 this package (`eslint-config-godaddy-react-flow`) **with auto-fix enabled automatically.**

``` js
{
"scripts": {
"lint": "eslint-godaddy-react-flow files/ you/ want-to/ lint/"
}
}
```

##### 2. Define your local `.eslintrc` and run `eslint` yourself:

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

The `--fix` option in `eslint` is [**only** available as a CLI option](https://github.com/eslint/eslint/issues/8041). Auto-fix will *NOT be enabled* unless you run `eslint --fix` in your `package.json`.

``` js
{
"scripts": {
"lint": "eslint --fix files/ you/ want-to/ lint/"
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
require('eslint-config-godaddy/cli')(
require('path').join(__dirname, '..', 'index')
);
17 changes: 17 additions & 0 deletions packages/eslint-config-godaddy-react-flow/extends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('path');

/**
* Helper function that attempts to resolve the specify named `config`
* locally before attempting to resolve it from `node_modules`. This
* tricks TravisCI into resolving correctly.
*
* @param {string} config Named `eslint-config-*` module
* @returns {string} Full path resolved locally or from `node_modules`.
*/
module.exports = function resolveLocal(config) {
try {
return require.resolve(path.resolve(__dirname, '..', config));
} catch (ex) {
return require.resolve(config);
}
};
39 changes: 39 additions & 0 deletions packages/eslint-config-godaddy-react-flow/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
extends: [
require('./extends')('eslint-config-godaddy'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't this be eslint-config-godaddy-react?

require('./extends')('eslint-config-godaddy-react'),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I'll make this change.

'plugin:eslint-plugin-react/recommended'
],
plugins: ['react', 'flowtype', 'babel'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
experimentalObjectRestSpread: true
}
},
rules: {
'react/display-name': 0,
'react/jsx-pascal-case': 2,
'react/jsx-uses-react': 1,
'react/prefer-es6-class': 2,
//
// Whitespace rules for specific scenarios (e.g. JSX)
//
'react/jsx-curly-spacing': [2, 'always', {
spacing: { objectLiterals: 'never' }
}],
'jsx-quotes': [2, 'prefer-single'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these rules should be inherited from eslint-config-godaddy-react no? If we add rules to that package I'd like to see them reflected here.

//
// Flow rules
//
'flowtype/define-flow-type': 2,
'flowtype/space-after-type-colon': [2, 'always'],
'flowtype/type-id-match': [2, '^([A-Z][A-Za-z0-9]*)$'],
'flowtype/use-flow-type': 2
},
settings: {
flowtype: {
onlyFilesWithFlowAnnotation: true
}
}
};
52 changes: 52 additions & 0 deletions packages/eslint-config-godaddy-react-flow/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "eslint-config-godaddy-react-flow",
"version": "1.1.0",
"description": "ESLint config for consistent style in ES6 React projects using Flow at GoDaddy.",
"scripts": {
"lint": "eslint .",
"pretest": "npm run --silent lint",
"test": "echo ok",
"unused": "eslint-find-rules --unused ./index.js || echo ''"
},
"repository": {
"type": "git",
"url": "git@github.com:godaddy/javascript.git"
},
"keywords": [
"godaddy",
"javascript",
"styleguide",
"style-guide",
"eslint",
"es6",
"react",
"flow"
],
"bin": {
"eslint-godaddy-react-flow": "bin/eslint-godaddy-react-flow"
},
"dependencies": {
"eslint-config-godaddy": "^1.0.0"
},
"peerDependencies": {
"eslint": "^3.15.0",
"babel-eslint": "^7.2.1",
"eslint-find-rules": "^1.14.3",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^4.8.0",
"eslint-plugin-react": "^6.9.0"
},
"license": "MIT",
"devDependencies": {
"eslint": "^3.15.0",
"babel-eslint": "^7.2.1",
"eslint-find-rules": "^1.14.3",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^4.8.0",
"eslint-plugin-react": "^6.9.0"
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config-godaddy-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ These use _exactly_ the configuration defined in this package (`eslint-config-g
``` js
{
"scripts": {
"lint": eslint-godaddy-react files/ you/ want-to/ lint/"
"lint": "eslint-godaddy-react files/ you/ want-to/ lint/"
}
}
```
Expand Down