云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
sync
/
react
/
cockpit-modbus
/
node_modules
/
eslint-compat-utils
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
dist
2025-08-13 14:04:43
46.54 KB
LICENSE
2025-04-30 13:33:19
1.04 KB
package.json
2025-04-30 13:33:21
2.91 KB
README.md
2025-04-30 13:33:21
1.36 KB
# eslint-compat-utils ***This package is still in the experimental stage.*** Provides an API for ESLint custom rules that is compatible with the latest ESLint even when using older ESLint. ## Installation ```bash npm install eslint-compat-utils ``` ## Usage ```js const { getSourceCode } = require("eslint-compat-utils"); module.exports = { meta: { /* ... */ }, create(context) { const sourceCode = getSourceCode(context) return { "Program"(node) { const scope = sourceCode.getScope(node); }, }; }, } ``` ### API #### `getSourceCode(context)` Returns an extended instance of `context.sourceCode` or the result of `context.getSourceCode()`. Extended instances can use new APIs such as `getScope(node)` even with old ESLint. #### `getCwd(context)` Gets the value of `context.cwd`, but for older ESLint it returns the result of `context.getCwd()`. Versions older than v6.6.0 return a value from the result of `process.cwd()`. #### `getFilename(context)` Gets the value of `context.filename`, but for older ESLint it returns the result of `context.getFilename()`. #### `getPhysicalFilename(context)` Gets the value of `context.physicalFilename`, but for older ESLint it returns the result of `context.getPhysicalFilename()`. Versions older than v7.28.0 return a value guessed from the result of `context.getFilename()`, but it may be incorrect.
2025-08-30 09:32:32 Saturday 216.73.216.107 Runningtime:0.04s Mem:1.48 MB