Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Kai Cataldo <7041728+kaicataldo@users.noreply.github.com>
  • Loading branch information
fa93hws and kaicataldo committed Oct 11, 2019
1 parent 9ac730e commit 04fe96b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions docs/developer-guide/nodejs-api.md
Expand Up @@ -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:

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/developer-guide/working-with-rules.md
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/linter/linter.js
Expand Up @@ -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" } };

Expand Down

0 comments on commit 04fe96b

Please sign in to comment.