eslint-plugin-import-order-alphabetical icon indicating copy to clipboard operation
eslint-plugin-import-order-alphabetical copied to clipboard

Exclude line from sorting

Open cdreve opened this issue 6 years ago • 1 comments

I am working on a react application and one of the rules I have is to keep the react import always first. So, I would like to exclude this line from sorting.

From:

import React from 'react';
import SizeMe from 'react-sizeme';
import PropTypes from 'prop-types';

To:

import React from 'react';
import PropTypes from 'prop-types';
import SizeMe from 'react-sizeme';

One option I can think of would be a comment at the end, something like:

// eslint-disable-line
// import-order-alphabetical-ignore-line

Another option would be to be able to add a way to ignore lines in the .eslintrc rule.

cdreve avatar Nov 14 '18 12:11 cdreve

I wanted the same thing but after some digging I found that import has a setting import/core-modules. It will basically allow you to add a list of packages as builtin.

This was actually a better solution in my opinion as an ignore option would not enforce the react import to be the first one which is the case for settings: import/core-modules.

Kirens avatar Apr 19 '19 09:04 Kirens