diff --git a/docs/src/developer-guide/working-with-rules.md b/docs/src/developer-guide/working-with-rules.md index eef6d38c8c1b..73b45e25c69c 100644 --- a/docs/src/developer-guide/working-with-rules.md +++ b/docs/src/developer-guide/working-with-rules.md @@ -163,7 +163,7 @@ Additionally, the `context` object has the following methods: This method returns the scope of the current node. It is a useful method for finding information about the variables in a given scope, and how they are used in other scopes. -#### Scope Types +#### Scope types The following table contains a list of AST node types and the scope type that they correspond to. For more information about the scope types, refer to the [`Scope` object documentation](./scope-manager-interface.md#scope-interface). @@ -203,6 +203,12 @@ Global variables have the following additional properties: * `Variable.eslintExplicitGlobalComments` (`Comment[] | undefined`) ... The array of `/* globals */` directive comments which defined this global variable in the source code file. This property is `undefined` if there are no `/* globals */` directive comments. * `Variable.eslintImplicitGlobalSetting` (`"readonly" | "writable" | undefined`) ... The configured value in config files. This can be different from `variable.writeable` if there are `/* globals */` directive comments. +For examples of using `context.getScope()` to track variables, refer to the source code for the following built-in rules: + +* [camelcase](https://github.com/eslint/eslint/blob/main/lib/rules/camelcase.js) +* [no-alert](https://github.com/eslint/eslint/blob/main/lib/rules/no-alert.js) +* [no-console](https://github.com/eslint/eslint/blob/main/lib/rules/no-console.js) + ### context.report() The main method you'll use is `context.report()`, which publishes a warning or error (depending on the configuration being used). This method accepts a single argument, which is an object containing the following properties: