Skip to content

Commit

Permalink
v1.0.89
Browse files Browse the repository at this point in the history
Add new rule
  • Loading branch information
eliottvincent committed Jul 4, 2024
1 parent adc136b commit b13e64d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Each item has emojis denoting:
| [crisp/vue-no-regex-data](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/vue-no-regex-data.js) | Disallows regular expressions to be declared in Vue data object | | 🟢 |
| [crisp/vue-props-declaration-multiline](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/vue-props-declaration-multiline.js) | Enforces props declarations to be multiline | | 🟢 |
| [crisp/vue-props-declaration-order](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/vue-props-declaration-order.js) | Ensures props declarations are alphabetically ordered | | 🟢 |
| [crisp/vue-ref-case](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/vue-ref-case.js) | Enforces `ref` attributes to snake case | | 🟢 |

## License

Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = {
"vue-html-indent": require("./rules/vue-html-indent"),
"vue-html-quotes": require("./rules/vue-html-quotes"),
"vue-no-regex-data": require("./rules/vue-no-regex-data"),
"vue-props-declaration-multiline": require("./rules/vue-props-declaration-multiline"),
"vue-props-declaration-order": require("./rules/vue-props-declaration-order"),
"vue-props-declaration-multiline": require("./rules/vue-props-declaration-multiline")
"vue-ref-case": require("./rules/vue-ref-case")
}
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-crisp",
"version": "1.0.88",
"version": "1.0.89",
"description": "Custom ESLint Rules for Crisp",
"author": "Crisp IM SAS",
"main": "index.js",
Expand Down
3 changes: 2 additions & 1 deletion recommended-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ module.exports = {
"crisp/vue-html-quotes": "error",
"crisp/vue-no-regex-data": "error",
"crisp/vue-props-declaration-multiline": "error",
"crisp/vue-props-declaration-order": "error"
"crisp/vue-props-declaration-order": "error",
"crisp/vue-ref-case": "error"
}
}
29 changes: 29 additions & 0 deletions rules/vue-ref-case.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
meta: {
type: "layout",
docs: {
description: "enforce ref attributes to be snake-cased",
category: "Stylistic Issues",
recommended: false,
},
fixable: null
},

create(context) {
return context.parserServices.defineTemplateBodyVisitor({
"VAttribute[directive=false][key.name='ref']"(node) {
const refValue = node.value && node.value.value;

if (refValue && !/^[a-z]+(_[a-z]+)*$/.test(refValue)) {
context.report({
node,
message: "Ref attribute \"{{refValue}}\" should be snake-cased.",
data: {
refValue,
},
});
}
}
})
}
};

0 comments on commit b13e64d

Please sign in to comment.