Skip to content

Commit

Permalink
feat: use @eslint-community dependencies (#6603)
Browse files Browse the repository at this point in the history
  • Loading branch information
oceandrama committed Mar 13, 2023
1 parent 133a10c commit 5f6ed73
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/architecture/Utils.mdx
Expand Up @@ -19,7 +19,7 @@ Any custom rules you write generally will be as well.
| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AST_NODE_TYPES` | An enum with the names of every single _node_ found in `TSESTree`. |
| `AST_TOKEN_TYPES` | An enum with the names of every single _token_ found in `TSESTree`. |
| `ASTUtils` | Tools for operating on the ESTree AST. Also includes the [`eslint-utils`](https://www.npmjs.com/package/eslint-utils) package, correctly typed to work with the types found in `TSESTree` |
| `ASTUtils` | Tools for operating on the ESTree AST. Also includes the [`@eslint-community/eslint-utils`](https://www.npmjs.com/package/@eslint-community/eslint-utils) package, correctly typed to work with the types found in `TSESTree` |
| `ESLintUtils` | Tools for creating ESLint rules with TypeScript. |
| `JSONSchema` | Types from the [`@types/json-schema`](https://www.npmjs.com/package/@types/json-schema) package, re-exported to save you having to manually import them. Also ensures you're using the same version of the types as this package. |
| `ParserServices` | Typing for the parser services provided when parsing a file using `@typescript-eslint/typescript-estree`. |
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Expand Up @@ -44,14 +44,14 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.54.1",
"@typescript-eslint/type-utils": "5.54.1",
"@typescript-eslint/utils": "5.54.1",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"natural-compare-lite": "^1.4.0",
"regexpp": "^3.2.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/prefer-includes.ts
@@ -1,7 +1,7 @@
import type { AST as RegExpAST } from '@eslint-community/regexpp';
import { parseRegExpLiteral } from '@eslint-community/regexpp';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
import type { AST as RegExpAST } from 'regexpp';
import { parseRegExpLiteral } from 'regexpp';
import * as ts from 'typescript';

import {
Expand Down
@@ -1,7 +1,7 @@
import type { AST as RegExpAST } from '@eslint-community/regexpp';
import { RegExpParser } from '@eslint-community/regexpp';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
import type { AST as RegExpAST } from 'regexpp';
import { RegExpParser } from 'regexpp';

import {
createRule,
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Expand Up @@ -39,13 +39,13 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.54.1",
"@typescript-eslint/types": "5.54.1",
"@typescript-eslint/typescript-estree": "5.54.1",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0",
"semver": "^7.3.7"
},
"peerDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/utils/src/ast-utils/eslint-utils/PatternMatcher.ts
@@ -1,24 +1,24 @@
import * as eslintUtils from 'eslint-utils';
import * as eslintUtils from '@eslint-community/eslint-utils';

interface PatternMatcher {
/**
* Iterate all matched parts in a given string.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-execall}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-execall}
*/
execAll(str: string): IterableIterator<RegExpExecArray>;

/**
* Check whether this pattern matches a given string or not.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-test}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-test}
*/
test(str: string): boolean;

/**
* Replace all matched parts by a given replacer.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-symbol-replace}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#matcher-symbol-replace}
* @example
* const { PatternMatcher } = require("eslint-utils")
* const matcher = new PatternMatcher(/\\p{Script=Greek}/g)
Expand Down Expand Up @@ -47,7 +47,7 @@ interface PatternMatcher {
* The class to find a pattern in strings as handling escape sequences.
* It ignores the found pattern if it's escaped with `\`.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#patternmatcher-class}
*/
const PatternMatcher = eslintUtils.PatternMatcher as {
new (pattern: RegExp, options?: { escaped?: boolean }): PatternMatcher;
Expand Down
10 changes: 5 additions & 5 deletions packages/utils/src/ast-utils/eslint-utils/ReferenceTracker.ts
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-namespace */
import * as eslintUtils from 'eslint-utils';
import * as eslintUtils from '@eslint-community/eslint-utils';

import type * as TSESLint from '../../ts-eslint';
import type { TSESTree } from '../../ts-estree';
Expand All @@ -15,7 +15,7 @@ interface ReferenceTracker {
* Iterate the references that the given `traceMap` determined.
* This method starts to search from global variables.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateglobalreferences}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateglobalreferences}
*/
iterateGlobalReferences<T>(
traceMap: ReferenceTracker.TraceMap<T>,
Expand All @@ -25,7 +25,7 @@ interface ReferenceTracker {
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `require()` expression.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iteratecjsreferences}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iteratecjsreferences}
*/
iterateCjsReferences<T>(
traceMap: ReferenceTracker.TraceMap<T>,
Expand All @@ -35,7 +35,7 @@ interface ReferenceTracker {
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `import`/`export` declarations.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateesmreferences}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#tracker-iterateesmreferences}
*/
iterateEsmReferences<T>(
traceMap: ReferenceTracker.TraceMap<T>,
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace ReferenceTracker {
/**
* The tracker for references. This provides reference tracking for global variables, CommonJS modules, and ES modules.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#referencetracker-class}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class}
*/
const ReferenceTracker = eslintUtils.ReferenceTracker as ReferenceTrackerStatic;

Expand Down
16 changes: 8 additions & 8 deletions packages/utils/src/ast-utils/eslint-utils/astUtilities.ts
@@ -1,12 +1,12 @@
import * as eslintUtils from 'eslint-utils';
import * as eslintUtils from '@eslint-community/eslint-utils';

import type * as TSESLint from '../../ts-eslint';
import type { TSESTree } from '../../ts-estree';

/**
* Get the proper location of a given function node to report.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionheadlocation}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getfunctionheadlocation}
*/
const getFunctionHeadLocation = eslintUtils.getFunctionHeadLocation as (
node:
Expand All @@ -19,7 +19,7 @@ const getFunctionHeadLocation = eslintUtils.getFunctionHeadLocation as (
/**
* Get the name and kind of a given function node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionnamewithkind}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getfunctionnamewithkind}
*/
const getFunctionNameWithKind = eslintUtils.getFunctionNameWithKind as (
node:
Expand All @@ -33,7 +33,7 @@ const getFunctionNameWithKind = eslintUtils.getFunctionNameWithKind as (
* Get the property name of a given property node.
* If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getpropertyname}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getpropertyname}
* @returns The property name of the node. If the property name is not constant then it returns `null`.
*/
const getPropertyName = eslintUtils.getPropertyName as (
Expand All @@ -52,7 +52,7 @@ const getPropertyName = eslintUtils.getPropertyName as (
* not been modified.
* For example, it considers `Symbol.iterator`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue}
* @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
* static value of the node, it returns `null`.
*/
Expand All @@ -65,7 +65,7 @@ const getStaticValue = eslintUtils.getStaticValue as (
* Get the string value of a given node.
* This function is a tiny wrapper of the getStaticValue function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstringifconstant}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstringifconstant}
*/
const getStringIfConstant = eslintUtils.getStringIfConstant as (
node: TSESTree.Node,
Expand Down Expand Up @@ -93,7 +93,7 @@ const getStringIfConstant = eslintUtils.getStringIfConstant as (
* - `Property([computed = true])`
* - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#hassideeffect}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#hassideeffect}
*/
const hasSideEffect = eslintUtils.hasSideEffect as (
node: TSESTree.Node,
Expand All @@ -109,7 +109,7 @@ const isParenthesized = eslintUtils.isParenthesized as {
* Check whether a given node is parenthesized or not.
* This function detects it correctly even if it's parenthesized by specific syntax.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#isparenthesized}
* @see {@link https://eslint-community.github.io/eslint-utils/api/ast-utils.html#isparenthesized}
* @returns `true` if the node is parenthesized.
* If `times` was given, it returns `true` only if the node is parenthesized the `times` times.
* For example, `isParenthesized(2, node, sourceCode)` returns true for `((foo))`, but not for `(foo)`.
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/ast-utils/eslint-utils/predicates.ts
@@ -1,4 +1,4 @@
import * as eslintUtils from 'eslint-utils';
import * as eslintUtils from '@eslint-community/eslint-utils';

import type { TSESTree } from '../../ts-estree';

Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/ast-utils/eslint-utils/scopeAnalysis.ts
@@ -1,12 +1,12 @@
import * as eslintUtils from 'eslint-utils';
import * as eslintUtils from '@eslint-community/eslint-utils';

import type * as TSESLint from '../../ts-eslint';
import type { TSESTree } from '../../ts-estree';

/**
* Get the variable of a given name.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#findvariable}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#findvariable}
*/
const findVariable = eslintUtils.findVariable as (
initialScope: TSESLint.Scope.Scope,
Expand All @@ -16,7 +16,7 @@ const findVariable = eslintUtils.findVariable as (
/**
* Get the innermost scope which contains a given node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#getinnermostscope}
* @see {@link https://eslint-community.github.io/eslint-utils/api/scope-utils.html#getinnermostscope}
* @returns The innermost scope which contains the given node.
* If such scope doesn't exist then it returns the 1st argument `initialScope`.
*/
Expand Down
@@ -1,4 +1,4 @@
declare module 'eslint-utils' {
declare module '@eslint-community/eslint-utils' {
export const findVariable: unknown;
export const getFunctionHeadLocation: unknown;
export const getFunctionNameWithKind: unknown;
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Expand Up @@ -2007,6 +2007,18 @@
dependencies:
eslint-visitor-keys "^3.3.0"

"@eslint-community/eslint-utils@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.2.0.tgz#a831e6e468b4b2b5ae42bf658bea015bf10bc518"
integrity sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==
dependencies:
eslint-visitor-keys "^3.3.0"

"@eslint-community/regexpp@^4.4.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.4.0.tgz#3e61c564fcd6b921cb789838631c5ee44df09403"
integrity sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ==

"@eslint/eslintrc@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.3.tgz#fcaa2bcef39e13d6e9e7f6271f4cc7cae1174886"
Expand Down

0 comments on commit 5f6ed73

Please sign in to comment.