sort-imports not behaving as expected
See original GitHub issueTell us about your environment
- ESLint Version: 6.8.0
- Node Version: 13.12.0
- npm Version: 6.14.4
What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser
Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"node": true
},
"extends": [
"@aminnairi",
"plugin:@typescript-eslint/eslint-recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-new": "off",
"no-unused-vars": "off",
"no-ternary": "off"
}
}
Extract from aminnairi/eslint-config
"sort-imports": ["error", { "ignoreCase": false, "ignoreDeclarationSort": false, "ignoreMemberSort": false, "memberSyntaxSortOrder": ["none", "all", "single", "multiple"] }],
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 Breadcrumbs from "@material-ui/core/Breadcrumbs";
import Button from "@material-ui/core/Button";
import Container from "@material-ui/core/Container";
import FormControl from "@material-ui/core/FormControl";
import GitHubIcon from "@material-ui/icons/GitHub";
import Grid from "@material-ui/core/Grid";
import InputLabel from "@material-ui/core/InputLabel";
import {Link} from "react-router-dom";
import MenuItem from "@material-ui/core/MenuItem";
import Select from "@material-ui/core/Select";
import SnackbarContent from "@material-ui/core/SnackbarContent";
import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
import {makeStyles} from "@material-ui/core/styles";
import React, {ChangeEvent, MouseEvent, SyntheticEvent, useState} from "react";
import Snackbar, {SnackbarOrigin} from "@material-ui/core/Snackbar";
$ eslint --fix
What did you expect to happen?
The named import for Link
should be sorted with the named imports, not with the default imports.
What actually happened? Please include the actual, raw output from ESLint.
The named import for Link
is not sorted with its named imports brothers.
Are you willing to submit a pull request to fix this bug?
No for the moment since I’ve never dived into the source-code of ESLint yet.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
goimports does not sort imports as expected - Stack Overflow
I have created dummy file (which is called file1.go ) with chaotic imports statements: package somepackage import ( "context" ...
Read more >Settings Reference for Python - Visual Studio Code
Python settings reference. The Python Extension for Visual Studio Code is highly configurable. This page describes the key settings you can work with....
Read more >Announcing TypeScript 4.9 RC - Microsoft Developer Blogs
Today we're excited to announce our Release Candidate (RC) of TypeScript 4.9. Between now and the stable release of TypeScript 4.9, we expect...
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 >Add ESLint Rules to Sort Imports And Audit Accessibility
If you are using Visual Studio Code and have ESLint extension installed, in the code editor, the linting errors for imports that are...
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
Thanks for your answer @anikethsaha.
I see, do you know what set of rules I should use in order to get the intended behaviour, meaning having my
import {Link}
sorted with named imports first?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.