Skip to content

Commit

Permalink
Add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Sep 16, 2024
1 parent cf3ba5c commit 730a0d2
Show file tree
Hide file tree
Showing 12 changed files with 1,507 additions and 107 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: Lint
name: Lint & Build
on:
pull_request:
paths:
- '**.md'

concurrency:
group: lint-${{ github.ref_name }}
group: validate-${{ github.ref_name }}
cancel-in-progress: true

env:
CAIDO_PNPM_VERSION: 9


jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -20,10 +17,21 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Lint
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.CAIDO_PNPM_VERSION }}

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint Markdown
uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 # v15
with:
globs: '**/*.md'
globs: 'src/**/*.md'

- name: Lint JS
run: pnpm lint:js

build:
runs-on: ubuntu-latest
Expand All @@ -33,7 +41,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3.0.0
uses: pnpm/action-setup@v4
with:
version: ${{ env.CAIDO_PNPM_VERSION }}

Expand All @@ -42,5 +50,3 @@ jobs:

- name: Run build
run: pnpm build


3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"fenced-code-language": false,
"no-duplicate-heading": false,
"ol-prefix": false,
"no-trailing-punctuation": false
"no-trailing-punctuation": false,
"heading-increment": false
}
26 changes: 13 additions & 13 deletions .vitepress/components/Pro.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<script setup lang="ts">
</script>
<script setup lang="ts"></script>

<template>
<div class="c-pro info custom-block">
<slot name="title">
<p class="custom-block-title">⚡PRO FEATURE</p>
</slot>
<p>
<slot>
<div class="c-pro info custom-block">
<slot name="title">
<p class="custom-block-title">⚡PRO FEATURE</p>
</slot>
</p>
</div>
<p>
<slot />
</p>
</div>
</template>

<style scoped>
Expand All @@ -25,9 +23,11 @@
inset: 0;
border-radius: 8px;
border: 2px solid transparent;
background: linear-gradient(140deg, var(--vp-c-brand-1), var(--vp-c-brand-2)) border-box;
mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
background: linear-gradient(140deg, var(--vp-c-brand-1), var(--vp-c-brand-2))
border-box;
mask:
linear-gradient(#fff 0 0) padding-box,
linear-gradient(#fff 0 0);
mask-composite: exclude;
}
</style>
2 changes: 1 addition & 1 deletion .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "vitepress";

import { referenceSidebar, guidesSidebar, conceptsSidebar } from "./sidebars";
import { conceptsSidebar, guidesSidebar, referenceSidebar } from "./sidebars";

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/sidebars/concepts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultTheme } from "vitepress";
import type { DefaultTheme } from "vitepress";

export const conceptsSidebar: DefaultTheme.SidebarItem[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion .vitepress/sidebars/guides.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DefaultTheme } from "vitepress";
import type { DefaultTheme } from "vitepress";

export const guidesSidebar: DefaultTheme.SidebarItem[] = [
{
Expand Down
83 changes: 42 additions & 41 deletions .vitepress/sidebars/reference.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
import {
DefaultTheme
} from "vitepress";
import type { DefaultTheme } from "vitepress";

export const referenceSidebar: DefaultTheme.SidebarItem[] = [{
text: "Introduction",
items: [{
text: 'Directory',
link: '/reference/'
},
]
},
{
text: 'Plugins',
items: [{
text: 'Custom CSS',
link: '/reference/plugins/custom_css'
},
{
text: '(WIP) Custom JS',
link: '/reference/plugins/custom_js'
},
{
text: '(WIP) Custom Workflow Nodes',
link: '/reference/plugins/custom_workflow_nodes'
}
]
},
{
text: 'SDKs',
items: [
{
text: 'Backend',
link: '/reference/sdks/backend_sdk',
},
{
text: 'Frontend (WIP)',
link: '/reference/sdks/frontend_sdk',
},
]
},
]
export const referenceSidebar: DefaultTheme.SidebarItem[] = [
{
text: "Introduction",
items: [
{
text: "Directory",
link: "/reference/",
},
],
},
{
text: "Plugins",
items: [
{
text: "Custom CSS",
link: "/reference/plugins/custom_css",
},
{
text: "(WIP) Custom JS",
link: "/reference/plugins/custom_js",
},
{
text: "(WIP) Custom Workflow Nodes",
link: "/reference/plugins/custom_workflow_nodes",
},
],
},
{
text: "SDKs",
items: [
{
text: "Backend",
link: "/reference/sdks/backend_sdk",
},
{
text: "Frontend (WIP)",
link: "/reference/sdks/frontend_sdk",
},
],
},
];
15 changes: 7 additions & 8 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import DefaultTheme from 'vitepress/theme'
import './custom.css'

import ProContainer from '../components/Pro.vue'
import type { Theme } from 'vitepress'
import DefaultTheme from "vitepress/theme";
import "./custom.css";

import ProContainer from "../components/Pro.vue";
import type { Theme } from "vitepress";

export default {
extends: DefaultTheme,
enhanceApp({ app }) {
app.component('ProContainer', ProContainer)
}
} satisfies Theme
app.component("ProContainer", ProContainer);
},
} satisfies Theme;
66 changes: 66 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import typescriptEslint from "typescript-eslint";
import vueEslintParser from "vue-eslint-parser";
import pluginVue from "eslint-plugin-vue";
import eslintjs from "@eslint/js";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

/** @type {import('eslint').Linter.Config } */
export default [
{
ignores: [".vitepress/cache"],
},
eslintjs.configs.recommended,
...typescriptEslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
...pluginVue.configs["flat/recommended"],
{
languageOptions: {
parser: vueEslintParser,
parserOptions: {
parser: typescriptEslint.parser,
project: "./tsconfig.json",
extraFileExtensions: [".vue"],
},
},
rules: {
// Disabled
"no-empty-pattern": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unused-expressions": "off",

// Disabled for performance issues
// Reference: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting/#eslint-plugin-import
"import/namespace": "off",

// Disable no-unused-vars and uses noUnusedLocals: true in tsconfig.json instead
// Reference: https://github.com/johnsoncodehk/volar/issues/47
"@typescript-eslint/no-unused-vars": "off",

// Enabled
"sort-imports": [
"warn",
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],

"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",

"vue/singleline-html-element-content-newline": "off",
"vue/multi-word-component-names": "off",
},
},
];
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview",
"lint": "markdownlint-cli2 'src/**/*.md'"
"lint": "pnpm lint:js && pnpm lint:md",
"lint:js": "ESLINT_ENV=production eslint ./.vitepress -c ./eslint.config.mjs --max-warnings 0",
"lint:md": "markdownlint-cli2 'src/**/*.md'"
},
"author": "Caido Labs Inc. <[email protected]>",
"license": "CC-BY-4.0",
"devDependencies": {
"vitepress": "^1.2.2"
"eslint": "9.10.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-vue": "9.27.0",
"markdownlint-cli2": "0.14.0",
"typescript": "5.6.2",
"typescript-eslint": "8.5.0",
"vitepress": "1.2.2",
"vue-eslint-parser": "9.4.3"
}
}
Loading

0 comments on commit 730a0d2

Please sign in to comment.