From 04fe96b1f4eb6c5ce778c9186a7ea036d1546bd1 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Fri, 11 Oct 2019 16:36:53 +1100 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: Kai Cataldo <7041728+kaicataldo@users.noreply.github.com> --- docs/developer-guide/nodejs-api.md | 6 +++--- docs/developer-guide/working-with-rules.md | 2 +- tests/lib/linter/linter.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/developer-guide/nodejs-api.md b/docs/developer-guide/nodejs-api.md index cbbc97b8367f..d72fc2ede2d5 100644 --- a/docs/developer-guide/nodejs-api.md +++ b/docs/developer-guide/nodejs-api.md @@ -83,7 +83,7 @@ const codeLines = SourceCode.splitLines(code); The `Linter` object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it simply parses and reports on the code. In particular, the `Linter` object does not process configuration objects or files. The `Linter` is a constructor, and you can create a new instance by passing in the options you want to use. The available options are: -* `cwd` - Path to a directory that should be considered as the current working directory and can be retrieved by calling `context.getCwd()` from the rule. (If the `cwd` is `undefined`, it will be normalized to `process.cwd()` if the `process` exists, or `undefined` otherwise) +* `cwd` - Path to a directory that should be considered as the current working directory. It is accessible to rules by calling `context.getCwd()`. If `cwd` is `undefined`, it will be normalized to `process.cwd()` if the global `process` object is defined (for example, in the Node.js runtime) , or `undefined` otherwise. For example: @@ -93,8 +93,8 @@ const linter1 = new Linter({ cwd: 'path/to/project' }); const linter2 = new Linter(); ``` -in this example, rules run on `linter1` will get `path/to/project` when calling `context.getCwd()`. -Those run on `linter2` would get `process.cwd()` if the `process` exists (e.g. under node environment) or `undefined` otherwise (e.g. on the browser https://eslint.org/demo). +In this example, rules run on `linter1` will get `path/to/project` when calling `context.getCwd()`. +Those run on `linter2` will get `process.cwd()` if the global `process` object is defined or `undefined` otherwise (e.g. on the browser https://eslint.org/demo). ### Linter#verify diff --git a/docs/developer-guide/working-with-rules.md b/docs/developer-guide/working-with-rules.md index 3bc3a9c68289..ef6cbd63468b 100644 --- a/docs/developer-guide/working-with-rules.md +++ b/docs/developer-guide/working-with-rules.md @@ -126,7 +126,7 @@ The `context` object contains additional functionality that is helpful for rules Additionally, the `context` object has the following methods: * `getAncestors()` - returns an array of the ancestors of the currently-traversed node, starting at the root of the AST and continuing through the direct parent of the current node. This array does not include the currently-traversed node itself. -* `getCwd()` - returns the `cwd` passed to [Linter](./nodejs-api.md#Linter), path to a directory that should be considered as the current working directory. +* `getCwd()` - returns the `cwd` passed to [Linter](./nodejs-api.md#Linter). It is a path to a directory that should be considered as the current working directory. * `getDeclaredVariables(node)` - returns a list of [variables](./scope-manager-interface.md#variable-interface) declared by the given node. This information can be used to track references to variables. * If the node is a `VariableDeclaration`, all variables declared in the declaration are returned. * If the node is a `VariableDeclarator`, all variables declared in the declarator are returned. diff --git a/tests/lib/linter/linter.js b/tests/lib/linter/linter.js index de9097675e21..4d04eb34ddc9 100644 --- a/tests/lib/linter/linter.js +++ b/tests/lib/linter/linter.js @@ -3195,7 +3195,7 @@ describe("Linter", () => { }); }); - describe("when receiving cwd in options in construction", () => { + describe("when receiving cwd in options during instantiation", () => { const code = "a;\nb;"; const config = { rules: { checker: "error" } };