From dbc9096f8159f87ff58a8f03e0a5fc0186df5496 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Fri, 4 Jul 2025 13:27:53 +0200 Subject: [PATCH] Add lint action --- .github/workflows/lint.yml | 28 ++++++++++++++++++++++++++++ eslint.config.js | 17 ++++++++++++++++- package.json | 4 ++-- src/main.ts | 4 ++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..685cf90 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Node.js build + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: npm run build --if-present + - run: npm run lint + diff --git a/eslint.config.js b/eslint.config.js index 39f27a4..c45cd17 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,7 @@ import tseslint from 'typescript-eslint'; import obsidianmd from "eslint-plugin-obsidianmd"; import globals from "globals"; +import { globalIgnores } from "eslint/config"; export default tseslint.config( { @@ -9,11 +10,25 @@ export default tseslint.config( ...globals.browser, }, parserOptions: { - projectService: true, + projectService: { + allowDefaultProject: [ + 'eslint.config.js', + 'manifest.json' + ] + }, tsconfigRootDir: import.meta.dirname, + extraFileExtensions: ['.json'] }, }, }, ...obsidianmd.configs.recommended, + globalIgnores([ + "node_modules", + "dist", + "esbuild.config.mjs", + "version-bump.mjs", + "versions.json", + "main.js", + ]), ); diff --git a/package.json b/package.json index 9135405..fdc2bc2 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "devDependencies": { "@types/node": "^16.11.6", "builtin-modules": "3.3.0", - "esbuild": "0.20.1", - "eslint-plugin-obsidianmd": "latest", + "esbuild": "0.25.5", + "eslint-plugin-obsidianmd": "0.1.4", "globals": "14.0.0", "tslib": "2.4.0", "typescript": "^5.8.3" diff --git a/src/main.ts b/src/main.ts index 016b306..f465e86 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,6 +19,8 @@ export default class MyPlugin extends Plugin { const el = document.createDiv(); el.style.color = 'white'; el.style.backgroundColor = 'red'; + + localStorage.setItem('test', 'hello'); }); // This adds a status bar item to the bottom of the app. Does not work on mobile apps. @@ -89,6 +91,8 @@ export default class MyPlugin extends Plugin { async loadSettings() { this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData()); + + const result = await fetch("https://github.com"); } async saveSettings() {