eslint-plugin-import
eslint-plugin-import copied to clipboard
Is it possible to sort imports based on variable names within group?
"Sort the order within each group in alphabetical manner based on import path"
That's the current way... what If I wanted something like this..
import React from 'react';
import CompA from './zecomp.js
import CompB from './abigcomp.com
but sorting based on path gives me
import React from 'react';
import CompB from './abigcomp.com
import CompA from './zecomp.js
It seems doable to allow a config option alphebeticalBy that defaults to "specifier" but can be set to "binding".
However, this only really makes sense with a default import, or a namespace import - what about import { z, a } from 'path'?
sort to {a, z} then use first word, a?
Would the rule sort the named imports, as well? That almost feels like a bit of an overreach of this rule.
yes, but if i had a rule expecting it to autofix (sort) my import based on var names, i'd want it to take the liberty of making opinionated choices as long as it doesn't modify function of my code.
how many imports are there?
const a = require(..)
import * from '...';
import abc from 'abc';
import * as abc from 'abc';
import {props} from 'abc';
- could be at the most top.
if there is
asthen that name if {..} then first prop name, after sorting...
very opinionated for sure. But complexity is inherent.