Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
webair committed May 3, 2024
1 parent 22ff757 commit bdfb0d0
Show file tree
Hide file tree
Showing 21 changed files with 329 additions and 329 deletions.
8 changes: 4 additions & 4 deletions dev-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "/src/global.scss";
import '/src/global.scss'

import { createApp } from "vue";
import { createApp } from 'vue'

import ExampleApp from "./ExampleApp.vue";
import ExampleApp from './ExampleApp.vue'

createApp(ExampleApp).mount("#app");
createApp(ExampleApp).mount('#app')
10 changes: 5 additions & 5 deletions dev-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import vueExamples from "vite-plugin-vue-examples";
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import vueExamples from 'vite-plugin-vue-examples'

export default defineConfig({
plugins: [
vue(),
vueExamples({ globalStylesheetPaths: ["/src/global.scss"] }),
vueExamples({ globalStylesheetPaths: ['/src/global.scss'] }),
],
});
})
24 changes: 12 additions & 12 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import eslintJs from "@eslint/js";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
import eslintPluginVue from "eslint-plugin-vue";
import typescriptEslint from "typescript-eslint";
import eslintJs from '@eslint/js'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
import eslintPluginVue from 'eslint-plugin-vue'
import typescriptEslint from 'typescript-eslint'

export default typescriptEslint.config(
eslintJs.configs.recommended,
...typescriptEslint.configs.recommended,
...eslintPluginVue.configs["flat/recommended"],
...eslintPluginVue.configs['flat/recommended'],

{
plugins: {
"typescript-eslint": typescriptEslint.plugin,
"simple-import-sort": eslintPluginSimpleImportSort,
'typescript-eslint': typescriptEslint.plugin,
'simple-import-sort': eslintPluginSimpleImportSort,
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
languageOptions: {
parserOptions: {
Expand All @@ -25,7 +25,7 @@ export default typescriptEslint.config(
},
},
{
ignores: ["**/dist/*"],
ignores: ['**/dist/*'],
},
eslintPluginPrettierRecommended,
);
)
66 changes: 33 additions & 33 deletions package/src/examples-app-main-file-transformer.test.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it } from 'vitest'

import { examplesAppMainFileTransformer } from "./examples-app-main-file-transformer";
import { examplesAppMainFileTransformer } from './examples-app-main-file-transformer'

describe("examplesAppMainFileTransformer", () => {
describe("matchesId", () => {
it("should match id", () => {
const examplesAppDir = "/examplesApp";
const transformer = examplesAppMainFileTransformer(examplesAppDir);
describe('examplesAppMainFileTransformer', () => {
describe('matchesId', () => {
it('should match id', () => {
const examplesAppDir = '/examplesApp'
const transformer = examplesAppMainFileTransformer(examplesAppDir)

const matches = transformer.matchesId(`${examplesAppDir}/main.ts`);
const matches = transformer.matchesId(`${examplesAppDir}/main.ts`)

expect(matches).toBe(true);
});
it("should match id when query string is added", () => {
const examplesAppDir = "/examplesApp";
const transformer = examplesAppMainFileTransformer(examplesAppDir);
expect(matches).toBe(true)
})
it('should match id when query string is added', () => {
const examplesAppDir = '/examplesApp'
const transformer = examplesAppMainFileTransformer(examplesAppDir)

const matches = transformer.matchesId(`${examplesAppDir}/main.ts?id=123`);
const matches = transformer.matchesId(`${examplesAppDir}/main.ts?id=123`)

expect(matches).toBe(true);
});
it("should not match id for other file", () => {
const examplesAppDir = "/examplesApp";
const transformer = examplesAppMainFileTransformer(examplesAppDir);
expect(matches).toBe(true)
})
it('should not match id for other file', () => {
const examplesAppDir = '/examplesApp'
const transformer = examplesAppMainFileTransformer(examplesAppDir)

const matches = transformer.matchesId(`${examplesAppDir}/App.vue`);
const matches = transformer.matchesId(`${examplesAppDir}/App.vue`)

expect(matches).toBe(false);
});
});
expect(matches).toBe(false)
})
})

describe("addStyleSheet", () => {
it("should add style sheets on top", () => {
const transformer = examplesAppMainFileTransformer("any");
const stylesheetPaths = ["global.scss", "@dir/global.scss"];
describe('addStyleSheet', () => {
it('should add style sheets on top', () => {
const transformer = examplesAppMainFileTransformer('any')
const stylesheetPaths = ['global.scss', '@dir/global.scss']

const transformedMainSource = transformer.addStyleSheet(
"code",
'code',
stylesheetPaths,
);
)

expect(transformedMainSource).toBe(
`import 'global.scss'\nimport '@dir/global.scss'\ncode`,
);
});
});
});
)
})
})
})
16 changes: 8 additions & 8 deletions package/src/examples-app-main-file-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
export const examplesAppMainFileTransformer = (examplesAppDir: string) => {
const matchesId = (id: string) => {
return id.startsWith(`${examplesAppDir}/main.ts`);
};
return id.startsWith(`${examplesAppDir}/main.ts`)
}

const addStyleSheet = (
mainSource: string,
stylesheetPaths: string[],
): string => {
let stylesheetImports = "";
let stylesheetImports = ''
for (const stylesheetPath of stylesheetPaths) {
stylesheetImports += `import '${stylesheetPath}'\n`;
stylesheetImports += `import '${stylesheetPath}'\n`
}
return `${stylesheetImports}` + mainSource;
};
return `${stylesheetImports}` + mainSource
}

return {
matchesId,
addStyleSheet,
};
};
}
}
2 changes: 1 addition & 1 deletion package/src/examples-app/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import ExamplesNavigation from "./ExamplesNavigation.vue";
import ExamplesNavigation from './ExamplesNavigation.vue'
</script>

<template>
Expand Down
18 changes: 9 additions & 9 deletions package/src/examples-app/ExamplesNavigation.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script setup lang="ts">
import { routeRecords } from "virtual:vue-examples-route-records";
import { ref } from "vue";
import { routeRecords } from 'virtual:vue-examples-route-records'
import { ref } from 'vue'
import ExamplesNavigationList from "./ExamplesNavigationList.vue";
import ExamplesNavigationList from './ExamplesNavigationList.vue'
const showOverlay = ref(false);
const showOverlay = ref(false)
const onClickExamples = () => {
showOverlay.value = true;
};
showOverlay.value = true
}
const onClickClose = () => {
showOverlay.value = false;
};
showOverlay.value = false
}
</script>

<template>
Expand All @@ -28,7 +28,7 @@ const onClickClose = () => {
</template>

<style scoped lang="scss">
@import "./styles/variables.scss";
@import './styles/variables.scss';
* {
all: revert;
Expand Down
14 changes: 7 additions & 7 deletions package/src/examples-app/ExamplesNavigationList.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<script setup lang="ts">
import { RouteRecordRaw } from "vue-router";
import { RouteRecordRaw } from 'vue-router'
import ExamplesNavigationListEntry from "./ExamplesNavigationListEntry.vue";
import ExamplesNavigationListEntry from './ExamplesNavigationListEntry.vue'
withDefaults(
defineProps<{
routeRecords: RouteRecordRaw[];
currentPath?: string;
routeRecords: RouteRecordRaw[]
currentPath?: string
}>(),
{ currentPath: "" },
);
{ currentPath: '' },
)
</script>

<template>
Expand All @@ -24,7 +24,7 @@ withDefaults(
</template>

<style scoped lang="scss">
@import "styles/variables.scss";
@import 'styles/variables.scss';
.examples-navigation-list {
padding: 0;
Expand Down
24 changes: 12 additions & 12 deletions package/src/examples-app/ExamplesNavigationListEntry.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<script setup lang="ts">
import { computed } from "vue";
import { RouteRecordRaw } from "vue-router";
import { computed } from 'vue'
import { RouteRecordRaw } from 'vue-router'
import ExamplesNavigationList from "./ExamplesNavigationList.vue";
import ExamplesNavigationList from './ExamplesNavigationList.vue'
const props = withDefaults(
defineProps<{
routeRecord: RouteRecordRaw;
currentPath?: string;
routeRecord: RouteRecordRaw
currentPath?: string
}>(),
{ currentPath: "" },
);
{ currentPath: '' },
)
const isExample = computed(() => {
return !!props.routeRecord.component;
});
return !!props.routeRecord.component
})
const completeRoutePath = computed(() => {
return `${props.currentPath}/${props.routeRecord.path}`;
});
return `${props.currentPath}/${props.routeRecord.path}`
})
</script>

<template>
Expand All @@ -40,7 +40,7 @@ const completeRoutePath = computed(() => {
</template>

<style scoped lang="scss">
@import "styles/variables.scss";
@import 'styles/variables.scss';
.examples-navigation-list-entry {
color: $color-font-secondary;
Expand Down
54 changes: 27 additions & 27 deletions package/src/examples-app/first-example-path.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { describe, expect, it } from "vitest";
import { Component } from "vue";
import { RouteRecordRaw } from "vue-router";
import { describe, expect, it } from 'vitest'
import { Component } from 'vue'
import { RouteRecordRaw } from 'vue-router'

import { firstExamplePath } from "./first-example-path";
import { firstExamplePath } from './first-example-path'

const dummyComponent: Component = {};
const dummyComponent: Component = {}

describe("firstExamplePath", () => {
it("should return path of example route", () => {
describe('firstExamplePath', () => {
it('should return path of example route', () => {
const routeRecords: RouteRecordRaw[] = [
{
path: "group",
children: [{ path: "NestedExample", component: dummyComponent }],
path: 'group',
children: [{ path: 'NestedExample', component: dummyComponent }],
},
{ path: "Example", component: dummyComponent },
];
{ path: 'Example', component: dummyComponent },
]

const path = firstExamplePath(routeRecords);
const path = firstExamplePath(routeRecords)

expect(path).toStrictEqual("Example");
});
expect(path).toStrictEqual('Example')
})

it("should return complete path to example in group when no example is found in root level", () => {
it('should return complete path to example in group when no example is found in root level', () => {
const routeRecords: RouteRecordRaw[] = [
{
path: "group",
children: [{ path: "NestedExample", component: dummyComponent }],
path: 'group',
children: [{ path: 'NestedExample', component: dummyComponent }],
},
];
]

const path = firstExamplePath(routeRecords);
const path = firstExamplePath(routeRecords)

expect(path).toStrictEqual("group/NestedExample");
});
expect(path).toStrictEqual('group/NestedExample')
})

it("should return empty path when no examples found", () => {
const routeRecords: RouteRecordRaw[] = [{ path: "group", children: [] }];
it('should return empty path when no examples found', () => {
const routeRecords: RouteRecordRaw[] = [{ path: 'group', children: [] }]

const path = firstExamplePath(routeRecords);
const path = firstExamplePath(routeRecords)

expect(path).toStrictEqual("");
});
});
expect(path).toStrictEqual('')
})
})
Loading

0 comments on commit bdfb0d0

Please sign in to comment.