@nextcloud/eslint-config
Version:
Eslint shared config for nextcloud apps and libraries
40 lines (39 loc) • 1.32 kB
JavaScript
/*!
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { defineTemplateBodyVisitor } from "../utils/vue-template-visitor.js";
const defineRule = (r) => r;
export default defineRule({
meta: {
fixable: 'code',
type: 'suggestion',
schema: [],
docs: {
description: 'Enforce non-breaking spaces before ellipsis',
},
messages: {
precedeWithNonbreakingSpace: 'Ellipsis must be preceded by non-breaking spaces',
},
},
create(context) {
const visitor = {
Literal(node) {
if (typeof node.value !== 'string') {
return;
}
const matches = node.value.match(/(\s+)…/);
if (matches && matches[1] !== ' ') {
context.report({
node,
messageId: 'precedeWithNonbreakingSpace',
fix(fixer) {
return fixer.replaceText(node, node.raw.replaceAll(/\s+…/g, ' …'));
},
});
}
},
};
return defineTemplateBodyVisitor(context, visitor, visitor);
},
});