From 3e831f6eae6c8338145a5a2f9246a305ed811370 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sun, 27 May 2018 17:41:00 +0900 Subject: [PATCH] Docs: update README.md --- README.md | 62 +++++-------------------------------------------------- 1 file changed, 5 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 1110707..7069f04 100644 --- a/README.md +++ b/README.md @@ -10,67 +10,15 @@ This package provides utility functions and classes for make ESLint custom rules. -For example, there is the class which tracks variable references. +For examples: -```js -const { ReferenceTracker } = require("eslint-utils") - -module.exports = { - meta: {}, - create(context) { - return { - "Program:exit"() { - const tracker = new ReferenceTracker(context.getScope()) - - // Track the references of global variables. - for (const { node, path } of tracker.iterateGlobalReferences({ - // Iterate the call expressions of `console.log`, `console.info` - console: { - log: { [ReferenceTracker.CALL]: true }, - info: { [ReferenceTracker.CALL]: true }, - }, - })) { - context.report({ - node, - message: "Don't use {{name}}.", - data: { name: path.join(".") }, - }) - } - - // Track the references of CommonJS modules. - for (const { node, path } of tracker.iterateCjsReferences({ - // Iterate the access of `fs.exists`. - fs: { - exists: { [ReferenceTracker.READ]: true }, - }, - })) { - context.report({ - node, - message: "Don't use {{name}}.", - data: { name: path.join(".") }, - }) - } - } - } - }, -} -``` - -## 💿 Installation - -Use [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/). - -``` -npm install eslint-utils -``` - -### Requirements - -- Node.js `6.5.0` or newer. +- [getStaticValue](https://mysticatea.github.io/eslint-utils/api/ast-utils.html#getstaticvalue) evaluates static value on AST. +- [PatternMatcher](https://mysticatea.github.io/eslint-utils/api/ast-utils.html#patternmatcher-class) finds a regular expression pattern as handling escape sequences. +- [ReferenceTracker](https://mysticatea.github.io/eslint-utils/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring. ## 📖 Usage -See [API reference](https://mysticatea.github.io/eslint-utils/). +See [documentation](https://mysticatea.github.io/eslint-utils/). ## 📰 Changelog