Skip to content

Commit 1e12ebd

Browse files
committed
chore: setup eslint for coalesce-vue and coalesce-vue-vuetify3
1 parent 42d4e87 commit 1e12ebd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1017
-911
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"dotnet.defaultSolution": "Coalesce.slnx",
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
},
36
"editor.formatOnPaste": false,
47
"editor.formatOnSave": true,
58
"editor.formatOnType": true,

package-lock.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"@types/node": "^22.15.3",
1212
"@vitejs/plugin-vue": "^6.0.1",
1313
"@vitest/coverage-v8": "^3.2.4",
14+
"@vitest/eslint-plugin": "^1.3.23",
1415
"@vue/eslint-config-typescript": "14.6.0",
1516
"@vue/test-utils": "~2.4.6",
1617
"cspell": "8.19.3",
1718
"eslint": "9.32.0",
19+
"eslint-config-prettier": "^10.1.8",
1820
"eslint-plugin-prettier": "^5.5.3",
1921
"eslint-plugin-vue": "10.5.0",
2022
"jsdom": "^26.1.0",

src/coalesce-vue-vuetify3/.eslintrc.cjs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import pluginVue from "eslint-plugin-vue";
2+
import vueTsEslintConfig from "@vue/eslint-config-typescript";
3+
import pluginVitest from "@vitest/eslint-plugin";
4+
import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
5+
export default [
6+
{
7+
name: "app/files-to-lint",
8+
files: ["**/*.{ts,mts,tsx,vue}"],
9+
languageOptions: {
10+
parserOptions: {
11+
tsconfigRootDir: import.meta.dirname,
12+
// or, in CommonJS, __dirname
13+
},
14+
},
15+
},
16+
17+
{
18+
name: "app/files-to-ignore",
19+
ignores: ["dist/**", "**/*.g.ts", "**/coverage/**", "eslint.config.mjs"],
20+
},
21+
22+
...pluginVue.configs["flat/recommended"],
23+
...vueTsEslintConfig(),
24+
{
25+
...pluginVitest.configs.recommended,
26+
files: ["src/**/__tests__/*", "src/**/*.spec.*"],
27+
},
28+
eslintPluginPrettier,
29+
30+
{
31+
rules: {
32+
"prettier/prettier": [
33+
"error",
34+
{
35+
endOfLine: "auto",
36+
},
37+
],
38+
39+
"vue/multi-word-component-names": "off",
40+
"vue/attribute-hyphenation": "off",
41+
"vue/component-definition-name-casing": "off",
42+
"vue/require-default-prop": "off", // Annoying and wrong about defineProps
43+
"vue/no-template-shadow": ["error", { allow: ["props"] }],
44+
"vue/no-mutating-props": ["error", { shallowOnly: true }],
45+
46+
"prefer-const": "error",
47+
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
48+
"no-console": "off",
49+
"no-undef": "off", // Redundant with Typescript
50+
51+
"@typescript-eslint/no-explicit-any": "off",
52+
"@typescript-eslint/no-unused-vars": [
53+
"error",
54+
{
55+
varsIgnorePattern:
56+
// Allow unused `const props = defineProps` (if props are only used in the template of an SFC)
57+
"^(props|mock|saveMock|_.*)$",
58+
args: "none",
59+
},
60+
],
61+
},
62+
},
63+
64+
{
65+
name: "app/tsx-overrides",
66+
files: ["**/*.tsx"],
67+
rules: {
68+
"@typescript-eslint/no-unused-expressions": "off",
69+
"vitest/expect-expect": "off", // https://github.com/vitest-dev/eslint-plugin-vitest/issues/697
70+
},
71+
},
72+
];

src/coalesce-vue-vuetify3/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"buildts": "tsc -p ./tsconfig.build-utils.json",
4242
"build-local-deps": "cd ../coalesce-vue && npm run build",
4343
"test": "vitest",
44+
"lint": "eslint .",
45+
"lint:fix": "eslint . --fix",
4446
"coverage": "vitest --coverage"
4547
},
4648
"dependencies": {

src/coalesce-vue-vuetify3/src/components/admin/c-admin-audit-log-page.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<c-list-page class="c-admin-table-toolbar--page" :list="listVm" />
3636

37-
<template v-slot:extension>
37+
<template #extension>
3838
<v-defaults-provider
3939
:defaults="{
4040
global: {
@@ -71,14 +71,14 @@
7171
<c-input
7272
v-model="filter.state"
7373
:for="listVm.$metadata.props.state"
74-
@click:clear="$nextTick(() => (filter.state = ''))"
7574
style="min-width: 210px; max-width: 210px"
75+
@click:clear="$nextTick(() => (filter.state = ''))"
7676
/>
7777

7878
<c-select
7979
v-if="'foreignKey' in userPropMeta"
80-
:for="userPropMeta"
8180
v-model:key-value="filter[userPropMeta.foreignKey.name]"
81+
:for="userPropMeta"
8282
clearable
8383
style="width: 240px"
8484
@click:clear="
@@ -146,8 +146,8 @@
146146
/>
147147
<pre
148148
:class="timeDiffClass(auditLog, items[index + 1])"
149-
v-text="timeDiff(auditLog, items[index + 1])"
150149
title="Time delta from the preceding row"
150+
v-text="timeDiff(auditLog, items[index + 1])"
151151
></pre>
152152
</td>
153153

@@ -164,8 +164,8 @@
164164
>
165165
<div
166166
v-if="auditLog.description"
167-
v-text="auditLog.description"
168167
class="c-audit-logs--entry-desc text-grey"
168+
v-text="auditLog.description"
169169
></div>
170170
</td>
171171

@@ -221,8 +221,8 @@
221221
{{ prop.oldValue }}
222222

223223
<span
224-
class="c-audit-logs--property-value-desc text-grey"
225224
v-if="prop.oldValueDescription"
225+
class="c-audit-logs--property-value-desc text-grey"
226226
>
227227
({{ prop.oldValueDescription }})
228228
</span>
@@ -233,8 +233,8 @@
233233
{{ prop.newValue }}
234234

235235
<span
236-
class="c-audit-logs--property-value-desc text-grey"
237236
v-if="prop.newValueDescription"
237+
class="c-audit-logs--property-value-desc text-grey"
238238
>
239239
({{ prop.newValueDescription }})
240240
</span>
@@ -375,10 +375,10 @@ function timeDiff(current: AuditLogBase, older?: AuditLogBase) {
375375
const positive = ms >= 0;
376376
ms = Math.abs(ms);
377377
378-
var totalSec = ms / 1000;
379-
var hours = Math.floor(totalSec / 3600);
380-
var minutes = Math.floor((totalSec - hours * 3600) / 60);
381-
var seconds = totalSec - hours * 3600 - minutes * 60;
378+
const totalSec = ms / 1000;
379+
const hours = Math.floor(totalSec / 3600);
380+
const minutes = Math.floor((totalSec - hours * 3600) / 60);
381+
const seconds = totalSec - hours * 3600 - minutes * 60;
382382
383383
return (
384384
(positive ? "+" : "-") +

src/coalesce-vue-vuetify3/src/components/admin/c-admin-create-btn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<v-list-item
1717
v-for="item in creatableTypes"
1818
:key="item.metadata.name"
19-
@click="emit('add', item.metadata, item.route!)"
2019
:title="item.metadata.displayName"
20+
@click="emit('add', item.metadata, item.route!)"
2121
></v-list-item>
2222
</v-list>
2323
</v-menu>

src/coalesce-vue-vuetify3/src/components/admin/c-admin-display.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function render() {
4242
4343
if (!meta) {
4444
throw Error(
45-
"Provided model has no $metadata property, and no specific value was provided via the 'for' component prop to c-display."
45+
"Provided model has no $metadata property, and no specific value was provided via the 'for' component prop to c-display.",
4646
);
4747
}
4848
@@ -81,7 +81,7 @@ function render() {
8181
(((model as any)[narrowedMeta.name] as ViewModelCollection<any, any>)
8282
?.$hasLoaded === false
8383
? "View"
84-
: "None")
84+
: "None"),
8585
);
8686
}
8787
@@ -95,7 +95,7 @@ function render() {
9595
{
9696
to: getRefNavRoute(router, model, meta),
9797
},
98-
() => propDisplay(model, narrowedMeta) ?? fkValue
98+
() => propDisplay(model, narrowedMeta) ?? fkValue,
9999
);
100100
}
101101
}
@@ -117,7 +117,7 @@ function render() {
117117
link.click();
118118
},
119119
},
120-
h(CDisplay, { ...props })
120+
h(CDisplay, { ...props }),
121121
);
122122
}
123123
}

src/coalesce-vue-vuetify3/src/components/admin/c-admin-editor-page.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
HiddenAreas,
2929
} from "coalesce-vue";
3030
31-
import { computed, watch, getCurrentInstance, onMounted } from "vue";
31+
import { computed, watch, getCurrentInstance } from "vue";
3232
import { useRoute, useRouter } from "vue-router";
3333
import { isPropReadOnly } from "../../util";
3434
import { copyParamsToNewViewModel } from "./util";
@@ -87,7 +87,7 @@ const pageTitle = computed(() => {
8787
return "Create - " + metadata.value.displayName;
8888
}
8989
90-
let display = viewModel ? modelDisplay(viewModel) : null;
90+
const display = viewModel ? modelDisplay(viewModel) : null;
9191
if (!display) {
9292
return metadata.value.displayName;
9393
}

0 commit comments

Comments
 (0)