@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
54 lines (53 loc) • 2.32 kB
TypeScript
import type { Rule } from 'eslint';
import { type ObjectExpression, type Property, type SpreadElement } from 'eslint-codemod-utils';
declare const ASTObjectExpression: {
/**
* Returns `true` if an object contains a property with the specified name, `false` otherwise.
*/
hasProperty(node: ObjectExpression, name: string): boolean;
/**
* Returns true if an object contains no nested values, false otherwise.
*
* Note:
* - Returns false if object contains spread elements.
* - Returns true if object is empty.
*/
isFlat(node: ObjectExpression): boolean;
/**
* Returns the first Property node from an Object that matches the provided name.
*/
getEntryByPropertyName(node: ObjectExpression, name: string): Property | undefined;
deleteEntry(node: ObjectExpression, name: string, fixer: Rule.RuleFixer): Rule.Fix[];
/**
* Returns only the property @type {Property['key']} like: `padding` from: `{ padding: '8px' }`.
* If you want the key/value pair, use `getEntryByPropertyName`.
*/
getProperty(node: ObjectExpression, name: string): Property['key'] | undefined;
/**
* Gets the array of key/value pairs in an ObjectExpression.
*/
getEntries(node: ObjectExpression): (Property | SpreadElement)[];
/**
* Returns a only the property @type {Property['value']} like: `'8px` from: `{ padding: '8px' }`.
*
* Values can be basically anything, so be careful with this.
*/
getValueByPropertyName(node: ObjectExpression, name: string): Property['value'] | undefined;
containsSpreadProps(node: ObjectExpression): boolean;
updateValue(node: ObjectExpression, propertyName: string, newValue: string, fixer: Rule.RuleFixer): Rule.Fix;
/**
* Appends a key-value pair to the end of an object. For example:
* ```
* ast.Object.appendEntry(
* node, // { padding: 'space.100' }
* key, // 'margin',
* value, // 'space.200'
* fixer,
* )
* ```
* Will result in `{ padding: 'space.100', margin: 'space.200'}`.
*/
appendEntry(node: ObjectExpression, key: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
recurse(node: ObjectExpression, callback: Function): void;
};
export { ASTObjectExpression as Object };