eslint-plugin-vue
Version:
Official ESLint plugin for Vue.js
99 lines (96 loc) • 3.32 kB
JavaScript
;
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
//#region lib/utils/indent-utils.js
var require_indent_utils = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports, module) => {
/**
* Check whether the given token is a wildcard.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is a wildcard.
*/
function isWildcard(token) {
return token != null && token.type === "Punctuator" && token.value === "*";
}
/**
* Check whether the given token is a question.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is a question.
*/
function isQuestion(token) {
return token != null && token.type === "Punctuator" && token.value === "?";
}
/**
* Check whether the given token is an extends keyword.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is an extends keywordn.
*/
function isExtendsKeyword(token) {
return token != null && token.type === "Keyword" && token.value === "extends";
}
/**
* Check whether the given token is a whitespace.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is a whitespace.
*/
function isNotWhitespace(token) {
return token != null && token.type !== "HTMLWhitespace" && (token.type !== "JSXText" || !!token.value.trim());
}
/**
* Check whether the given token is a comment.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is a comment.
*/
function isComment(token) {
return token != null && (token.type === "Block" || token.type === "Line" || token.type === "Shebang" || typeof token.type === "string" && token.type.endsWith("Comment"));
}
/**
* Check whether the given token is a comment.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `false` if the token is a comment.
*/
function isNotComment(token) {
return token != null && token.type !== "Block" && token.type !== "Line" && token.type !== "Shebang" && !(typeof token.type === "string" && token.type.endsWith("Comment"));
}
/**
* Check whether the given node is not an empty text node.
* @param {ASTNode} node The node to check.
* @returns {boolean} `false` if the token is empty text node.
*/
function isNotEmptyTextNode(node) {
return !(node.type === "VText" && node.value.trim() === "");
}
/**
* Check whether the given token is a pipe operator.
* @param {Token|undefined|null} token The token to check.
* @returns {boolean} `true` if the token is a pipe operator.
*/
function isPipeOperator(token) {
return token != null && token.type === "Punctuator" && token.value === "|";
}
/**
* Get the last element.
* @template T
* @param {T[]} xs The array to get the last element.
* @returns {T | undefined} The last element or undefined.
*/
function last(xs) {
return xs.length === 0 ? void 0 : xs.at(-1);
}
module.exports = {
isWildcard,
isQuestion,
isExtendsKeyword,
isNotWhitespace,
isComment,
isNotComment,
isNotEmptyTextNode,
isPipeOperator,
last
};
}));
//#endregion
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function () {
return require_indent_utils();
}
});