-
Notifications
You must be signed in to change notification settings - Fork 47
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
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/" | ||
} | ||
} | ||
``` |
4 changes: 4 additions & 0 deletions
4
packages/eslint-config-godaddy-react-flow/bin/eslint-godaddy-react-flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module.exports = { | ||
extends: [ | ||
require('./extends')('eslint-config-godaddy'), | ||
'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'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these rules should be inherited from |
||
// | ||
// 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 | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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.