eslint-plugin-perfectionist
Version:
ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
16 lines (15 loc) • 514 B
JavaScript
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
/**
* Computes the name of an array member.
*
* @param props - The parameters object.
* @param props.sourceCode - ESLint source code object for text extraction.
* @param props.node - The AST node representing an array member.
* @returns The name of the array member.
*/
function computeNodeName({ sourceCode, node }) {
return node.type === AST_NODE_TYPES.Literal ?
`${node.value}`
: sourceCode.getText(node)
}
export { computeNodeName }