Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Make lint preset throw if included after other presets #800

Closed
edmorley opened this issue Apr 17, 2018 · 2 comments
Closed

Make lint preset throw if included after other presets #800

edmorley opened this issue Apr 17, 2018 · 2 comments
Assignees
Milestone

Comments

@edmorley
Copy link
Member

As seen in #763 and elsewhere, if the linter presets are included after the other presets, then they don't work as expected.

To help make this case more obvious to users, it seems to make sense for the lint presets to throw if not declared first. eg in eslint preset:

if neutrino.config.module.rules.has('compile') {
  throw new Error('Linter presets must be declared before any other presets.');
}
@edmorley edmorley added this to the v9 milestone Apr 17, 2018
@eliperelman
Copy link
Member

We would also need to make sure that another instance hasn't already been set:

if (
  neutrino.config.module.rules.has('compile') &&
  !neutrino.config.module.rules.has('lint')
) {

@edmorley
Copy link
Member Author

edmorley commented Apr 17, 2018

You mean in case people do something like this?

  use: [
    '@neutrinojs/airbnb',
    '@neutrinojs/react',
    '@neutrinojs/standardjs',
]

If so, I don't think that is a case we should worry about supporting. In the unlikely event they are using multiple @neutrinojs/* lint presets, they should just list them all at the start.

@edmorley edmorley self-assigned this Jun 7, 2018
@edmorley edmorley added the bug label Jun 7, 2018
edmorley added a commit that referenced this issue Jun 7, 2018
Presets such as `@neutrinojs/web` and `@neutrinojs/react` check to
see if a `lint` rule is defined, and if so, adapt its settings to
suit the particular environment/framework. This means that the lint
presets must be defined prior to the compile presets or the final
eslint configuration will not be correct.

Previously if the ordering was incorrect there would be no error
message, causing confusion when eslint wasn't behaving as expected.

Fixes #800.
Refs #763.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants