Skip to content

Commit fad6532

Browse files
authored
feat: use eslint-compat-utils (#316)
* feat: use eslint-compat-utils * Create rich-goats-notice.md * fix
1 parent 3859204 commit fad6532

29 files changed

+241
-74
lines changed

.changeset/rich-goats-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-vue-scoped-css": minor
3+
---
4+
5+
feat: use eslint-compat-utils

.eslintrc.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,55 @@ module.exports = {
2323
"@typescript-eslint/ban-ts-ignore": "off",
2424
"eslint-comments/no-unused-disable": "error",
2525
"@typescript-eslint/no-non-null-assertion": "off",
26+
// Repo rule
27+
"@typescript-eslint/no-restricted-imports": [
28+
"error",
29+
{
30+
patterns: [
31+
{
32+
group: ["/regexpp", "/regexpp/*"],
33+
message: "Please use `@eslint-community/regexpp` instead.",
34+
},
35+
{
36+
group: ["/eslint-utils", "/eslint-utils/*"],
37+
message: "Please use `@eslint-community/eslint-utils` instead.",
38+
},
39+
],
40+
},
41+
],
42+
"no-restricted-properties": [
43+
"error",
44+
{
45+
object: "context",
46+
property: "getSourceCode",
47+
message: "Use src/utils/compat.ts",
48+
},
49+
{
50+
object: "context",
51+
property: "getFilename",
52+
message: "Use src/utils/compat.ts",
53+
},
54+
{
55+
object: "context",
56+
property: "getPhysicalFilename",
57+
message: "Use src/utils/compat.ts",
58+
},
59+
{
60+
object: "context",
61+
property: "getCwd",
62+
message: "Use src/utils/compat.ts",
63+
},
64+
{
65+
object: "context",
66+
property: "getScope",
67+
message: "Use src/utils/compat.ts",
68+
},
69+
{
70+
object: "context",
71+
property: "parserServices",
72+
message: "Use src/utils/compat.ts",
73+
},
74+
],
2675
},
2776
overrides: [
2877
{

.github/workflows/format.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 👔 Format
2+
3+
on:
4+
workflow_dispatch: null
5+
6+
jobs:
7+
format:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
- name: Setup node
14+
uses: actions/setup-node@v4
15+
- name: Install deps
16+
run: npm install
17+
- name: Format
18+
run: npm run eslint-fix
19+
- name: Commit
20+
run: |
21+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
22+
git config --local user.name "github-actions[bot]"
23+
24+
git add .
25+
if [ -z "$(git status --porcelain)" ]; then
26+
echo "no formatting changed"
27+
exit 0
28+
fi
29+
git commit -m "chore: format"
30+
git push
31+
echo "pushed formatting changes https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"

docs/.vuepress/components/demo/stylelint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
extends: ["stylelint-config-standard"],
33
rules: {
44
"no-descending-specificity": null,
5-
indentation: null,
65
"selector-max-empty-lines": null,
76
"selector-type-no-unknown": null,
87
"block-no-empty": null,

docs/.vuepress/components/stylelint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ module.exports = {
22
extends: ["stylelint-config-standard", "stylelint-config-recommended-vue"],
33
rules: {
44
"no-descending-specificity": null,
5-
indentation: null,
65
},
76
};

lib/rules/enforce-style-type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
isValidStyleContext,
1212
getCommentDirectivesReporter,
1313
} from "../styles/context";
14+
import { getSourceCode } from "../utils/compat";
1415

1516
const styleTypesAttrs = ["scoped", "module"] as const;
1617
type StyleTypes = "plain" | (typeof styleTypesAttrs)[number];
@@ -64,8 +65,9 @@ export = {
6465
}
6566

6667
const reporter = getCommentDirectivesReporter(context);
68+
const sourceCode = getSourceCode(context);
6769
const tokenStore =
68-
context.parserServices.getTemplateBodyTokenStore?.() as TokenStore;
70+
sourceCode.parserServices.getTemplateBodyTokenStore?.() as TokenStore;
6971
const { options } = context;
7072

7173
const allows: AllowsOption = options[0]?.allows ?? ["scoped"];

lib/rules/no-deprecated-deep-combinator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import type { VCSSSelectorCombinator } from "../styles/ast";
88
import type { RuleContext, Range, RuleListener } from "../types";
99
import { isDeepCombinator } from "../styles/utils/selectors";
10+
import { getSourceCode } from "../utils/compat";
1011

1112
export = {
1213
meta: {
@@ -45,7 +46,7 @@ export = {
4546
value: node.value.trim(),
4647
},
4748
fix(fixer) {
48-
const sourceCodeText = context.getSourceCode().text;
49+
const sourceCodeText = getSourceCode(context).text;
4950
const range = [...node.range] as Range;
5051
let newText = "::v-deep";
5152
if (sourceCodeText[range[0] - 1]?.trim()) {

lib/rules/no-unused-keyframes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
getCommentDirectivesReporter,
88
} from "../styles/context";
99
import { isValidStyleContext } from "../styles/context/style";
10+
import { getSourceCode } from "../utils/compat";
1011

1112
export = {
1213
meta: {
@@ -42,7 +43,7 @@ export = {
4243
return {};
4344
}
4445
const reporter = getCommentDirectivesReporter(context);
45-
const sourceCode = context.getSourceCode();
46+
const sourceCode = getSourceCode(context);
4647

4748
/**
4849
* Reports the given node

lib/rules/require-scoped.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
isValidStyleContext,
1111
getCommentDirectivesReporter,
1212
} from "../styles/context";
13+
import { getSourceCode } from "../utils/compat";
1314

1415
export = {
1516
meta: {
@@ -40,8 +41,9 @@ export = {
4041
return {};
4142
}
4243
const reporter = getCommentDirectivesReporter(context);
44+
const sourceCode = getSourceCode(context);
4345
const tokenStore =
44-
context.parserServices.getTemplateBodyTokenStore?.() as TokenStore;
46+
sourceCode.parserServices.getTemplateBodyTokenStore?.() as TokenStore;
4547

4648
/**
4749
* Reports the given node.

lib/rules/require-v-deep-argument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
isVCSSDeclarationProperty,
2323
isVCSSComment,
2424
} from "../styles/utils/css-nodes";
25+
import { getSourceCode } from "../utils/compat";
2526

2627
export = {
2728
meta: {
@@ -90,8 +91,7 @@ export = {
9091
nextNode.range[0],
9192
];
9293
if (
93-
context
94-
.getSourceCode()
94+
getSourceCode(context)
9595
.text.slice(...betweenRange)
9696
.trim()
9797
) {

0 commit comments

Comments
 (0)