Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-codemod-utils

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-codemod-utils - npm Package Compare versions

Comparing version 1.8.6 to 1.8.7

dist/cjs/__fixtures__/program.d.ts

2

dist/cjs/__tests__/program.test.js

@@ -7,3 +7,3 @@ "use strict";

const __1 = require("..");
const program_1 = __importDefault(require("./__fixtures__/program"));
const program_1 = __importDefault(require("../__fixtures__/program"));
describe('program', () => {

@@ -10,0 +10,0 @@ test('basic', () => {

@@ -69,2 +69,20 @@ "use strict";

});
test('parsed ts type query', () => {
const { body } = espree.parse(`type X = 'hello'\ntype Y = typeof X`, ESPREE_OPTIONS);
expect((0, __1.node)(body[0]).toString()).eq(`type X = 'hello'`);
expect((0, __1.node)(body[1]).toString()).eq(`type Y = typeof X`);
});
test('parsed ts type operator', () => {
const { body } = espree.parse(`type X = 'hello'\ntype Y = keyof typeof X`, ESPREE_OPTIONS);
expect((0, __1.node)(body[0]).toString()).eq(`type X = 'hello'`);
expect((0, __1.node)(body[1]).toString()).eq(`type Y = keyof typeof X`);
});
test('type alias declaration (keyword)', () => {
const { body } = espree.parse(`type X = string`, ESPREE_OPTIONS);
expect((0, __1.node)(body[0]).toString()).eq(`type X = string`);
});
test('type alias declaration (literal)', () => {
const { body } = espree.parse(`type X = 'hello'`, ESPREE_OPTIONS);
expect((0, __1.node)(body[0]).toString()).eq(`type X = 'hello'`);
});
test('parsed ts union & intersection types with generic', () => {

@@ -71,0 +89,0 @@ const { body } = espree.parse(`type X<T> = 'hello' | 'thing' & 8`, ESPREE_OPTIONS);

@@ -126,2 +126,4 @@ "use strict";

TSUnionType: ts_nodes_1.tsUnionType,
TSTypeQuery: ts_nodes_1.tsTypeQuery,
TSTypeOperator: ts_nodes_1.tsTypeOperator,
TSTypeAliasDeclaration: ts_nodes_1.tsTypeAliasDeclaration,

@@ -128,0 +130,0 @@ TSTypeParameterDeclaration: ts_nodes_1.tsTypeParameterDeclaration,

@@ -73,2 +73,22 @@ import { TSESTree } from '@typescript-eslint/types';

/**
* __TSTypeOperator__
*
* @example
* ```
* type X = 'hello'
* type Y = typeof X
* ^^^^^^^^
* ```
*/
export declare const tsTypeOperator: StringableASTNodeFn<TSESTree.TSTypeOperator>;
/**
* __TSTypeQuery__
*
* @example
* ```
* type X = typeof 'hello'
* ```
*/
export declare const tsTypeQuery: StringableASTNodeFn<TSESTree.TSTypeQuery>;
/**
* FIXME Implementation does not meet spec

@@ -75,0 +95,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsIntersectionType = exports.tsUnionType = exports.tsTypeAliasDeclaration = exports.tsNonNullExpression = exports.tsLiteralType = exports.tsTypeParameter = exports.tsTypeParameterDeclaration = exports.tsTypeParameterInstantiation = exports.tsQualifiedName = exports.tsEmptyBodyFunctionExpression = exports.tsReadonlyKeyword = exports.tsBooleanKeyword = exports.tsUnknownKeyword = exports.tsNullKeyword = exports.tsTypeReference = exports.tsAnyKeyword = exports.tsStringKeyword = exports.tsAsExpression = void 0;
exports.tsIntersectionType = exports.tsUnionType = exports.tsTypeAliasDeclaration = exports.tsNonNullExpression = exports.tsLiteralType = exports.tsTypeParameter = exports.tsTypeQuery = exports.tsTypeOperator = exports.tsTypeParameterDeclaration = exports.tsTypeParameterInstantiation = exports.tsQualifiedName = exports.tsEmptyBodyFunctionExpression = exports.tsReadonlyKeyword = exports.tsBooleanKeyword = exports.tsUnknownKeyword = exports.tsNullKeyword = exports.tsTypeReference = exports.tsAnyKeyword = exports.tsStringKeyword = exports.tsAsExpression = void 0;
const types_1 = require("@typescript-eslint/types");

@@ -169,2 +169,40 @@ const node_1 = require("./utils/node");

/**
* __TSTypeOperator__
*
* @example
* ```
* type X = 'hello'
* type Y = typeof X
* ^^^^^^^^
* ```
*/
const tsTypeOperator = ({ typeAnnotation, operator, ...other }) => {
return {
...other,
typeAnnotation,
operator,
type: types_1.AST_NODE_TYPES.TSTypeOperator,
toString: () => `${operator}${typeAnnotation ? ` ${(0, node_1.node)(typeAnnotation)}` : ''}`,
};
};
exports.tsTypeOperator = tsTypeOperator;
/**
* __TSTypeQuery__
*
* @example
* ```
* type X = typeof 'hello'
* ```
*/
const tsTypeQuery = ({ exprName, typeParameters, ...other }) => {
return {
...other,
typeParameters,
exprName,
type: types_1.AST_NODE_TYPES.TSTypeQuery,
toString: () => `typeof ${(0, node_1.node)(exprName)}${typeParameters ? (0, node_1.node)(typeParameters) : ''}`,
};
};
exports.tsTypeQuery = tsTypeQuery;
/**
* FIXME Implementation does not meet spec

@@ -174,4 +212,4 @@ */

return {
...other,
name,
...other,
type: types_1.AST_NODE_TYPES.TSTypeParameter,

@@ -215,3 +253,3 @@ toString: () => `${(0, node_1.node)(name)}`,

*/
const tsTypeAliasDeclaration = ({ id, typeAnnotation, typeParameters, ...other }) => {
const tsTypeAliasDeclaration = ({ id, typeAnnotation, typeParameters, declare, ...other }) => {
return {

@@ -221,5 +259,6 @@ id,

typeParameters,
declare,
...other,
type: types_1.AST_NODE_TYPES.TSTypeAliasDeclaration,
toString: () => `type ${(0, node_1.node)(id)}${typeParameters ? `${(0, node_1.node)(typeParameters)}` : ''} = ${(0, node_1.node)(typeAnnotation)}`,
toString: () => `${declare ? 'declare ' : ''}type ${(0, node_1.node)(id)}${typeParameters ? `${(0, node_1.node)(typeParameters)}` : ''} = ${(0, node_1.node)(typeAnnotation)}`,
};

@@ -226,0 +265,0 @@ };

import { jsxAttribute, jsxClosingElement, jsxClosingFragment, jsxElement, jsxEmptyExpression, jsxExpressionContainer, jsxFragment, jsxIdentifier, jsxMemberExpression, jsxOpeningElement, jsxOpeningFragment, jsxSpreadAttribute, jsxSpreadChild, jsxText, } from './jsx-nodes';
import { arrayExpression, arrayPattern, arrowFunctionExpression, assignmentExpression, awaitExpression, binaryExpression, blockStatement, breakStatement, callExpression, catchClause, chainExpression, classBody, classDeclaration, classExpression, conditionalExpression, continueStatement, debuggerStatement, doWhileStatement, emptyStatement, exportAllDeclaration, exportDefaultDeclaration, exportNamedDeclaration, exportSpecifier, expressionStatement, forInStatement, forOfStatement, forStatement, functionDeclaration, functionExpression, identifier, ifStatement, importDeclaration, importDefaultSpecifier, importExpression, importNamespaceSpecifier, importSpecifier, literal, logicalExpression, memberExpression, methodDefinition, newExpression, objectExpression, objectPattern, program, property, propertyDefinition, restElement, returnStatement, sequenceExpression, spreadElement, staticBlock, superCallExpression, switchCase, switchStatement, taggedTemplateExpression, templateElement, templateLiteral, thisExpression, throwStatement, tryStatement, unaryExpression, updateExpression, variableDeclaration, variableDeclarator, whileStatement, withStatement, yieldExpression, } from './nodes';
import { tsAnyKeyword, tsAsExpression, tsBooleanKeyword, tsEmptyBodyFunctionExpression, tsIntersectionType, tsLiteralType, tsNonNullExpression, tsNullKeyword, tsQualifiedName, tsReadonlyKeyword, tsStringKeyword, tsTypeAliasDeclaration, tsTypeParameter, tsTypeParameterDeclaration, tsTypeParameterInstantiation, tsTypeReference, tsUnionType, tsUnknownKeyword, } from './ts-nodes';
import { tsAnyKeyword, tsAsExpression, tsBooleanKeyword, tsEmptyBodyFunctionExpression, tsIntersectionType, tsLiteralType, tsNonNullExpression, tsNullKeyword, tsQualifiedName, tsReadonlyKeyword, tsStringKeyword, tsTypeAliasDeclaration, tsTypeOperator, tsTypeParameter, tsTypeParameterDeclaration, tsTypeParameterInstantiation, tsTypeQuery, tsTypeReference, tsUnionType, tsUnknownKeyword, } from './ts-nodes';
import { identity } from './utils/identity';

@@ -123,2 +123,4 @@ export const DEFAULT_WHITESPACE = '\n ';

TSUnionType: tsUnionType,
TSTypeQuery: tsTypeQuery,
TSTypeOperator: tsTypeOperator,
TSTypeAliasDeclaration: tsTypeAliasDeclaration,

@@ -125,0 +127,0 @@ TSTypeParameterDeclaration: tsTypeParameterDeclaration,

@@ -73,2 +73,22 @@ import { TSESTree } from '@typescript-eslint/types';

/**
* __TSTypeOperator__
*
* @example
* ```
* type X = 'hello'
* type Y = typeof X
* ^^^^^^^^
* ```
*/
export declare const tsTypeOperator: StringableASTNodeFn<TSESTree.TSTypeOperator>;
/**
* __TSTypeQuery__
*
* @example
* ```
* type X = typeof 'hello'
* ```
*/
export declare const tsTypeQuery: StringableASTNodeFn<TSESTree.TSTypeQuery>;
/**
* FIXME Implementation does not meet spec

@@ -75,0 +95,0 @@ */

@@ -154,2 +154,38 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';

/**
* __TSTypeOperator__
*
* @example
* ```
* type X = 'hello'
* type Y = typeof X
* ^^^^^^^^
* ```
*/
export const tsTypeOperator = ({ typeAnnotation, operator, ...other }) => {
return {
...other,
typeAnnotation,
operator,
type: AST_NODE_TYPES.TSTypeOperator,
toString: () => `${operator}${typeAnnotation ? ` ${node(typeAnnotation)}` : ''}`,
};
};
/**
* __TSTypeQuery__
*
* @example
* ```
* type X = typeof 'hello'
* ```
*/
export const tsTypeQuery = ({ exprName, typeParameters, ...other }) => {
return {
...other,
typeParameters,
exprName,
type: AST_NODE_TYPES.TSTypeQuery,
toString: () => `typeof ${node(exprName)}${typeParameters ? node(typeParameters) : ''}`,
};
};
/**
* FIXME Implementation does not meet spec

@@ -159,4 +195,4 @@ */

return {
...other,
name,
...other,
type: AST_NODE_TYPES.TSTypeParameter,

@@ -197,3 +233,3 @@ toString: () => `${node(name)}`,

*/
export const tsTypeAliasDeclaration = ({ id, typeAnnotation, typeParameters, ...other }) => {
export const tsTypeAliasDeclaration = ({ id, typeAnnotation, typeParameters, declare, ...other }) => {
return {

@@ -203,5 +239,6 @@ id,

typeParameters,
declare,
...other,
type: AST_NODE_TYPES.TSTypeAliasDeclaration,
toString: () => `type ${node(id)}${typeParameters ? `${node(typeParameters)}` : ''} = ${node(typeAnnotation)}`,
toString: () => `${declare ? 'declare ' : ''}type ${node(id)}${typeParameters ? `${node(typeParameters)}` : ''} = ${node(typeAnnotation)}`,
};

@@ -208,0 +245,0 @@ };

{
"name": "eslint-codemod-utils",
"version": "1.8.6",
"version": "1.8.7",
"description": "A collection of AST helper functions for more complex ESLint rule fixes.",

@@ -5,0 +5,0 @@ "author": "Alex Hinds",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc