Skip to content

Commit

Permalink
feat!: rename setting class-attr-name
Browse files Browse the repository at this point in the history
  • Loading branch information
levchak0910 committed Mar 30, 2024
1 parent 540cd19 commit 0299a42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ Example **.eslintrc.js**:
```js
module.exports = {
plugins: ['@vkcn'],
settings: { "vkcn/class-attr-name": /custom-reg-exp/ }, // optional
settings: { "@vkcn/class-attr-name": /custom-reg-exp/ }, // optional
rules: {
'@vkcn/<rule-name>': 'error'
}
}
```

By using `settings: { "vkcn/class-attr-name": /custom-reg-exp/ }` it is possible to run rules throughout any attribute/directive which matches regexp. By default only `class` is checked.
By using `settings: { "@vkcn/class-attr-name": /custom-reg-exp/ }` it is possible to run rules throughout any attribute/directive which matches regexp. By default only `class` is checked.

_Please note!_ When using a custom regexp - `class` **must be included** into it

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/class-attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RuleContext } from "../types";
import type { VAttribute, VDirective } from "vue-eslint-parser/ast";

export function getClassAttrNameRegexp(context: RuleContext): RegExp {
const customClassAttrName = context.settings?.["vkcn/class-attr-name"];
const customClassAttrName = context.settings?.["@vkcn/class-attr-name"];

const customClassAttrNameRegexp =
customClassAttrName instanceof RegExp ? customClassAttrName : /^class$/;
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/no-dynamic-class-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const tester = new RuleTester({
ecmaVersion: 2019,
sourceType: "module",
},
settings: { "vkcn/class-attr-name": /(.+-)?class$/ },
settings: { "@vkcn/class-attr-name": /(.+-)?class$/ },
});

type RuleOptions = {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-undefined-class-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ tester.run("no-undefined-class-names", rule as any, {
{
name: "custom attribute names",
filename: "app.vue",
settings: { "vkcn/class-attr-name": /^(bar|baz)$/ },
settings: { "@vkcn/class-attr-name": /^(bar|baz)$/ },
code: html`
<template>
<div bar="app--foo" :baz="'app--foo'"></div>
Expand Down Expand Up @@ -443,7 +443,7 @@ tester.run("no-undefined-class-names", rule as any, {
{
name: "undefined with custom attribute names",
filename: "app.vue",
settings: { "vkcn/class-attr-name": /^(bar|baz)$/ },
settings: { "@vkcn/class-attr-name": /^(bar|baz)$/ },
code: html`
<template>
<div bar="app--foobar" :baz="'app--foobaz'"></div>
Expand Down

0 comments on commit 0299a42

Please sign in to comment.