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

"extends" in .remarkrc #183

Closed
kachkaev opened this issue Jun 8, 2016 · 6 comments
Closed

"extends" in .remarkrc #183

kachkaev opened this issue Jun 8, 2016 · 6 comments
Labels
👀 no/external This makes more sense somewhere else 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have

Comments

@kachkaev
Copy link

kachkaev commented Jun 8, 2016

Hey guys,

I discovered remark after having some experience with eslint and I quite like the fact that these two tools share some ideas. Because of the resulting similarity, I expected to see one feature in remark, but I could not find it. It is about .remarkrc inheritance.

In eslint people often rely on some shared config, such as one by airbnb. It is possible create your own base config on top of something common and use it in all new projects:

cd new-project
npm install --save eslint-config-my-super-rules

new-project/.eslintrc:

{
  "extends": "my-super-rules"
}

When a team decides to follow a new .eslint rule, someone just updates eslint-config-my-super-rules (a central node module) and then others just npm update inside the dependent projects. This way it is much easier to stay organized in a team because no eslint rules are project-specific.

The same approach could be used with remark linter (or other remark plugins):

cd new-project
npm install --save remark-config-my-super-rules

new-project/.remarkrc:

{
  "extends": "my-super-rules"
}

When all remark-linter rules are shared across multiple projects, there is less debate on how *.md should look like in each individual case. If a team is not happy with the current state of things, a rule is added or removed in a single source of truth for remark and everyone is happy again.

How feasible would be to add something like this to remark?

@wooorm
Copy link
Member

wooorm commented Jun 8, 2016

Coool! I like this idea, and I definitely see it included in the future.

Now, ESLint is a linter, whereas remark is more like esprima, acorn, or others. With that in mind, do you see the whole .remarkrc extend other configs?

{
  "extends": "my-super-rules",
  "output": true
}

Or, just the plugins:

{
  "plugins": {
      "extends": "my-super-rules",
  },
  "output": true
}

Or, just remark-lint:

{
  "plugins": {
    "lint": {
      "extends": "my-super-rules"
    }
  },
  "output": true
}

Note that something like this already works, by using --config-path ./node_modules/my-super-rules/index.js, but that’s not very nice of course.

@wooorm wooorm added 🦋 type/enhancement This is great to have remarkrc(5) 🙉 open/needs-info This needs some more info 🧒 semver/minor This is backwards-compatible change labels Jun 8, 2016
@kachkaev
Copy link
Author

kachkaev commented Jun 8, 2016

Hey @wooorm, glad that you like the suggestion!

I haven't been using remark for anything but linting so far, so I'm afraid it's difficult for me to recommend what sort of inheritance would be better. Thanks for the --config-path tip!

There's probably one more thing one can do in the meantime: to simply make my-project/.remarkrc a symlink to my-project/node_modules/remark-config-my-super-rules/.remarkrc. A symlink will perfectly fit into a git repo, so a cloned working copy should work right away after git clone and npm install (unless you are on Windows). Looks like a solution with a symlink will suit me for now, because I'm not planning to introduce any additional project-specific rules and because Atom's linter for markdown files will be able to understand me.

@wooorm wooorm added 👀 no/external This makes more sense somewhere else and removed remarkrc(5) labels Jun 16, 2016
@alexander-akait
Copy link

@wooorm I think it would be cool to be able extend in all levels (config, plugins, setting - rules for plugins)

@wooorm
Copy link
Member

wooorm commented Aug 16, 2016

Small update: I’ve decided to go with presets instead, similar to how Babel presets work.

Here’s an example using presets:

{
  "presets": [
    "lint-recommended" // remark-preset-lint-recommended
  ],
  // completely optional overwriting of options:
  "plugins": {
    "lint": {
      "bullet": "*"
    }
  }
}

Where remark-preset-lint-recommended could look as follows:

{
  "plugins": {
    "lint": {
      "finalNewline": true,
     // ...
    }
  }
}

If the user installed remark-lint, it’ll use that, otherwise the one in the preset is used!

Thus, they’re basically sharable configs, but the mental model of Babel fits better than ESLint.

For now I’m writing some tests and stuff. Hope to do a proper release this/next week.

@Francois-Esquire

This comment was marked as resolved.

@wooorm
Copy link
Member

wooorm commented Aug 1, 2022

Locking and hiding to keep the discussion clean.
You are responding on a 6 year old, solved, issue. See my last comment, and the commit that closed this, for the answer “has this been implemented”.
This has since changed a bit. Presets can be passed everywhere just like plugins can.
For the latest on presets, see the API docs: https://github.com/unifiedjs/unified#preset.

@remarkjs remarkjs locked as resolved and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
👀 no/external This makes more sense somewhere else 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have
Development

No branches or pull requests

4 participants