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

Add sorting rules #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/react/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const HelloMessage = ({name}) => {
}, [setGreeting]);

return (
<div onClick={onClick}>
<div data-attribute="yes" onClick={onClick}>
{greeting} {name}
</div>
);
Expand Down
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
extends: ['prettier'],
plugins: ['import', 'prettier', 'sort-imports-es6-autofix'],
env: {
node: true,
browser: true,
es6: true,
node: true,
},
extends: ['prettier'],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['import', 'prettier', 'sort-imports-es6-autofix'],
rules: {
'array-callback-return': 'error',
'block-scoped-var': 'error',
Expand Down Expand Up @@ -63,13 +63,12 @@ module.exports = {
'prettier/prettier': [
'error',
{
singleQuote: true,
arrowParens: 'avoid',
bracketSpacing: false,
singleQuote: true,
trailingComma: 'es5',
arrowParens: 'avoid',
},
],
strict: 'off',
'sort-imports-es6-autofix/sort-imports-es6': [
'error',
{
Expand All @@ -78,6 +77,8 @@ module.exports = {
memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'],
},
],
'sort-keys': ['error', 'asc', {caseSensitive: false, natural: true}],
strict: 'off',
'use-isnan': 'error',
'valid-typeof': 'error',
},
Expand Down
22 changes: 12 additions & 10 deletions react.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
module.exports = {
extends: ['./index.js', 'prettier/react'],
plugins: ['react', 'react-hooks'],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: 'detect',
},
},
plugins: ['react', 'react-hooks'],
rules: {
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-key': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-sort-props': 'off',
'react/jsx-sort-default-props': 'error',
'react/jsx-sort-props': 'error',
Copy link
Member

Choose a reason for hiding this comment

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

See also db7a16d. Only pointing out that there are different opinions on this one. I don't have any strongly held opinions on these things as long as they are auto-fixable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just think the more rules we have the less the codebases can differ and the easier it is to switch between them going forward in Brian's and Quinn's idea to have teams less siloed in distinct projects 🤷

Copy link

Choose a reason for hiding this comment

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

I also understand there are different opinions on this one, at first I kind of disliked the sorting (as overkill), but now that I have gotten used to it it helps to find stuff more easily and read code better

'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/no-array-index-key': 'error',
Expand All @@ -32,6 +26,14 @@ module.exports = {
'react/no-will-update-set-state': 'error',
'react/prop-types': 'error',
'react/react-in-jsx-scope': 'error',
'react/sort-prop-types': 'off',
'react/sort-comp': 'error',
'react/sort-prop-types': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
},
settings: {
react: {
version: 'detect',
},
},
};