From 7dc8f80a5ee8aa5d16cddfb15a2a9d159a569afd Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sat, 28 Mar 2020 20:33:51 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20fix=20rule=20names=20in=20docume?= =?UTF-8?q?ntation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/rules/callback-return.md | 6 +++--- docs/rules/global-require.md | 4 ++-- docs/rules/handle-callback-err.md | 1 - docs/rules/no-mixed-requires.md | 10 +++++----- docs/rules/no-new-require.md | 4 ++-- docs/rules/no-process-env.md | 4 ++-- docs/rules/no-process-exit.md | 4 ++-- docs/rules/no-restricted-import.md | 16 ++++++++-------- docs/rules/no-restricted-require.md | 16 ++++++++-------- docs/rules/no-sync.md | 8 ++++---- 10 files changed, 36 insertions(+), 37 deletions(-) diff --git a/docs/rules/callback-return.md b/docs/rules/callback-return.md index 9622d65a..46b17738 100644 --- a/docs/rules/callback-return.md +++ b/docs/rules/callback-return.md @@ -32,7 +32,7 @@ The rule takes a single option - an array of possible callback names - which may Examples of **incorrect** code for this rule with the default `["callback", "cb", "next"]` option: ```js -/*eslint callback-return: "error"*/ +/*eslint node/callback-return: "error"*/ function foo(err, callback) { if (err) { @@ -45,7 +45,7 @@ function foo(err, callback) { Examples of **correct** code for this rule with the default `["callback", "cb", "next"]` option: ```js -/*eslint callback-return: "error"*/ +/*eslint node/callback-return: "error"*/ function foo(err, callback) { if (err) { @@ -60,7 +60,7 @@ function foo(err, callback) { Examples of **incorrect** code for this rule with the option `["done", "send.error", "send.success"]`: ```js -/*eslint callback-return: ["error", ["done", "send.error", "send.success"]]*/ +/*eslint node/callback-return: ["error", ["done", "send.error", "send.success"]]*/ function foo(err, done) { if (err) { diff --git a/docs/rules/global-require.md b/docs/rules/global-require.md index 8b1bbad0..c4f4fd11 100644 --- a/docs/rules/global-require.md +++ b/docs/rules/global-require.md @@ -29,7 +29,7 @@ This rule requires all calls to `require()` to be at the top level of the module Examples of **incorrect** code for this rule: ```js -/*eslint global-require: "error"*/ +/*eslint node/global-require: "error"*/ /*eslint-env es6*/ // calling require() inside of a function is not allowed @@ -61,7 +61,7 @@ try { Examples of **correct** code for this rule: ```js -/*eslint global-require: "error"*/ +/*eslint node/global-require: "error"*/ // all these variations of require() are ok require('x'); diff --git a/docs/rules/handle-callback-err.md b/docs/rules/handle-callback-err.md index 71673557..b8cae6ee 100644 --- a/docs/rules/handle-callback-err.md +++ b/docs/rules/handle-callback-err.md @@ -71,7 +71,6 @@ If the configured name of the error variable begins with a `^` it is considered * If the option is `"^.+Error$"`, the rule reports unhandled errors where the parameter name ends with `Error` (for example, `connectionError` or `validationError` will match). * If the option is `"^.*(e|E)rr"`, the rule reports unhandled errors where the parameter name matches any string that contains `err` or `Err` (for example, `err`, `error`, `anyError`, `some_err` will match). - ## 🔎 Implementation - [Rule source](../../lib/rules/handle-callback-err.js) diff --git a/docs/rules/no-mixed-requires.md b/docs/rules/no-mixed-requires.md index a445804b..ecc06dc0 100644 --- a/docs/rules/no-mixed-requires.md +++ b/docs/rules/no-mixed-requires.md @@ -39,7 +39,7 @@ Configuring this rule with one boolean option `true` is deprecated. Examples of **incorrect** code for this rule with the default `{ "grouping": false, "allowCall": false }` options: ```js -/*eslint no-mixed-requires: "error"*/ +/*eslint node/no-mixed-requires: "error"*/ var fs = require('fs'), i = 0; @@ -52,7 +52,7 @@ var async = require('async'), Examples of **correct** code for this rule with the default `{ "grouping": false, "allowCall": false }` options: ```js -/*eslint no-mixed-requires: "error"*/ +/*eslint node/no-mixed-requires: "error"*/ // only require declarations (grouping off) var eventEmitter = require('events').EventEmitter, @@ -75,7 +75,7 @@ var foo = require('foo' + VERSION), Examples of **incorrect** code for this rule with the `{ "grouping": true }` option: ```js -/*eslint no-mixed-requires: ["error", { "grouping": true }]*/ +/*eslint node/no-mixed-requires: ["error", { "grouping": true }]*/ // invalid because of mixed types "core" and "module" var fs = require('fs'), @@ -91,7 +91,7 @@ var foo = require('foo'), Examples of **incorrect** code for this rule with the `{ "allowCall": true }` option: ```js -/*eslint no-mixed-requires: ["error", { "allowCall": true }]*/ +/*eslint node/no-mixed-requires: ["error", { "allowCall": true }]*/ var async = require('async'), debug = require('diagnostics').someFunction('my-module'), /* allowCall doesn't allow calling any function */ @@ -101,7 +101,7 @@ var async = require('async'), Examples of **correct** code for this rule with the `{ "allowCall": true }` option: ```js -/*eslint no-mixed-requires: ["error", { "allowCall": true }]*/ +/*eslint node/no-mixed-requires: ["error", { "allowCall": true }]*/ var async = require('async'), debug = require('diagnostics')('my-module'), diff --git a/docs/rules/no-new-require.md b/docs/rules/no-new-require.md index 9fee50a0..6e45f6da 100644 --- a/docs/rules/no-new-require.md +++ b/docs/rules/no-new-require.md @@ -28,7 +28,7 @@ This rule aims to eliminate use of the `new require` expression. Examples of **incorrect** code for this rule: ```js -/*eslint no-new-require: "error"*/ +/*eslint node/no-new-require: "error"*/ var appHeader = new require('app-header'); ``` @@ -36,7 +36,7 @@ var appHeader = new require('app-header'); Examples of **correct** code for this rule: ```js -/*eslint no-new-require: "error"*/ +/*eslint node/no-new-require: "error"*/ var AppHeader = require('app-header'); var appHeader = new AppHeader(); diff --git a/docs/rules/no-process-env.md b/docs/rules/no-process-env.md index 4e004001..7473da3f 100644 --- a/docs/rules/no-process-env.md +++ b/docs/rules/no-process-env.md @@ -10,7 +10,7 @@ This rule is aimed at discouraging use of `process.env` to avoid global dependen Examples of **incorrect** code for this rule: ```js -/*eslint no-process-env: "error"*/ +/*eslint node/no-process-env: "error"*/ if(process.env.NODE_ENV === "development") { //... @@ -20,7 +20,7 @@ if(process.env.NODE_ENV === "development") { Examples of **correct** code for this rule: ```js -/*eslint no-process-env: "error"*/ +/*eslint node/no-process-env: "error"*/ var config = require("./config"); diff --git a/docs/rules/no-process-exit.md b/docs/rules/no-process-exit.md index 047bc597..d6ca7ce1 100644 --- a/docs/rules/no-process-exit.md +++ b/docs/rules/no-process-exit.md @@ -29,7 +29,7 @@ This rule aims to prevent the use of `process.exit()` in Node.js JavaScript. As Examples of **incorrect** code for this rule: ```js -/*eslint no-process-exit: "error"*/ +/*eslint node/no-process-exit: "error"*/ process.exit(1); process.exit(0); @@ -38,7 +38,7 @@ process.exit(0); Examples of **correct** code for this rule: ```js -/*eslint no-process-exit: "error"*/ +/*eslint node/no-process-exit: "error"*/ Process.exit(); var exit = process.exit; diff --git a/docs/rules/no-restricted-import.md b/docs/rules/no-restricted-import.md index 56f9a225..4ee73b5a 100644 --- a/docs/rules/no-restricted-import.md +++ b/docs/rules/no-restricted-import.md @@ -11,7 +11,7 @@ The rule takes an array as options: the names of restricted modules. ```json { - "no-restricted-import": ["error", [ + "node/no-restricted-import": ["error", [ "foo-module", "bar-module" ]] @@ -22,7 +22,7 @@ You may also specify a custom message for each module you want to restrict as fo ```json { - "no-restricted-import": ["error", [ + "node/no-restricted-import": ["error", [ { "name": "foo-module", "message": "Please use foo-module2 instead." @@ -39,7 +39,7 @@ And you can use glob patterns in the `name` property. ```json { - "no-restricted-import": ["error", [ + "node/no-restricted-import": ["error", [ { "name": "lodash/*", "message": "Please use xyz-module instead." @@ -60,7 +60,7 @@ module.exports = { { files: "client/**", rules: { - "no-restricted-import": ["error", [ + "node/no-restricted-import": ["error", [ { name: path.resolve(__dirname, "server/**"), message: "Don't use server code from client code." @@ -71,7 +71,7 @@ module.exports = { { files: "server/**", rules: { - "no-restricted-import": ["error", [ + "node/no-restricted-import": ["error", [ { name: path.resolve(__dirname, "client/**"), message: "Don't use client code from server code." @@ -88,7 +88,7 @@ module.exports = { Examples of **incorrect** code for this rule with sample `"fs", "cluster", "lodash"` restricted modules: ```js -/*eslint no-restricted-import: ["error", ["fs", "cluster", "lodash/*"]]*/ +/*eslint node/no-restricted-import: ["error", ["fs", "cluster", "lodash/*"]]*/ import fs from 'fs'; import cluster from 'cluster'; @@ -98,14 +98,14 @@ import pick from 'lodash/pick'; Examples of **correct** code for this rule with sample `"fs", "cluster", "lodash"` restricted modules: ```js -/*eslint no-restricted-import: ["error", ["fs", "cluster", "lodash/*"]]*/ +/*eslint node/no-restricted-import: ["error", ["fs", "cluster", "lodash/*"]]*/ import crypto from 'crypto'; import _ from 'lodash'; ``` ```js -/*eslint no-restricted-import: ["error", ["fs", "cluster", { "name": ["lodash/*", "!lodash/pick"] }]]*/ +/*eslint node/no-restricted-import: ["error", ["fs", "cluster", { "name": ["lodash/*", "!lodash/pick"] }]]*/ import pick from 'lodash/pick'; ``` diff --git a/docs/rules/no-restricted-require.md b/docs/rules/no-restricted-require.md index 3d4192b4..bcd2070b 100644 --- a/docs/rules/no-restricted-require.md +++ b/docs/rules/no-restricted-require.md @@ -18,7 +18,7 @@ The rule takes an array as options: the names of restricted modules. ```json { - "no-restricted-require": ["error", [ + "node/no-restricted-require": ["error", [ "foo-module", "bar-module" ]] @@ -29,7 +29,7 @@ You may also specify a custom message for each module you want to restrict as fo ```json { - "no-restricted-require": ["error", [ + "node/no-restricted-require": ["error", [ { "name": "foo-module", "message": "Please use foo-module2 instead." @@ -46,7 +46,7 @@ And you can use glob patterns in the `name` property. ```json { - "no-restricted-require": ["error", [ + "node/no-restricted-require": ["error", [ { "name": "lodash/*", "message": "Please use xyz-module instead." @@ -67,7 +67,7 @@ module.exports = { { files: "client/**", rules: { - "no-restricted-require": ["error", [ + "node/no-restricted-require": ["error", [ { name: path.resolve(__dirname, "server/**"), message: "Don't use server code from client code." @@ -78,7 +78,7 @@ module.exports = { { files: "server/**", rules: { - "no-restricted-require": ["error", [ + "node/no-restricted-require": ["error", [ { name: path.resolve(__dirname, "client/**"), message: "Don't use client code from server code." @@ -95,7 +95,7 @@ module.exports = { Examples of **incorrect** code for this rule with sample `"fs", "cluster", "lodash"` restricted modules: ```js -/*eslint no-restricted-require: ["error", ["fs", "cluster", "lodash/*"]]*/ +/*eslint node/no-restricted-require: ["error", ["fs", "cluster", "lodash/*"]]*/ const fs = require('fs'); const cluster = require('cluster'); @@ -105,14 +105,14 @@ const pick = require('lodash/pick'); Examples of **correct** code for this rule with sample `"fs", "cluster", "lodash"` restricted modules: ```js -/*eslint no-restricted-require: ["error", ["fs", "cluster", "lodash/*"]]*/ +/*eslint node/no-restricted-require: ["error", ["fs", "cluster", "lodash/*"]]*/ const crypto = require('crypto'); const _ = require('lodash'); ``` ```js -/*eslint no-restricted-require: ["error", ["fs", "cluster", { "name": ["lodash/*", "!lodash/pick"] }]]*/ +/*eslint node/no-restricted-require: ["error", ["fs", "cluster", { "name": ["lodash/*", "!lodash/pick"] }]]*/ const pick = require('lodash/pick'); ``` diff --git a/docs/rules/no-sync.md b/docs/rules/no-sync.md index 60052171..04359323 100644 --- a/docs/rules/no-sync.md +++ b/docs/rules/no-sync.md @@ -14,7 +14,7 @@ This rule has an optional object option `{ allowAtRootLevel: }`, which Examples of **incorrect** code for this rule with the default `{ allowAtRootLevel: false }` option: ```js -/*eslint no-sync: "error"*/ +/*eslint node/no-sync: "error"*/ fs.existsSync(somePath); @@ -26,7 +26,7 @@ function foo() { Examples of **correct** code for this rule with the default `{ allowAtRootLevel: false }` option: ```js -/*eslint no-sync: "error"*/ +/*eslint node/no-sync: "error"*/ obj.sync(); @@ -38,7 +38,7 @@ async(function() { Examples of **incorrect** code for this rule with the `{ allowAtRootLevel: true }` option ```js -/*eslint no-sync: ["error", { allowAtRootLevel: true }]*/ +/*eslint node/no-sync: ["error", { allowAtRootLevel: true }]*/ function foo() { var contents = fs.readFileSync(somePath).toString(); @@ -50,7 +50,7 @@ var bar = baz => fs.readFileSync(qux); Examples of **correct** code for this rule with the `{ allowAtRootLevel: true }` option ```js -/*eslint no-sync: ["error", { allowAtRootLevel: true }]*/ +/*eslint node/no-sync: ["error", { allowAtRootLevel: true }]*/ fs.readFileSync(somePath).toString(); ```