Add lint action

This commit is contained in:
Johannes Theiner
2025-07-04 13:27:53 +02:00
parent 90290a8af5
commit dbc9096f81
4 changed files with 50 additions and 3 deletions

28
.github/workflows/lint.yml vendored Normal file
View File

@@ -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

View File

@@ -1,6 +1,7 @@
import tseslint from 'typescript-eslint'; import tseslint from 'typescript-eslint';
import obsidianmd from "eslint-plugin-obsidianmd"; import obsidianmd from "eslint-plugin-obsidianmd";
import globals from "globals"; import globals from "globals";
import { globalIgnores } from "eslint/config";
export default tseslint.config( export default tseslint.config(
{ {
@@ -9,11 +10,25 @@ export default tseslint.config(
...globals.browser, ...globals.browser,
}, },
parserOptions: { parserOptions: {
projectService: true, projectService: {
allowDefaultProject: [
'eslint.config.js',
'manifest.json'
]
},
tsconfigRootDir: import.meta.dirname, tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.json']
}, },
}, },
}, },
...obsidianmd.configs.recommended, ...obsidianmd.configs.recommended,
globalIgnores([
"node_modules",
"dist",
"esbuild.config.mjs",
"version-bump.mjs",
"versions.json",
"main.js",
]),
); );

View File

@@ -14,8 +14,8 @@
"devDependencies": { "devDependencies": {
"@types/node": "^16.11.6", "@types/node": "^16.11.6",
"builtin-modules": "3.3.0", "builtin-modules": "3.3.0",
"esbuild": "0.20.1", "esbuild": "0.25.5",
"eslint-plugin-obsidianmd": "latest", "eslint-plugin-obsidianmd": "0.1.4",
"globals": "14.0.0", "globals": "14.0.0",
"tslib": "2.4.0", "tslib": "2.4.0",
"typescript": "^5.8.3" "typescript": "^5.8.3"

View File

@@ -19,6 +19,8 @@ export default class MyPlugin extends Plugin {
const el = document.createDiv(); const el = document.createDiv();
el.style.color = 'white'; el.style.color = 'white';
el.style.backgroundColor = 'red'; 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. // 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() { async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
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() { async saveSettings() {