GithubHelp home page GithubHelp logo

Comments (9)

eliperelman avatar eliperelman commented on July 17, 2024 3

Just to be clear, the reason I don't like Neutrino creating files is it just enforces repo boilerplate over presets. Project maintainers can add those files if they wish, but it is outside of the scope of Neutrino to create these files.

from neutrino.

eliperelman avatar eliperelman commented on July 17, 2024

So, I'm really against the creation of files in a repo, at least from the perspective of Neutrino creating them. Using the Neutrino API should be easy enough, although it doesn't really eliminate the boilerplate of getting the presets.

// .eslintrc.js

const Neutrino = require('neutrino');
const pkg = require('./package.json');
const api = new Neutrino(pkg.config.presets);

module.exports = api.module.rule('lint').loaders.get('eslint').options;

Unfortunately, the ESLint RC file format is different than the config passed to an instance of ESLint's CLIEngine (and therefore eslint-loader), so it isn't just as simple as exporting the same config. 😞

from neutrino.

kebot avatar kebot commented on July 17, 2024

Yes, project maintainer can add those files by hand. But better to build some scripts to generator these files. How about creating a new project like neutrino-utils-genconfig?

I'll do that later, tired of copy configs every time when starting a new project.

from neutrino.

eliperelman avatar eliperelman commented on July 17, 2024

Yes, I think that will work just fine for an external project.

By the way, I just had a thought. Maybe it should be the responsibility of the lint preset to also allow an export of its configuration consumable as an RC file. Then the preset would do the necessary conversion to allow it to be read as by ESLint's CLIEngine. Basically, it would enable you to do:

module.exports = require('neutrino-preset-airbnb-base/eslint');

EDIT: Hmm, I clearly hadn't thought that all the way through. That approach wouldn't work for the merging of lint configuration between presets. It would only get you the lint config from the base preset. I think my comment above still presents the best solution at the moment.

from neutrino.

akaRem avatar akaRem commented on July 17, 2024

Hi.

I have such interesting problem:
Neutrino says that I have style errors.
I open my IDE and hit "reformat code" and it does reformat according to internal defaults.
Everything is fine, but neutrino still see the problem.

Currently there are 2 places for eslint presets and most of IDEs respect them.
In neutrino-preset-airbnb-base it's supposed that configuration overrides should be put into config.neutrino.module.rule.lint.loader.eslint.options and this location will not be checked by IDEs.
IDEs don't expect that there are some style rules deep inside neutrino presets too.

So.. To fix this problem, I need this .eslintrc file.

I could fill it by hands, but then I need to sync my eslintrc file with all neutrino preset updates.
I could use internal api (api.getWebpackOptions().module.rules[0].use[0].options). But what if these indexes (0-s) will change after adding some other plugin?
Another problem is that such styling plugins could have deep dependency tree with overrides and it will be too hard to find out real styles used in my project.

From my point of view.. I'll have more problems using this preset than just running eslint directly.

I like this idea with one universal build/run tool for node projects. But It would be better if it will be compatible with existing tools.
I'd suggest you to createneutrino-preset-eslint which will just parse eslint config from package.json or from rc file?
If you need some custom preset for neutrino, you can publish it as another eslint preset. and include it into package.json uder eslintConfig namespace.

from neutrino.

eliperelman avatar eliperelman commented on July 17, 2024

@akaRem would this work for you? Just create a file in the root of your project named .eslintrc.js and use this as the contents:

// .eslintrc.js
const Neutrino = require('neutrino');
const pkg = require('./package.json');
const api = new Neutrino(pkg.config.presets);

module.exports = api.module.rules.get('lint').loaders.get('eslint').options;

from neutrino.

eliperelman avatar eliperelman commented on July 17, 2024

Just had a thought, maybe I could expose this on neutrino.custom from the lint base. Something like:

api.custom.lintConfig();

which will re-format the object to something usable by an ESLint rc format.

from neutrino.

eliperelman avatar eliperelman commented on July 17, 2024

Released lint presets with a new method: api.custom.eslintrc(), in v4.3.0. Documented:

https://neutrino.js.org/presets/neutrino-lint-base/#eslintrc-config

Thanks!

from neutrino.

akaRem avatar akaRem commented on July 17, 2024

@eliperelman looks nice and much more useful! Thanks.

from neutrino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.