mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Add lint rules from eslint-plugin-node.
This commit is contained in:
parent
6525c36f1e
commit
e1eb81cd21
11 changed files with 61 additions and 19 deletions
|
@ -7,7 +7,8 @@
|
|||
"es6": true
|
||||
},
|
||||
"plugins": [
|
||||
"jsdoc"
|
||||
"jsdoc",
|
||||
"node"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:all",
|
||||
|
@ -65,10 +66,53 @@
|
|||
"space-before-function-paren": ["error", "never"],
|
||||
"vars-on-top": "off",
|
||||
"wrap-regex": "off",
|
||||
|
||||
"jsdoc/check-examples": "error",
|
||||
"jsdoc/check-indentation": "error",
|
||||
"jsdoc/check-syntax": "error",
|
||||
"jsdoc/match-description": "error",
|
||||
"jsdoc/require-description": "error"
|
||||
"jsdoc/require-description": "error",
|
||||
|
||||
"node/handle-callback-err": "error",
|
||||
"node/no-callback-literal": "error",
|
||||
"node/no-exports-assign": "error",
|
||||
"node/no-extraneous-import": "error",
|
||||
"node/no-extraneous-require": "error",
|
||||
"node/no-missing-import": "error",
|
||||
"node/no-missing-require": "error",
|
||||
"node/no-new-require": "error",
|
||||
"node/no-path-concat": "error",
|
||||
"node/no-process-exit": "error",
|
||||
"node/no-unpublished-bin": "error",
|
||||
"node/no-unpublished-import": "error",
|
||||
"node/no-unpublished-require": "error",
|
||||
"node/no-unsupported-features/es-builtins": "error",
|
||||
"node/no-unsupported-features/es-syntax": "error",
|
||||
"node/no-unsupported-features/node-builtins": ["error", {
|
||||
"ignores": [
|
||||
"fs.promises"
|
||||
]
|
||||
}],
|
||||
"node/process-exit-as-throw": "error",
|
||||
"node/shebang": "error",
|
||||
"node/no-deprecated-api": "error",
|
||||
"node/callback-return": "error",
|
||||
"node/exports-style": "error",
|
||||
"node/file-extension-in-import": "error",
|
||||
"node/global-require": "off",
|
||||
"node/no-mixed-requires": "error",
|
||||
"node/no-process-env": "error",
|
||||
"node/no-restricted-import": "error",
|
||||
"node/no-restricted-require": "error",
|
||||
"node/no-sync": "off",
|
||||
"node/prefer-global/buffer": "error",
|
||||
"node/prefer-global/console": "error",
|
||||
"node/prefer-global/process": "error",
|
||||
"node/prefer-global/text-decoder": "error",
|
||||
"node/prefer-global/text-encoder": "error",
|
||||
"node/prefer-global/url-search-params": "error",
|
||||
"node/prefer-global/url": "error",
|
||||
"node/prefer-promises/dns": "error",
|
||||
"node/prefer-promises/fs": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,3 @@ module.exports = window.markdownit;
|
|||
if (!module.exports) {
|
||||
console.error("markdown-it must be loaded before markdownlint.");
|
||||
}
|
||||
|
||||
// Use browser's URL implementation if not available on url module
|
||||
var url = require("url");
|
||||
if (!url.URL) {
|
||||
url.URL = URL;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ That function is called once for each file/string input and is passed the parsed
|
|||
A simple rule implementation looks like:
|
||||
|
||||
```js
|
||||
const { URL } = require("url");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import markdownlint from "../..";
|
||||
|
||||
const assert = require("assert");
|
||||
const { URL } = require("url");
|
||||
const markdownlintJsonPath = "../../.markdownlint.json";
|
||||
|
||||
function assertConfiguration(config: markdownlint.Configuration) {
|
||||
|
|
|
@ -32,7 +32,7 @@ const emphasisMarkersRe = /[_*]/g;
|
|||
const linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
|
||||
|
||||
// readFile options for reading with the UTF-8 encoding
|
||||
module.exports.utf8Encoding = { "encoding": "utf8" };
|
||||
module.exports.utf8Encoding = "utf8";
|
||||
|
||||
// All punctuation characters (normal and full-width)
|
||||
module.exports.allPunctuation = ".,;:!?。,;:!?";
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { URL } = require("url");
|
||||
const markdownIt = require("markdown-it");
|
||||
const rules = require("./rules");
|
||||
const helpers = require("../helpers");
|
||||
|
@ -681,6 +680,7 @@ function lintFile(
|
|||
}
|
||||
// Make a/synchronous call to read file
|
||||
if (synchronous) {
|
||||
// @ts-ignore
|
||||
lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding));
|
||||
} else {
|
||||
fs.readFile(file, helpers.utf8Encoding, lintContentWrapper);
|
||||
|
@ -889,6 +889,7 @@ function readConfig(file, parsers, callback) {
|
|||
*/
|
||||
function readConfigSync(file, parsers) {
|
||||
// Read file
|
||||
// @ts-ignore
|
||||
const content = fs.readFileSync(file, helpers.utf8Encoding);
|
||||
// Try to parse file
|
||||
const { config, message } = parseConfiguration(file, content, parsers);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
const packageJson = require("../package.json");
|
||||
const homepage = packageJson.homepage;
|
||||
const version = packageJson.version;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"test-cover": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 node test/markdownlint-test.js",
|
||||
"test-declaration": "cd example/typescript && tsc && node type-check.js",
|
||||
"test-extra": "node test/markdownlint-test-extra.js",
|
||||
"lint": "eslint --max-warnings 0 lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0\" demo && eslint --rule \"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0\" example",
|
||||
"lint": "eslint --max-warnings 0 lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0\" demo && eslint --rule \"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0, node/no-missing-require: 0, node/no-extraneous-require: 0\" example",
|
||||
"ci": "npm run test-cover && npm run lint && npm run test-declaration",
|
||||
"build-config-schema": "node schema/build-config-schema.js",
|
||||
"build-declaration": "tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration",
|
||||
|
@ -42,6 +42,7 @@
|
|||
"cpy-cli": "~3.1.1",
|
||||
"eslint": "~7.8.1",
|
||||
"eslint-plugin-jsdoc": "~30.3.1",
|
||||
"eslint-plugin-node": "~11.1.0",
|
||||
"globby": "~11.0.1",
|
||||
"js-yaml": "~3.14.0",
|
||||
"make-dir-cli": "~2.0.0",
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
const { URL } = require("url");
|
||||
const { promisify } = require("util");
|
||||
const md = require("markdown-it")();
|
||||
const pluginInline = require("markdown-it-for-inline");
|
||||
|
@ -3946,6 +3945,16 @@ tape("customRulesLintJavaScript", (test) => {
|
|||
test.ifError(err);
|
||||
const expected = {
|
||||
"test/lint-javascript.md": [
|
||||
{
|
||||
"lineNumber": 8,
|
||||
"ruleNames": [ "lint-javascript" ],
|
||||
"ruleDescription": "Rule that lints JavaScript code",
|
||||
"ruleInformation": null,
|
||||
"errorDetail":
|
||||
"Definition for rule 'node/handle-callback-err' was not found.",
|
||||
"errorContext": "\"use strict\";",
|
||||
"errorRange": null
|
||||
},
|
||||
{
|
||||
"lineNumber": 10,
|
||||
"ruleNames": [ "lint-javascript" ],
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
const { filterTokens } = require("markdownlint-rule-helpers");
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"description": "Rule that reports an error for lines with the letters 'EX'",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue