-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add eslint for javascript code consistency #111
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
86164d1
Add eslint
gauravtiwari fa3a6a4
Ignore node_modules
gauravtiwari 77b6ea0
Lint javascript code to make it consistent
gauravtiwari 111876b
Rename file extension in installer
gauravtiwari a372ba1
Move eslint rules to config file
gauravtiwari d2c07fb
Revert changing extension
gauravtiwari 2ad9d13
Fix typo
gauravtiwari d4d8927
Use short hand and arrow function
gauravtiwari d05106d
Remove duplicate plugins and use env to target browser
gauravtiwari 9c1d98e
Add rules to disable semicolon and trailing comma
gauravtiwari 8f38dfb
Use single quote for strings
gauravtiwari de2af01
Sync with master and merge conflict
gauravtiwari 21f5e26
Lint vue example
gauravtiwari 6bc4304
Fix typo
gauravtiwari aee16bb
Remove inline argument
gauravtiwari b373ea7
Use standard no-console rule
gauravtiwari 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 hidden or 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,14 @@ | ||
| module.exports = { | ||
| 'extends': 'airbnb', | ||
| 'rules': { | ||
| 'comma-dangle': ['error', 'never'], | ||
| 'import/no-unresolved': 'off', | ||
| 'import/no-extraneous-dependencies': 'off', | ||
| 'import/extensions': 'off', | ||
| semi: ['error', 'never'], | ||
| }, | ||
| 'env': { | ||
| 'browser': true, | ||
| 'node': true, | ||
| }, | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /.bundle | ||
| node_modules |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ | |
| // | ||
| // <%= javascript_pack_tag 'hello_angular' %> | ||
|
|
||
| require("hello_angular") | ||
| require('./hello_angular') | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,25 @@ | ||
| // Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file, | ||
| // like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom | ||
| // of the page. | ||
|
|
||
| import React from 'react' | ||
| import ReactDOM from 'react-dom' | ||
|
|
||
| const Hello = props => ( | ||
| <div>Hello {props.name}!</div> | ||
| ) | ||
|
|
||
| Hello.defaultProps = { | ||
| name: 'David' | ||
| } | ||
|
|
||
| Hello.propTypes = { | ||
| name: React.PropTypes.string | ||
| } | ||
|
|
||
| document.addEventListener('DOMContentLoaded', () => { | ||
| ReactDOM.render( | ||
| <Hello name="React" />, | ||
| document.body.appendChild(document.createElement('div')), | ||
| ) | ||
| }) | ||
This file contains hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| { | ||
| "name": "webpacker", | ||
| "version": "1.0.0", | ||
| "description": "Webpacker makes it easy to use the JavaScript preprocessor and bundler [Webpack](https://webpack.github.io) to manage application-like JavaScript in Rails. It coexists with the asset pipeline, as the purpose is only to use Webpack for app-like JavaScript, not images, css, or even JavaScript Sprinkles (that all continues to live in app/assets).", | ||
| "main": "index.js", | ||
| "dependencies": {}, | ||
| "devDependencies": { | ||
| "eslint": "^3.16.1", | ||
| "eslint-config-airbnb": "^14.1.0", | ||
| "eslint-plugin-import": "^2.2.0", | ||
| "eslint-plugin-jsx-a11y": "^4.0.0", | ||
| "eslint-plugin-react": "^6.10.0" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "lint": "node_modules/eslint/bin/eslint.js lib/" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/rails/webpacker.git" | ||
| }, | ||
| "author": "David Heinemeier Hansson <[email protected]>", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/rails/webpacker/issues" | ||
| }, | ||
| "homepage": "https://github.com/rails/webpacker#readme" | ||
| } |
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 this isn't a class anymore?
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.
Functional components have a lot of cachet right now. I think it's a little too fancy for a bare-bones example but we can always fix it 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.
@guilleiguaran Because we can do away with functional component. Perhaps, we can make a class example too, but I guess the intention of this gem to not teach react but rather setup an environment that works with 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.
@guilleiguaran the linter will complain if you use a class when a simple function will suffice.