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

How can I set order for import './index.styl' #35

Open
lupenq opened this issue Dec 4, 2020 · 4 comments
Open

How can I set order for import './index.styl' #35

lupenq opened this issue Dec 4, 2020 · 4 comments

Comments

@lupenq
Copy link

lupenq commented Dec 4, 2020

I know that the documentation has a clause about such imports, but can there still be some way?
I just want the style imports to always be at the bottom of everyone else

ex. imports:

import React, { useState } from 'react'
import { Image } from 'react-native'
import { observer, useDidUpdate } from 'startupjs'
import PropTypes from 'prop-types'
import randomcolor from 'randomcolor'
import Div from './../Div'
import Span from '../typography/Span'
import './index.styl'

my config:

    "import-helpers/order-imports": [
            "warn",
              { 
                "newlinesBetween": "ignore",
                "groups": [
                    "/^react$/",
                    "/react-native/",
                    "/^react.*/",
                    "/^startupjs/", 
                    "/^@?startupjs.*/",
                    "/^@?dmapper.*/",
                    "module",
                    "/components/",
                    ["/helpers/", "/hooks/"],
                    ["sibling", "parent"],
                    "/.\/index.styl/"
                ]
              }
        ]
@lupenq
Copy link
Author

lupenq commented Dec 21, 2020

@Tibfib

@willhoney7
Copy link
Owner

Hi @lupenq,

There is currently no way to do this. The library specifically ignores bare imports. Support could be added, but it would need to be an option, preferably a per-group option. I'm open to PRs to add the functionality.

Thanks!

@PezCoder
Copy link

PezCoder commented Jan 5, 2021

Hey @Tibfib, Great plugin first of all. After a ton of research & playing with a lot of eslint plugins for sorting imports, this comes really close to what I was looking for. I'm trying to migrate away from the sort-imports by visual studio.

I'm having a similar use case where it's quite common for these style imports to be at the bottom of all the imports as a separate group like @lupenq mentioned in this issue. (Also related #24)

I don't mind raising a PR for this, Can you help guide me in the right direction on the expectation & how can I get started with this project?

I've never worked on an eslint plugin before but I'm well aware of the JS ecosystem & have played with the usages of this particular plugin with different regex.

@hyoretsu
Copy link

This would be pretty neat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants