sort-imports, ignoreDeclarationSort breaks memberSyntaxSortOrder.
See original GitHub issueTell us about your environment
- ESLint Version: ^6.0.1
- Node Version: v10.11.0
- npm Version: 6.4.1 / yarn 1.12.3
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint
Please show your full configuration:
Configuration
module.exports = {
parser: 'babel-eslint',
env: {
browser: true,
es6: true,
node: true,
},
extends: ['eslint:recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['react'],
settings: {
react: {
version: 'detect',
},
linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }],
},
rules: {
// https://eslint.org/docs/rules/quotes
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
// https://eslint.org/docs/rules/semi
semi: ['error', 'always'],
// https://eslint.org/docs/rules/curly
curly: 'error',
// https://eslint.org/docs/rules/default-case
'default-case': 'error',
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: 'error',
// https://eslint.org/docs/rules/no-else-return
'no-else-return': 'error',
// https://eslint.org/docs/rules/no-multi-spaces
'no-multi-spaces': 'error',
// https://eslint.org/docs/rules/no-new-wrappers
'no-new-wrappers': 'error',
// https://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 'error',
// https://eslint.org/docs/rules/radix
radix: 'error',
// https://eslint.org/docs/rules/require-await
'require-await': 'error',
// https://eslint.org/docs/rules/yoda
yoda: 'error',
// https://eslint.org/docs/rules/no-use-before-define
'no-use-before-define': 'error',
// https://eslint.org/docs/rules/array-bracket-spacing
'array-bracket-spacing': ['error', 'never'],
// https://eslint.org/docs/rules/block-spacing
'block-spacing': 'error',
// https://eslint.org/docs/rules/brace-style
'brace-style': 'error',
// https://eslint.org/docs/rules/camelcase
camelcase: ['error', { ignoreDestructuring: true }],
// https://eslint.org/docs/rules/comma-spacing
'comma-spacing': ['error', { before: false, after: true }],
// https://eslint.org/docs/rules/computed-property-spacing
'computed-property-spacing': ['error', 'never'],
// https://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': ['error', 'never'],
// https://eslint.org/docs/rules/func-style
'func-style': ['error', 'expression'],
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': ['error', 'prefer-double'],
// https://eslint.org/docs/rules/key-spacing
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
// https://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': 'error',
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': 'error',
// https://eslint.org/docs/rules/no-multiple-empty-lines
'no-multiple-empty-lines': 'error',
// https://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': 'error',
// https://eslint.org/docs/rules/prefer-object-spread
'prefer-object-spread': 'error',
// https://eslint.org/docs/rules/semi-style
'semi-style': ['error', 'last'],
// https://eslint.org/docs/rules/sort-keys
// "sort-keys": "error",
// https://eslint.org/docs/rules/sort-vars
// "sort-vars": "error",
// https://eslint.org/docs/rules/template-tag-spacing
'template-tag-spacing': 'error',
// https://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 'error',
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// https://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': 'error',
// https://eslint.org/docs/rules/no-var
'no-var': 'error',
// https://eslint.org/docs/rules/object-shorthand
'object-shorthand': ['error', 'properties'],
// https://eslint.org/docs/rules/prefer-arrow-callback
'prefer-arrow-callback': 'error',
// https://eslint.org/docs/rules/prefer-const
'prefer-const': 'error',
// https://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 'error',
// https://eslint.org/docs/rules/prefer-spread
'prefer-spread': 'error',
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
// https://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': 'error',
// https://eslint.org/docs/rules/sort-imports
'sort-imports': [
'error',
{ ignoreDeclarationSort: true, memberSyntaxSortOrder: ['all', 'single', 'multiple', 'none'] },
],
// https://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md
'react/boolean-prop-naming': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
'react/button-has-type': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md
'react/default-props-match-prop-types': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': ['error', 'always'],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
'react/no-array-index-key': 'off',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
'react/no-children-prop': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
'react/no-deprecated': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
'react/no-did-mount-set-state': ['error', 'disallow-in-func'],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
'react/no-did-update-set-state': ['error', 'disallow-in-func'],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
'react/no-direct-mutation-state': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
'react/no-find-dom-node': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
'react/no-is-mounted': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
'react/no-multi-comp': ['error', { ignoreStateless: true }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md
'react/no-redundant-should-component-update': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-typos.md
'react/no-typos': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
'react/no-string-refs': 'error',
//https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md
'react/no-this-in-sfc': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
'react/no-unescaped-entities': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
'react/no-unknown-property': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md
'react/no-unsafe': ['error', { checkAliases: true }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
'react/no-unused-prop-types': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md
'react/no-unused-state': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
'react/no-will-update-set-state': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
'react/prefer-es6-class': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
'react/prefer-stateless-function': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
'react/react-in-jsx-scope': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md
'react/require-default-props': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
'react/require-optimization': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
'react/require-render-return': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
'react/sort-comp': [
'error',
{
order: ['static-methods', 'instance-variables', 'lifecycle', 'everything-else', 'render'],
},
],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
'react/sort-prop-types': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
'react/static-property-placement': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
'react/style-prop-object': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
'react/void-dom-elements-no-children': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
'react/jsx-boolean-value': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md
'react/jsx-child-element-spacing': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
'react/jsx-key': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
'react/jsx-no-comment-textnodes': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
'react/jsx-no-duplicate-props': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
'react/jsx-no-target-blank': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
'react/jsx-no-undef': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'ignore' }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
'react/jsx-pascal-case': ['error', { ignore: ['SVG'] }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md
'react/jsx-props-no-multi-spaces': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-default-props.md
'react/jsx-sort-default-props': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
'react/jsx-sort-props': ['error', { callbacksLast: true, shorthandFirst: true, noSortAlphabetically: true }],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': 'error',
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 'error',
},
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import React, { Component } from 'react';
import styled, { cx } from 'react-emotion';
import { theme } from 'styled-system';
import Foo from 'foo';
import { baz, bar } from 'bar';
import PropTypes from 'prop-types';
eslint ./*.js src
What did you expect to happen? Get some errors
What actually happened? Please include the actual, raw output from ESLint. Nothing
Are you willing to submit a pull request to fix this bug? Have no time
If I remove ignoreDeclarationSort
it works. But I want to force import order and only force alphabetical order on multiple imports.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Expected 'multiple' syntax before 'single' syntax - Stack Overflow
This is configured in your settings where it says 'memberSyntaxSortOrder': ['none', 'all', 'multiple', 'single'] because 'multiple' is ...
Read more >sort-imports - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >[Solved]-ESLint import sort grouping-node.js
That's exactly what ignoreDeclarationSort does: if it's true then ESLint will ignore import lines. And if ignoreMemberSort is false it will check ordering ......
Read more >ESLint Compatibility - daidodo/format-imports GitHub Wiki
Introduction · sort-imports. ignoreDeclarationSort and ignoreMemberSort; allowSeparatedGroups and memberSyntaxSortOrder. memberSyntaxSortOrder ...
Read more >How to Structure Your React Projects - Joy of Code
You're going to realize what to break into components when you see things repeating. It's going to save you a lot of ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Padchi
I think that I understand your example, but just to clarify how you expect this rule to work, there are probably two problems here:
import React, { Component } from 'react'
- this should be'single'
?import { theme } from 'styled-system'
- this should be'multiple'
?ignoreDeclarationSort
option worksWith the sort order from the example (
single
beforemultiple
) andignoreDeclarationSort:true
, would you expect the rule to work like this:Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.