eslint-codemod-utils
Advanced tools
Comparing version 1.8.5 to 1.8.6
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -184,2 +188,5 @@ if (k2 === undefined) k2 = k; | ||
}); | ||
test('via the parser', () => { | ||
expect((0, __1.node)(espree.parse(`const y = {\nhello: 'world',\n [thing]: 'bro',\n [thing]() {},\n [thing]: () => {},\n get x() {}\n}`, ESPREE_OPTIONS).body[0]).toString()).eq(`const y = {\n hello: 'world',\n [thing]: 'bro',\n [thing]: function () {},\n [thing]: () => {},\n get x() {}\n}`); | ||
}); | ||
}); | ||
@@ -186,0 +193,0 @@ describe('memberExpression', () => { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
import * as ESTree from 'estree-jsx'; | ||
import type { StringableASTNode, StringableASTNodeFn, WithoutType } from './types'; | ||
export declare const whiteSpace: (loc?: ESTree.SourceLocation | undefined) => string; | ||
export declare const whiteSpace: (loc?: ESTree.SourceLocation) => string; | ||
export declare const comments: (comments?: ESTree.Comment[]) => { | ||
@@ -5,0 +5,0 @@ comments: ESTree.Comment[]; |
@@ -377,3 +377,3 @@ import { TSESTree } from '@typescript-eslint/types'; | ||
export declare const functionDeclaration: StringableASTNodeFn<ESTree.FunctionDeclaration, 'generator' | 'async'>; | ||
export declare const methodOrPropertyFn: (fn: ESTree.FunctionExpression) => string; | ||
export declare const methodOrPropertyFn: ({ params, body, }: ESTree.FunctionExpression) => string; | ||
export declare const methodDefinition: StringableASTNodeFn<ESTree.MethodDefinition>; | ||
@@ -380,0 +380,0 @@ export declare const propertyDefinition: StringableASTNodeFn<ESTree.PropertyDefinition>; |
@@ -573,5 +573,4 @@ "use strict"; | ||
type: types_1.AST_NODE_TYPES.Property, | ||
toString: () => `${kind === 'init' ? '' : kind + ' '}${(0, node_1.node)(key)}${kind !== 'init' ? '' : ': '}${kind !== 'init' && (0, utils_1.isNodeOfType)(value, 'FunctionExpression') | ||
? // @ts-ignore | ||
(0, exports.methodOrPropertyFn)(value) | ||
toString: () => `${kind === 'init' ? '' : kind + ' '}${computed ? '[' : ''}${(0, node_1.node)(key)}${computed ? ']' : ''}${kind !== 'init' ? '' : ': '}${kind !== 'init' && (0, utils_1.isNodeOfType)(value, 'FunctionExpression') | ||
? (0, exports.methodOrPropertyFn)(value) | ||
: (0, node_1.node)(value)}`, | ||
@@ -1007,4 +1006,4 @@ }; | ||
exports.functionDeclaration = functionDeclaration; | ||
const methodOrPropertyFn = (fn) => { | ||
return `(${fn.params.map(node_1.node).join(', ')}) ${(0, node_1.node)(fn.body)}`; | ||
const methodOrPropertyFn = ({ params, body, }) => { | ||
return `(${params.map(node_1.node).join(', ')}) ${(0, node_1.node)(body)}`; | ||
}; | ||
@@ -1020,3 +1019,3 @@ exports.methodOrPropertyFn = methodOrPropertyFn; | ||
type: types_1.AST_NODE_TYPES.MethodDefinition, | ||
toString: () => `${(0, node_1.node)(key)} ${(0, exports.methodOrPropertyFn)(value)}`, | ||
toString: () => `${computed ? `[${(0, node_1.node)(key)}]` : (0, node_1.node)(key)} ${(0, exports.methodOrPropertyFn)(value)}`, | ||
}; | ||
@@ -1023,0 +1022,0 @@ }; |
import type { Node as ESTreeNode, JSXSpreadChild } from 'estree-jsx'; | ||
import type { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types'; | ||
import type { Rule } from 'eslint'; | ||
export declare type EslintCodemodUtilsBaseNode = ESTreeNode | { | ||
export type EslintCodemodUtilsBaseNode = ESTreeNode | { | ||
type: keyof typeof AST_NODE_TYPES; | ||
} | JSXSpreadChild; | ||
export declare type WithoutType<T extends EslintCodemodUtilsBaseNode> = Omit<T, 'type'>; | ||
export declare type StringableASTNode<T extends EslintCodemodUtilsBaseNode> = T & { | ||
export type WithoutType<T extends EslintCodemodUtilsBaseNode> = Omit<T, 'type'>; | ||
export type StringableASTNode<T extends EslintCodemodUtilsBaseNode> = T & { | ||
toString(): string; | ||
}; | ||
export declare type StringableASTNodeFn<EstreeNodeType extends EslintCodemodUtilsBaseNode, Key extends keyof EstreeNodeType = 'type'> = (node: WithoutType<Key extends 'type' ? EstreeNodeType : Omit<EstreeNodeType, Key> & Pick<Partial<EstreeNodeType>, Key> & { | ||
export type StringableASTNodeFn<EstreeNodeType extends EslintCodemodUtilsBaseNode, Key extends keyof EstreeNodeType = 'type'> = (node: WithoutType<Key extends 'type' ? EstreeNodeType : Omit<EstreeNodeType, Key> & Pick<Partial<EstreeNodeType>, Key> & { | ||
type: any; | ||
}>) => StringableASTNode<EstreeNodeType>; | ||
export declare type EslintNode = EslintCodemodUtilsBaseNode & Partial<Rule.NodeParentExtension>; | ||
export declare type TSEslintNode = EslintCodemodUtilsBaseNode & Pick<TSESTree.BaseNode, 'parent'>; | ||
export type EslintNode = EslintCodemodUtilsBaseNode & Partial<Rule.NodeParentExtension>; | ||
export type TSEslintNode = EslintCodemodUtilsBaseNode & Pick<TSESTree.BaseNode, 'parent'>; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
import type { EslintCodemodUtilsBaseNode, StringableASTNode } from '../types'; | ||
export declare type NodeMap<T extends EslintCodemodUtilsBaseNode = EslintCodemodUtilsBaseNode> = { | ||
export type NodeMap<T extends EslintCodemodUtilsBaseNode = EslintCodemodUtilsBaseNode> = { | ||
[E in T as E['type']]: (eventNodeListener: E) => StringableASTNode<E>; | ||
@@ -4,0 +4,0 @@ }; |
import * as ESTree from 'estree-jsx'; | ||
import type { StringableASTNode, StringableASTNodeFn, WithoutType } from './types'; | ||
export declare const whiteSpace: (loc?: ESTree.SourceLocation | undefined) => string; | ||
export declare const whiteSpace: (loc?: ESTree.SourceLocation) => string; | ||
export declare const comments: (comments?: ESTree.Comment[]) => { | ||
@@ -5,0 +5,0 @@ comments: ESTree.Comment[]; |
@@ -377,3 +377,3 @@ import { TSESTree } from '@typescript-eslint/types'; | ||
export declare const functionDeclaration: StringableASTNodeFn<ESTree.FunctionDeclaration, 'generator' | 'async'>; | ||
export declare const methodOrPropertyFn: (fn: ESTree.FunctionExpression) => string; | ||
export declare const methodOrPropertyFn: ({ params, body, }: ESTree.FunctionExpression) => string; | ||
export declare const methodDefinition: StringableASTNodeFn<ESTree.MethodDefinition>; | ||
@@ -380,0 +380,0 @@ export declare const propertyDefinition: StringableASTNodeFn<ESTree.PropertyDefinition>; |
@@ -539,5 +539,4 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types'; | ||
type: AST_NODE_TYPES.Property, | ||
toString: () => `${kind === 'init' ? '' : kind + ' '}${node(key)}${kind !== 'init' ? '' : ': '}${kind !== 'init' && isNodeOfType(value, 'FunctionExpression') | ||
? // @ts-ignore | ||
methodOrPropertyFn(value) | ||
toString: () => `${kind === 'init' ? '' : kind + ' '}${computed ? '[' : ''}${node(key)}${computed ? ']' : ''}${kind !== 'init' ? '' : ': '}${kind !== 'init' && isNodeOfType(value, 'FunctionExpression') | ||
? methodOrPropertyFn(value) | ||
: node(value)}`, | ||
@@ -940,4 +939,4 @@ }; | ||
}); | ||
export const methodOrPropertyFn = (fn) => { | ||
return `(${fn.params.map(node).join(', ')}) ${node(fn.body)}`; | ||
export const methodOrPropertyFn = ({ params, body, }) => { | ||
return `(${params.map(node).join(', ')}) ${node(body)}`; | ||
}; | ||
@@ -952,3 +951,3 @@ export const methodDefinition = ({ computed, key, kind, value, ...other }) => { | ||
type: AST_NODE_TYPES.MethodDefinition, | ||
toString: () => `${node(key)} ${methodOrPropertyFn(value)}`, | ||
toString: () => `${computed ? `[${node(key)}]` : node(key)} ${methodOrPropertyFn(value)}`, | ||
}; | ||
@@ -955,0 +954,0 @@ }; |
import type { Node as ESTreeNode, JSXSpreadChild } from 'estree-jsx'; | ||
import type { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types'; | ||
import type { Rule } from 'eslint'; | ||
export declare type EslintCodemodUtilsBaseNode = ESTreeNode | { | ||
export type EslintCodemodUtilsBaseNode = ESTreeNode | { | ||
type: keyof typeof AST_NODE_TYPES; | ||
} | JSXSpreadChild; | ||
export declare type WithoutType<T extends EslintCodemodUtilsBaseNode> = Omit<T, 'type'>; | ||
export declare type StringableASTNode<T extends EslintCodemodUtilsBaseNode> = T & { | ||
export type WithoutType<T extends EslintCodemodUtilsBaseNode> = Omit<T, 'type'>; | ||
export type StringableASTNode<T extends EslintCodemodUtilsBaseNode> = T & { | ||
toString(): string; | ||
}; | ||
export declare type StringableASTNodeFn<EstreeNodeType extends EslintCodemodUtilsBaseNode, Key extends keyof EstreeNodeType = 'type'> = (node: WithoutType<Key extends 'type' ? EstreeNodeType : Omit<EstreeNodeType, Key> & Pick<Partial<EstreeNodeType>, Key> & { | ||
export type StringableASTNodeFn<EstreeNodeType extends EslintCodemodUtilsBaseNode, Key extends keyof EstreeNodeType = 'type'> = (node: WithoutType<Key extends 'type' ? EstreeNodeType : Omit<EstreeNodeType, Key> & Pick<Partial<EstreeNodeType>, Key> & { | ||
type: any; | ||
}>) => StringableASTNode<EstreeNodeType>; | ||
export declare type EslintNode = EslintCodemodUtilsBaseNode & Partial<Rule.NodeParentExtension>; | ||
export declare type TSEslintNode = EslintCodemodUtilsBaseNode & Pick<TSESTree.BaseNode, 'parent'>; | ||
export type EslintNode = EslintCodemodUtilsBaseNode & Partial<Rule.NodeParentExtension>; | ||
export type TSEslintNode = EslintCodemodUtilsBaseNode & Pick<TSESTree.BaseNode, 'parent'>; |
import type { EslintCodemodUtilsBaseNode, StringableASTNode } from '../types'; | ||
export declare type NodeMap<T extends EslintCodemodUtilsBaseNode = EslintCodemodUtilsBaseNode> = { | ||
export type NodeMap<T extends EslintCodemodUtilsBaseNode = EslintCodemodUtilsBaseNode> = { | ||
[E in T as E['type']]: (eventNodeListener: E) => StringableASTNode<E>; | ||
@@ -4,0 +4,0 @@ }; |
{ | ||
"name": "eslint-codemod-utils", | ||
"version": "1.8.5", | ||
"version": "1.8.6", | ||
"description": "A collection of AST helper functions for more complex ESLint rule fixes.", | ||
@@ -29,7 +29,7 @@ "author": "Alex Hinds", | ||
"devDependencies": { | ||
"@types/eslint": "^8.4.1", | ||
"@types/node": "^17.0.18", | ||
"@types/eslint": "^8.4.10", | ||
"@types/node": "^18.0.0", | ||
"@typescript-eslint/typescript-estree": "^5.45.0", | ||
"espree": "^9.3.1", | ||
"typescript": "^4.5.5", | ||
"typescript": "^4.9.0", | ||
"vitest": "latest" | ||
@@ -36,0 +36,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
605700
16878