AtomLinter / linter-markdown

Lint markdown files within atom
https://atom.io/packages/linter-markdown
MIT License
43 stars 8 forks source link

Custom .remarkrc under Windows #140

Closed ThomDietrich closed 7 years ago

ThomDietrich commented 7 years ago

Hello, please excuse me for possibly asking a dead simple question. How do I use a custom remark configuration on a Windows system? I do not seem to be able to get it working.

Thanks for all hints ;)

wooorm commented 7 years ago

Hi @ThomDietrich, thanks for using linter-markdown!

Are you already using a remarkrc? Like this? If so, could you share how you’re using your remark config?

ThomDietrich commented 7 years ago

Hey @wooorm, thanks for getting back at me so quickly. I realized there was an error in my configuration. Anyhow, with your example configuration in place Atom is trying to parse it but provides the following error message:

Other than indicated, I can see the plugin(s) located at c:\Users\Birke\.atom\packages\linter-markdown\node_modules\remark-preset-lint-recommended\ etc. Did I miss something?

Error: Could not find module `remark-preset-lint-recommended`
at addModule (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:232:35)
at use (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:202:7)
at addEach (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:185:13)
at addPreset (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:165:9)
at merge (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:151:5)
at Config.create (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\configuration.js:106:5)
at done (C:\Users\Birke\.atom\packages\linter-markdown\node_modules\unified-engine\lib\find-up.js:141:20) at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
wooorm commented 7 years ago

Have you read this projects readme?

Specifically:

If there is configuration for remark-lint, through .remarkrc files or remarkConfig in package.jsons, this linter works just like remark-cli but only uses the remark-lint plugin. Make sure remark-lint is installed in this case (locally).

In that section, you’ll be linked to more useful info on configuration.

Finally, I think you’re missing the fact that you still need to install plugins locally. So, if you’re using remark-preset-lint-recommended, you’ll also need to install it in your project: npm install remark-preset-lint-recommended. Every plugin states how to install it in its docs; in this case remark-preset-lint-recommended’s readme.

Does this help?

wooorm commented 7 years ago

@ThomDietrich Friendly ping!

ThomDietrich commented 7 years ago

Sorry for the delay, Just tested the above and everything is working as expected. Issue solved on my side.

Maybe you can improve the documentation slightly. I saw the warning in the README but the error as shown above suggested that remark is already available (and hence the docs maybe a bit outdated) - could just be me 🐒. Maybe emphasize this requirement better or improve the error message to state "remark-cli missing on your system". Jm2c. Thanks for this great tool ;)

ThomDietrich commented 7 years ago

I've got one more question though. Hope you can clarify this for me quickly. Why does the following configuration only honor the last "list-indent" setting, not either of the first ones?

{
  "settings": {
    "list-item-indent": "mixed",
    "remark-lint-list-item-indent": "mixed"
  },
  "plugins": [
    ["remark-preset-lint-recommended", true],
    ["remark-preset-lint-consistent", true],
    ["remark-lint-list-item-indent", "mixed"]
  ]
}
wooorm commented 7 years ago

settings doesn’t work for lint rules (it did in previous versions). Now it’s all plugins, and if the same plugin is declared multiple times (in this case, remark-lint-list-item-indent), the last one wins!

ThomDietrich commented 7 years ago

Okay thanks for the clarification. In this case you might need to update some documentation, e.g., https://github.com/unifiedjs/unified-engine/blob/master/doc/configure.md Thanks again!

wooorm commented 7 years ago

I get that it seems confusing. As I mentioned though, “settings doesn’t work for lint rules”, but the documentation over there doesn’t refer to that. It’s for settings defining how markdown is parsed (and compiled), unrelated to linting!

For linting, I suggest the section on rules, and the section on configuring remark-lint!

By the way, your feedback is very valuable, and I’d love would be interested in creating a PR to make the docs here better!

ThomDietrich commented 7 years ago

I see. All of this is a bit confusing if you are coming "from the side" and your intention is to have some linting inside Atom 😉 I might include remark in our CI setup, in this case I will study the documentation better. Anyhow, thanks for the quick and helpful answers!!