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

bug with options and double run #5

Closed
alexander-akait opened this issue Mar 1, 2016 · 27 comments
Closed

bug with options and double run #5

alexander-akait opened this issue Mar 1, 2016 · 27 comments
Labels
🙋 no/question This does not need any changes

Comments

@alexander-akait
Copy link

remark().use(lint)

.remarkrc

"plugins": {
        "lint": {
            "list-item-indent": "space"
        }
}

First use remark() use .remarkrc and run lint plugin, second use double run lint plugin, but not get config file .remarkrc

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

If you specify use(lint) in the code and in a .remarkrc file, you’re specifying that the lint plug-in runs twice. Same as remark().use(lint).use(lint).

I think this is a feature; why do you think it’s a bug?

@alexander-akait
Copy link
Author

@wooorm hm, as possible to run only lint?

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

Yes, by either not specifying it in .remarkrc, or not specifying it in .use(lint). Choose one, and you’ll get it once!

@alexander-akait
Copy link
Author

@wooorm good, but if i run use, my .remarkrc not loaded in remark cli. It is normal? It is not convenient. I have 2 task in gulp, first run before all and lints all files, second render html from markdown. I have 2 separate task for this, because i use watch for lint changing files (i not need to html render).

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

I’m not yet sure what you’re saying, but it sounds like two questions. Could you show me what code you use, what goes wrong, and what you expect?

@alexander-akait
Copy link
Author

@wooorm

'use strict';

var options = require('../options');
var taskConfig = options.get('tasks.remarkLint');

if (!taskConfig.enable) {
    return;
}

var gulp = require('gulp');
var gulpPlumber = require('gulp-plumber');
var gulpRemark = require('gulp-remark');
var remarkLint = require('remark-lint');
var definingConfiguration = require('../lib/defining-configuration');

function remarkLintTask() {
    var config = this.config;

    return gulp
        .src(config.paths.src.globs, config.paths.src.options)
        .pipe(gulpPlumber(config.options.plumber))
        .pipe(gulpRemark().use(remarkLint));
}

gulp.task('remarkLint', definingConfiguration(taskConfig, remarkLintTask));

module.exports = remarkLintTask;

Run this task i run twice lint, but first get .remarkrc, second not get and use default params. Why second use not get configuration file?

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

OK, I think this is gulp-remark related, not remark. I don’t know much about gulp. @denysdovhan, can you help here?

@alexander-akait
Copy link
Author

@wooorm @denysdovhan and still I would like to know whether it is possible to run only lint? May be
add use for run only need plugin?

var gulpRemarkUse = require('gulp-remark').use;

@denysdovhan
Copy link
Collaborator

I think this is a feature; why do you think it’s a bug?
@wooorm

@evilebottnawi I can't understand too why you think about this as problem. Just use only .use(plugin, [options]) and define your settings there, or use only .remarkrc and define your configs there.

This behavior is OK. It's like you've say twice what to do:

  1. Run lint without any parameters (from gulpfile.js)
  2. Run lint with these specified parameters (from .remarkrc)

I think you didn't noticed that you can define options for remark-lint from code, as second paramether of .use().

@alexander-akait
Copy link
Author

@denysdovhan Ok twice it is normal. But define options (for plugins) in code it is not normal and uncomfortable. I work in big command and we created shared config for linting markdown in many own project - options in code it is not solution, it is strange.

@denysdovhan
Copy link
Collaborator

@evilebottnawi why? Don't you define options for postcss-plugins, for example? It's OK.

If you don't like to define your settings in code, use .remarkignore instead.

@denysdovhan denysdovhan added help wanted 🙏 This could use your insight or help 🙋 no/question This does not need any changes labels Mar 1, 2016
@alexander-akait
Copy link
Author

@denysdovhan postcss-plugins not use .*rc files

@alexander-akait
Copy link
Author

@denysdovhan we use eslint and have .eslintrc shared config for all projects, we use stylelint and have .stylelintrc shared config for all projects, it would be nice to have the same opportunity and the setting remark-lint.

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

it would be nice to have the same opportunity and the setting remark-lint.

You can! Just remove the .use(...) from your code, as I mentioned above:

Yes, by either not specifying it in .remarkrc, or not specifying it in .use(lint). Choose one, and you’ll get it once!

@alexander-akait
Copy link
Author

@wooorm i need only linting, why run all plugins? My code may contain error and i can stop build on error. In big project i have many linter and first run linter before build.

@alexander-akait
Copy link
Author

Also i use browserSync and pipe all changes. I need run linting on change code, i not need other plugins (not render html)

@denysdovhan
Copy link
Collaborator

@wooorm can detectRC option be passed through gulpRemark({ detectRC: false })?

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

@evilebottnawi If you don’t need other plug-ins, don’t use other plug-ins. This has nothing to do with your comments or your question.

Look, you provided code twice: first a .remarkrc and a .use(lint) call, this issue is relating to that and we explained how you can fix your problem. The second time, you provided a gulpfile without .remarkrc. Your problem is fixed, from looking at that file.

Now you’re talking about stuff which I haven’t seen code for, and which shouldn’t happen with the code you provided.

@denysdovhan Yes, source.

@alexander-akait
Copy link
Author

@wooorm ok i use and run linter once, but second use not get configuration from .remarkrc

gulpRemark({detectRC: false}).use(gulpRemarkLint)

I do not understand why you think it is convenient, but I will cite an example of using linters before build - standard workflow in many projects (incidentally frail option not working, gulp not exit with error code >0). Many projects have separate repo where store configuration for eslint, stylelint and etc. And use their in all projects. Hard code options in code it is bad.

@alexander-akait
Copy link
Author

@wooorm @denysdovhan why not create api:

var gulpRemark = require('gulp-remark');
var gulpRemarkUse = require('gulp-remark').use;

Where gulpRemark() - get remarkrc and run all plugins and gulpRemarkUse(plugin, options) run only plugin. And why i use with plugin, .remarkrc not load?

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

@evilebottnawi It seems you’re saying many different things, e.g., --frail not working. Please raise separate issues for those (with your code, what you tried, what you expected, and what happened).

In your last comment, you’re proposing a mechanism where only one plug-in is run. I do not know of any other similar systems which allow that. Think Babel, which doesn’t allow running one plug-in, or PostCSS, which doesn’t allow just running one plug-in.

Maybe you’re interested in gulp-remark-lint?

@denysdovhan
Copy link
Collaborator

@evilebottnawi if you want, you can use it like this:

const gulpRemarkUse = require('gulp-remark')().use;

And it will do what you need.

@alexander-akait
Copy link
Author

@wooorm postcss plugins not use .rc files, rewark add this feature, but if i use only one plugin, options from .remarkrc not loaded. it's a bit strange. Thanks for plugin.
@denysdovhan all plugins will work then.

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

Then use const gulpRemarkUse = require('gulp-remark')({detectRC: false}).use;

@alexander-akait
Copy link
Author

@wooorm
I install directry rewark and

remark *.md

All options for plugins are loaded

use

remark --use remark-lint *.md

Options not loaded for plugin from .remarkrc. It is really a bit strange. It is normal?

@wooorm
Copy link
Member

wooorm commented Mar 1, 2016

Don’t use plug-ins both in .remarkrc and in the flags. you’re specifying it to run the same plug-in, by two different names, and thus twice.

@denysdovhan
Copy link
Collaborator

#5 (comment) about remark, not about gulp-remark. If you think this is strange, please open an issue there.

Thank you for your question. I'm gonna close this issue, because the problem is solved. If you have any other question, please ask.

P.S: postcss-cli has config files.

@wooorm wooorm removed the help wanted 🙏 This could use your insight or help label Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

3 participants