Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Lint code fences in markdown files? #779

Closed
tunnckoCore opened this issue Jan 10, 2017 · 8 comments
Closed

Lint code fences in markdown files? #779

tunnckoCore opened this issue Jan 10, 2017 · 8 comments

Comments

@tunnckoCore
Copy link

tunnckoCore commented Jan 10, 2017

Issue Type

Question / Bug

Issue Description

I'm not sure if the issue is for here, actually.

I have .eslintrc

{
  "extends": ["standard"],
  "plugins": ["markdown"]
}

and have just linter and linter-eslint packages. When run eslint from CLI it reports them as expected. But when typing in the markdown file it does not report any errors as like in the javascript files. So it seems it does not detects or respects the eslint-plugin-markdown?

I also added source.md in the linter-eslint settings.

Bug Checklist

  • Restart Atom - yes
  • Verify the eslint CLI gives the proper result, while linter-eslint does not - yes
  • Paste the output of the Linter Eslint: Debug command from the Command Palette below

atom version: 1.12.9
linter-eslint version: 8.0.0
eslint version: 3.13.1
hours since last atom restart: 0.3
platform: linux
Using local project eslint from /home/charlike/hub/fasfsdfsdf/node_modules/eslint
linter-eslint configuration: {
  "fixOnSave": true,
  "globalNodePath": "/home/charlike/.nvm/versions/node/v7.3.0",
  "scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic",
    "source.md",
    "source.markdown"
  ],
  "lintHtmlFiles": false,
  "useGlobalEslint": false,
  "showRuleIdInMessage": true,
  "disableWhenNoEslintConfig": true,
  "eslintrcPath": "",
  "advancedLocalNodeModules": "",
  "eslintRulesDir": "",
  "disableEslintIgnore": false,
  "disableFSCache": false,
  "rulesToSilenceWhileTyping": []
}

the tested markdown file

## Foobar

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\\`\`\`js
const foo = 1;

foo = 123
\`\`\`

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

eslint cli

~/hub/fasfsdfsdf  
% 1 ❯ eslint --ext md .                                                                                 January 11, 01:43:40

/home/charlike/hub/fasfsdfsdf/foo.md
  7:7   error  'foo' is assigned a value but never used  no-unused-vars
  7:14  error  Extra semicolon                           semi
  9:1   error  'foo' is constant                         no-const-assign

✖ 3 problems (3 errors, 0 warnings)

@tunnckoCore
Copy link
Author

Both locally and globally installed

~/hub/fasfsdfsdf  
% ❯ npm ls | grep eslint                                                                                January 11, 02:01:52
├─┬ [email protected]
├── [email protected]
├─┬ [email protected]
├── [email protected]
└── [email protected]

@Arcanemagus
Copy link
Member

This should work just fine if you add the right scope, the default Markdown language in Atom marks Markdown files as source.gfm not source.md.

Another thing to note is that the blocks need to be "real" embedded blocks, your example has the ` commented out so it reads as plain Markdown text.

Tested with the following files: linter-eslint_GH779.zip

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 11, 2017

@Arcanemagus i commented out them because can't be shown correctly here at the issue. They are real.

edit: I mean how to show code fence block in code fence block here at the issue? :D That's why i did it that way.

@Arcanemagus
Copy link
Member

I figured, since your CLI results would be impossible otherwise 😛.

Does this work properly for you if you change the scope to source.gfm?

@tunnckoCore
Copy link
Author

I'll try.

@tunnckoCore
Copy link
Author

Hm. I have language-gfm enabled? And the md file is using GitHub Markdown. For js files it seems to work, intentionally set to insert semi colons so i can see the diff. When I'm in markdown file in seems like it now insert them, nor shows any errors.

A bit later. Ooh, okey I set the source.gfm in the linter-eslint settings, the debug info seems that it includes it.

"scopes": [
    "source.js",
    "source.jsx",
    "source.js.jsx",
    "source.babel",
    "source.js-semantic",
    "source.md",
    "source.gfm",
    "source.markdown"
  ],

but it shows me an error Parsing error: Unexpected character '#'at line 1 col 1 when i'm in README.md

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 12, 2017

I also tried to remove the others source.md and source.markdown it still fails.

edit: Restarted the Atom, same.

@tunnckoCore
Copy link
Author

Doh! My fault. Didn't include the markdown plugin in the config, no i see the correct style errors like unused var and etc.

But there is another issue. It seems it not auto fix the errors? I'll open another issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants