-
Notifications
You must be signed in to change notification settings - Fork 4
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
initial configuration #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
env: { | ||
es6: true, | ||
node: true, | ||
browser: true | ||
}, | ||
parser: "babel-eslint", | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true | ||
}, | ||
sourceType: "module" | ||
}, | ||
plugins: ["react", "import", "jsx-a11y", "react-native"], | ||
extends: ["wolox"], | ||
globals: { | ||
__DEV__: true | ||
}, | ||
rules: { | ||
// Import | ||
"import/default": "error", | ||
"import/export": "error", | ||
"import/exports-last": "error", | ||
"import/extensions": [ | ||
"error", | ||
"never", | ||
{ js: "never", svg: "always", scss: "always", png: "always", css: "always" } | ||
], | ||
"import/first": "error", | ||
"import/named": "error", | ||
"import/namespace": "error", | ||
"import/newline-after-import": "error", | ||
"import/no-absolute-path": "error", | ||
"import/no-extraneous-dependencies": "error", | ||
"import/no-mutable-exports": "error", | ||
"import/no-named-as-default-member": "error", | ||
"import/no-named-default": "error", | ||
"import/no-self-import": "error", | ||
"import/no-unresolved": "error", | ||
"import/no-useless-path-segments": "error", | ||
"import/no-webpack-loader-syntax": "error", | ||
"import/order": ["error", { "newlines-between": "always" }], | ||
"import/prefer-default-export": "off", | ||
|
||
// jsx-a11y | ||
"jsx-a11y/anchor-is-valid": "error", | ||
|
||
// React | ||
"react/boolean-prop-naming": "error", | ||
"react/button-has-type": "error", | ||
"react/default-props-match-prop-types": "error", | ||
"react/forbid-dom-props": ["error", { forbid: ["style", "id"] }], | ||
"react/forbid-prop-types": "error", | ||
"react/jsx-boolean-value": ["error", "never"], | ||
"react/jsx-child-element-spacing": "error", | ||
"react/jsx-closing-bracket-location": "error", | ||
"react/jsx-closing-tag-location": "error", | ||
"react/jsx-curly-brace-presence": [ | ||
"error", | ||
{ props: "never", children: "never" } | ||
], | ||
"react/jsx-curly-spacing": "error", | ||
"react/jsx-equals-spacing": "error", | ||
"react/jsx-filename-extension": ["error", { extensions: [".js"] }], | ||
"react/jsx-first-prop-new-line": "error", | ||
"react/jsx-handler-names": "error", | ||
"react/jsx-indent": ["error", 2], | ||
"react/jsx-key": "error", | ||
"react/jsx-max-depth": ["error", { max: 4 }], | ||
"react/jsx-no-bind": "error", | ||
"react/jsx-no-comment-textnodes": "error", | ||
"react/jsx-no-duplicate-props": "error", | ||
"react/jsx-no-target-blank": "error", | ||
"react/jsx-one-expression-per-line": "error", | ||
"react/jsx-pascal-case": "error", | ||
"react/jsx-props-no-multi-spaces": "error", | ||
"react/jsx-sort-default-props": "error", | ||
"react/jsx-tag-spacing": ["error", { beforeClosing: "never" }], | ||
"react/jsx-uses-vars": "error", | ||
"react/jsx-wrap-multilines": [ | ||
"error", | ||
{ | ||
declaration: "parens-new-line", | ||
assignment: "parens-new-line", | ||
return: "parens-new-line", | ||
arrow: "parens-new-line", | ||
condition: "parens-new-line", | ||
logical: "parens-new-line", | ||
prop: "parens-new-line" | ||
} | ||
], | ||
"react/forbid-foreign-prop-types": "error", | ||
"react/no-access-state-in-setstate": "error", | ||
"react/no-array-index-key": "error", | ||
"react/no-children-prop": "error", | ||
"react/no-danger": "error", | ||
"react/no-deprecated": "error", | ||
"react/no-did-mount-set-state": "error", | ||
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. We should allow 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. Agree! 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. I don't see why a setState may be done in @mvbattan Could you share the link to this docs? Even so, if there is in fact a use case where you'd want to do it it should have to be an exception rather than a rule. I prefer having to disable the linter for that special case. 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. There you go:
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. Oh, I see what you're saying now. Sure, Unless you think there might be usual cases where this has to be done. |
||
"react/no-did-update-set-state": "error", | ||
"react/no-direct-mutation-state": "error", | ||
"react/no-find-dom-node": "error", | ||
"react/no-is-mounted": "error", | ||
"react/no-multi-comp": "error", | ||
"react/no-render-return-value": "error", | ||
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. Does this conflicts with React's Portals ? 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. Here's the argument for this rule https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md Regarding ReactDOM.createPortal, I don't think this rule applies to that. Here's the react docs that support it: https://reactjs.org/docs/react-dom.html#render
tl;dr: apparently the behaviour of using the result of ReactDOM.render() may be deprecated. |
||
"react/no-typos": "error", | ||
"react/no-string-refs": "error", | ||
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. IMHO if possible, we should update this one to only support this: 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. I've checked literally all react's eslint plugin and there's not rule for that apparently. |
||
"react/no-this-in-sfc": "error", | ||
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. Is there a way to prevent this accessing at other places, like 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. There's an eslint rule to avoid using This is the rule: https://eslint.org/docs/rules/no-invalid-this 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. I think that these cases aren't very common 🤔 In this case, I'd disable the linter rule. In my experience, dealing with 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. Sorry, I'm confused about which rule we're talking about. Do you like or dislike this rule (react/no-this-in-sfc)? I can't find any harm on having it, you just shouldn't use On the other hand, I think we can discuss having the But again, I'm still not sure if avoiding possible bugs given that it's not very common having to use 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. I like this rule. I don't see the reason for not implementing it and doing the opposite, using 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. @damfinkel I like this rule but was wondering if this can be extensible to other use cases 😇 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.
|
||
"react/no-unescaped-entities": "error", | ||
"react/no-unknown-property": "error", | ||
"react/no-unsafe": "error", | ||
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. I'd delete this one, since 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. I don't know how common that use case is. If it's not that common, I'd prefer keeping the rule and disabling it in that specific case, so in the rest of the app we avoid use of UNSAFE methods. |
||
"react/no-unused-prop-types": "error", | ||
"react/no-unused-state": "error", | ||
"react/no-will-update-set-state": "error", | ||
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. Also, I'd add 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. totally agree! 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. I'll add it, but I haven't actually checked 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. Great |
||
"react/prefer-es6-class": "error", | ||
"react/prefer-stateless-function": "error", | ||
"react/prop-types": [2, { ignore: ["style", "children", "dispatch"] }], | ||
"react/require-default-props": "off", | ||
"react/react-in-jsx-scope": "error", | ||
"react/require-render-return": "error", | ||
"react/self-closing-comp": "error", | ||
"react/sort-prop-types": [ | ||
"error", | ||
{ | ||
ignoreCase: true, | ||
callbacksLast: true, | ||
requiredFirst: true, | ||
sortShapeProp: true | ||
} | ||
], | ||
"react/style-prop-object": "error", | ||
"react/void-dom-elements-no-children": "error" | ||
|
||
// React Native | ||
"no-colors-literals": "error", | ||
"no-inline-styles": "error" | ||
}, | ||
settings: { | ||
"import/resolver": { | ||
node: { | ||
extensions: [".js", ".android.js", ".ios.js"] | ||
} | ||
} | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@wolox/eslint-config-react", | ||
"version": "1.0.0", | ||
"description": "Wolox's ESLint configuration for React projects ", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Wolox/eslint-config-wolox-react.git" | ||
}, | ||
"keywords": [ | ||
"ESLint", | ||
"React", | ||
"Wolox" | ||
], | ||
"author": "Damián Finkelstein <dfinkelstein@wolox.com.ar>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Wolox/eslint-config-wolox-react/issues" | ||
}, | ||
"homepage": "https://github.com/Wolox/eslint-config-wolox-react#readme", | ||
"peerDependencies": { | ||
"eslint": "^5.6.0", | ||
"eslint-config-wolox": "2.0.0", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.1", | ||
"eslint-plugin-react": "^7.11.1", | ||
"eslint-plugin-react-native": "^3.3.0" | ||
} | ||
} |
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.
Or
.jsx
is being contemplated here ?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.
I think it enforces not to use
.jsx
just.js
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.
I see this rule fine
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.
Yeah, the idea was to avoid
.jsx
. Do you think we should allow.jsx
?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.
Avoid
.jsx
please 😇