Giter VIP home page Giter VIP logo

eslint-plugin-md's Issues

"Cannot read property 'tokens' of undefined" error

Version of the eslint-plugin-md: 1.0.19

I have an error when trying to parse a markdown file wiht code snippets and when the code is fenced. I'm getting this error:

Cannot read property 'tokens' of undefined
TypeError: Cannot read property 'tokens' of undefined
    at validate (/home/[...]/node_modules/eslint/lib/util/source-code.js:28:14)
    at ...

Example of files and configuration causing the error:

README.md

npm start --dry-run

.eslintrc (yaml syntax):

extends:
    - "plugin:md/recommended"

rules:
    md/remark: 
        - error
        - plugins: 
            - "preset-lint-markdown-style-guide"
            - 
                - "lint-fenced-code-flag"
                - allowEmpty: true
            -
                - "lint-ordered-list-marker-value"
                - "ordered"

overrides:
    -
        files:
            - "*.md"
        parser: "markdown-eslint-parser"

I've seen that in the mdProcessor.js of this plugin, line 34, inside preprocess function, it is storing some sort of filename with the extension of the code snippet appended to it and perhaps it could be giving problems:

const jsBlocksResult = nonMdBlocksInner.map(({ text, lang }, i) => ({
      text,
      // eslint internal code appends this filename to real filename
      filename: `/../../${partName}.${lang}`,
    }))

As you can see in the example, I disabled the lint-fenced-code-flag in order to be able to pass the validation by removing the language from the code snippets, but this is not an option since I have many md files plenty of this feature.

Formatting with Prettier not working

Hi, I am loving this library already. Linting entire Markdown files with ESLint is great, so I'm glad you put this together.

I am having trouble getting this to work as expected with Prettier though. It is not formatting my files to account for line-length.

Here is my .prettierrc.json:

{
	"semi": true,
	"singleQuote": true,
	"tabWidth": 2,
	"useTabs": false,
	"trailingComma": "all",
	"printWidth": 80,
	"overrides": [
		{
			"files": "*.json",
			"options": {
				"trailingComma": "none"
			}
		},
		{
			"files": [
				"*.md"
			],
			"options": {
				"parser": "markdown",
				"rules": {
					"prettier/prettier": [
						"error",
						{
							"parser": "markdown"
						}
					]
				}
			}
		}
	]
}

and here is my .eslintrc.json:

{
	"semi": true,
	"singleQuote": true,
	"tabWidth": 2,
	"useTabs": false,
	"trailingComma": "all",
	"printWidth": 80,
	"overrides": [
		{
			"files": "*.json",
			"options": {
				"trailingComma": "none"
			}
		},
		{
			"files": [
				"*.md"
			],
			"options": {
				"parser": "markdown",
				"rules": {
					"prettier/prettier": [
						"error",
						{
							"parser": "markdown"
						}
					]
				}
			}
		}
	]
}

and here are the dependencies from my package.json:

"dependencies": {
    "fibers": "^4.0.2",
    "glob": "^7.1.6",
    "gray-matter": "^4.0.2",
    "isomorphic-unfetch": "^3.0.0",
    "next": "^9.3.1",
    "node-sass": "^4.13.1",
    "raw-loader": "^4.0.0",
    "react": "^16.13.1",
    "react-addons-shallow-compare": "^15.6.2",
    "react-dom": "^16.13.1",
    "react-markdown": "^4.3.1",
    "react-syntax-highlighter": "^12.2.1",
    "sass": "^1.26.3",
    "styled-components": "^5.1.0",
    "swr": "^0.1.18"
  },
  "devDependencies": {
    "babel-plugin-styled-components": "^1.10.7",
    "eslint": "^7.2.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-json": "^2.1.1",
    "eslint-plugin-md": "^1.0.15",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-react": "^7.20.0",
    "eslint-plugin-react-hooks": "^4.0.4",
    "husky": "^4.2.5",
    "lint-staged": ">=10",
    "markdown-eslint-parser": "^1.2.1",
    "prettier": "2.0.5"
  },

For reference, I am using VSCode, but I can't get this working from the CLI either. I would appreciate any help you can provide!

Disabled log JSBR and MG by default.

my english is not good, sorry.
thanks for your works, eslint-plugin-md is amazing for me.
but there is only one trouble prevent i use it in my project.
it is the extra logging about JSBR and MG.
looking forward to your reply 馃憤

Disabling rules

I'm strugging with disabling rules using the .eslintrc.js file. All of the output is tagged as "md/remark", so if I disable that rule everything get's disabled.
14:59 error Missing new line after list item (list-item-spacing) md/remark

How can I disable the "list-item-spacing" rule?

Thanks!

[Bug] Doesn't parse indented code blocks

When the codeblock is indented followed by a codeblock that is not, the parser has a really bad time trying to parse it.

I created a repo with a reproduction case: https://github.com/scinos/eslint-md-parsing-error

Input:

- list

  ```js
  foo()
  ```

---

```js
bar()
```

Lint errors (./node_modules/.bin/eslint .):

   3:3  error  Insert `路路`                              prettier/prettier
   4:1  error  Insert `路路`                              prettier/prettier
   5:1  error  Insert `路路`                              prettier/prettier
   6:1  error  Insert `路路`                              prettier/prettier
   7:1  error  Insert `路路`                              prettier/prettier
   8:1  error  Insert `路路`                              prettier/prettier
   9:1  error  Insert `路路`                              prettier/prettier
  10:1  error  Insert `路路`                              prettier/prettier
  11:1  error  Insert `路路`                              prettier/prettier
   5:3  error  Parsing error: Unexpected character '`'

Output when using autofix (./node_modules/.bin/eslint . --fix):

          -   list

    ```js
    foo()
  ```

---
  
```js
bar()
```

I found two workarounds:

  1. Removing the language tag from the first codeblock
  2. Un-indenting the first codeblock

Abandoned?

is this project still maintained? dependabot has been ignored for a few years now and there are a few high risk vulnerabilities in the old versions that this project depends on.

`lint-no-missing-blank-lines` doesn't play nice with this plugin

I was trying to use the lint-no-missing-blank-lines rule with this package, but ran into some problems. Given a Markdown file with the following content:

# Example

foobar

```js
let x = 42;
console.log(x);
```

Using this plugin with ESLint

module.exports = {
  overrides: [
    {
      files: ["**/*.md"],
      parser: "markdown-eslint-parser",
      extends: [
        "plugin:md/recommended",
      ],
      rules: {
        "md/remark": ["error",{
          plugins: [
            ["lint-no-missing-blank-lines"],
          ]
      },
    },
  ],
};

Gives the following errors:

  6:1  error  Missing blank line before block node (no-missing-blank-lines)  md/remark
  7:1  error  Missing blank line before block node (no-missing-blank-lines)  md/remark
  8:1  error  Missing blank line before block node (no-missing-blank-lines)  md/remark

Whereas a similar setup using remark-lint directly reports no errors, see https://codesandbox.io/s/remark-debug-forked-w8w1w?file=/src/index.js

I'm guessing this plugin/ESLint is doing something to the file that confuses remark, but I wasn't able to figure out what...

[Feature request] Ignore files

It would be nice to have a way to fully ignore files that I don't want get linted/fixed (for example, a LICENSE file).

Maybe a <!-- eslint-disable --> at the top?

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.