4.0.2 • Published 1 year ago

textlint-rule-eslint v4.0.2

Weekly downloads
103
License
MIT
Repository
github
Last release
1 year ago

textlint-rule-eslint Actions Status: test

textlint rule to lint JavaScript in Markdown with ESLint.

Use case

ESLint can lint Markdown files using eslint-plugin-markdown. But eslint-plugin-markdown doesn't support disabling Markdown (HTML) comments for ignoring some CodeBlocks.

textlint can filter some CodeBlocks using textlint-filter-rule-comments:

<!-- textlint-disable -->

```js
var ignore = "This is ignored"
```

<!-- textlint-enable -->

Sometimes, we want to write broken JavaScript code into a JS CodeBlock for syntax highlight:

This is error example of parsing:

<!-- textlint-disable eslint -->

```js
// This is invalid example
const const;
```

<!-- textlint-enable eslint -->

To ignore ESLint parsing errors that cannot be ignored from the config file, you can use ignoreParsingErrors:

{
    "rules": {
        "eslint": {
          "configFile": "path/to/.eslintrc"
          "ignoreParsingErrors": true
        }
    }
}

Installation

Install with npm:

npm install textlint-rule-eslint eslint

:warning: textlint-rule-eslint 4+ requires eslint 8+.

Usage

Via .textlintrc (recommended):

{
    "rules": {
        "eslint": {
          // Required: path to .eslintrc file
          "configFile": "path/to/.eslintrc"
        }
    }
}

Via CLI:

textlint --rule eslint README.md

Options

  • configFile: string
    • Required
    • path to .eslintrc file
  • langs: string[]
    • Default: ["js", "javascript", "node", "jsx"]
    • recognize lang of CodeBlock
  • ignoreParsingErrors: Boolean
    • Default: false
    • ignore ESLint parsing errors while still reporting other ESLint errors
{
    "rules": {
        "eslint": {
            // Required: path to .eslintrc file
            "configFile": "path/to/.eslintrc",
            // recognize lang of CodeBlock
            "langs": ["js", "javascript", "node", "jsx"]
            // Ignore ESLint parsing errors
            "ignoreParsingErrors": true
        }
    }
}

Fixable

textlint-rule-eslint support --fix option.

textlint rule

See https://github.com/textlint/textlint/#fixable for more details.

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

4.0.2

1 year ago

4.0.1

1 year ago

4.0.0

2 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago