Skip to content

Conversation

swernerx
Copy link
Contributor

@swernerx swernerx commented Jun 6, 2019

We figured out that the auto-fix feature of the "order" rule destroyed our custom imports which are using a custom babel-module resolver. Settings for the resolver:

'import/resolver': {
  'babel-module': {
    extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
    alias: {
      '-': './src/',
    },
  },
},

Until now, unknown import types were sorted problematically by the "order" feature. These were not assigned to a common group but loosely added or kept between the other imports. This was especially problematic when using the 'newlines-between'-feature. In this case there was an additional line feed after each unknown import. See examples below.

Example:

import { get } from 'lodash'
import { FormError } from '-/components/Product/Configuration/FormError'
import React, { PureComponent } from 'react'
import { ModalContainer } from '../../../Modal/ModalContainer'
import { addEvent, removeEvent } from '-/common/tracking/basket'
import { ChangeItem } from '-/components/Basket/ChangeItem'
import getBasketProduct from './BasketProduct.gql'
import UpdateItemInBasket from './UpdateItemInBasket.gql'

Previous version output:

import { get } from 'lodash'

import { FormError } from '-/components/Product/Configuration/FormError'

import React, { PureComponent } from 'react'

import { ModalContainer } from '../../../Modal/ModalContainer'

import { addEvent, removeEvent } from '-/common/tracking/basket'

import { ChangeItem } from '-/components/Basket/ChangeItem'

import getBasketProduct from './BasketProduct.gql'
import UpdateItemInBasket from './UpdateItemInBasket.gql'

New version output:

import { get } from 'lodash'
import React, { PureComponent } from 'react'

import { FormError } from '-/components/Product/Configuration/FormError'
import { addEvent, removeEvent } from '-/common/tracking/basket'
import { ChangeItem } from '-/components/Basket/ChangeItem'

import { ModalContainer } from '../../../Modal/ModalContainer'

import getBasketProduct from './BasketProduct.gql'
import UpdateItemInBasket from './UpdateItemInBasket.gql'

I updated the docs accordingly, added new tests and made sure that nothing else broke. The change itself is pretty small but it dramatically changes the result for these situations.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.803% when pulling 4827e72 on swernerx:fix/order-unknown-types into 15e5c61 on benmosher:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.803% when pulling 4827e72 on swernerx:fix/order-unknown-types into 15e5c61 on benmosher:master.

@coveralls
Copy link

coveralls commented Jun 6, 2019

Coverage Status

Coverage remained the same at 97.803% when pulling d81a5c8 on swernerx:fix/order-unknown-types into 15e5c61 on benmosher:master.

@ljharb
Copy link
Member

ljharb commented Jun 11, 2019

I’m a bit confused - what code is generating “unknown”? Is this a type that we’ve always generated but simply not allowed to be in the config list?

@swernerx
Copy link
Contributor Author

Yes, it seems like this is exactly the case.

@swernerx
Copy link
Contributor Author

swernerx commented Jun 11, 2019

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple semver-minor, thanks

@ljharb ljharb merged commit 45bfe47 into import-js:master Jun 11, 2019
@swernerx
Copy link
Contributor Author

Thanks! Can you tell when the new version will be released?

@swernerx swernerx deleted the fix/order-unknown-types branch June 12, 2019 07:00
@ljharb
Copy link
Member

ljharb commented Jun 12, 2019

i can't, no, but this PR will be in the next one, whenever that is :-)

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

Successfully merging this pull request may close these issues.

3 participants