From 125df475f781f72eba71623a6d0ab8edde6ff327 Mon Sep 17 00:00:00 2001 From: Jannis Hell Date: Tue, 10 Nov 2020 13:13:03 +0100 Subject: [PATCH 1/3] add sorting rules --- examples/react/component.js | 2 +- index.js | 11 ++++++----- react.js | 22 ++++++++++++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/examples/react/component.js b/examples/react/component.js index ebdc59e..024d3b8 100644 --- a/examples/react/component.js +++ b/examples/react/component.js @@ -10,7 +10,7 @@ const HelloMessage = ({name}) => { }, [setGreeting]); return ( -
+
{greeting} {name}
); diff --git a/index.js b/index.js index fd363c2..faa48fb 100644 --- a/index.js +++ b/index.js @@ -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', @@ -63,12 +63,13 @@ module.exports = { 'prettier/prettier': [ 'error', { - singleQuote: true, + arrowParens: 'avoid', bracketSpacing: false, + singleQuote: true, trailingComma: 'es5', - arrowParens: 'avoid', }, ], + 'sort-keys': ['error', 'asc', {caseSensitive: false, natural: true}], strict: 'off', 'sort-imports-es6-autofix/sort-imports-es6': [ 'error', diff --git a/react.js b/react.js index 52e0743..41db84c 100644 --- a/react.js +++ b/react.js @@ -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', 'react/jsx-uses-react': 'error', 'react/jsx-uses-vars': 'error', 'react/no-array-index-key': 'error', @@ -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', + }, }, }; From 5e26c96fa598a98498b1e6280267774484fc7133 Mon Sep 17 00:00:00 2001 From: Jannis Hell Date: Wed, 11 Nov 2020 14:41:17 +0100 Subject: [PATCH 2/3] rebase --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index faa48fb..3dbcdbe 100644 --- a/index.js +++ b/index.js @@ -69,8 +69,6 @@ module.exports = { trailingComma: 'es5', }, ], - 'sort-keys': ['error', 'asc', {caseSensitive: false, natural: true}], - strict: 'off', 'sort-imports-es6-autofix/sort-imports-es6': [ 'error', { @@ -79,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', }, From ce4a7b8f2e3a38fdac71788941e37519d2bb8292 Mon Sep 17 00:00:00 2001 From: Jannis Hell Date: Tue, 17 Nov 2020 15:40:32 +0100 Subject: [PATCH 3/3] no need for sorting twice --- react.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/react.js b/react.js index 41db84c..5f3f06a 100644 --- a/react.js +++ b/react.js @@ -11,8 +11,8 @@ module.exports = { 'react/jsx-key': 'error', 'react/jsx-no-duplicate-props': 'error', 'react/jsx-no-undef': 'error', - 'react/jsx-sort-default-props': 'error', - 'react/jsx-sort-props': 'error', + 'react/jsx-sort-default-props': ['error', {ignoreCase: true}], + 'react/jsx-sort-props': ['error', {ignoreCase: true}], 'react/jsx-uses-react': 'error', 'react/jsx-uses-vars': 'error', 'react/no-array-index-key': 'error', @@ -27,7 +27,7 @@ module.exports = { 'react/prop-types': 'error', 'react/react-in-jsx-scope': 'error', 'react/sort-comp': 'error', - 'react/sort-prop-types': 'error', + 'react/sort-prop-types': ['error', {ignoreCase: true}], 'react-hooks/exhaustive-deps': 'warn', 'react-hooks/rules-of-hooks': 'error', },