Skip to content

Commit

Permalink
github-actions: add lint github action
Browse files Browse the repository at this point in the history
  • Loading branch information
julesvirallinen committed Sep 12, 2023
1 parent e1b467b commit 587360c
Show file tree
Hide file tree
Showing 8 changed files with 727 additions and 176 deletions.
21 changes: 15 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"root": true,
"ignorePatterns": ["**.js"],
"ignorePatterns": [
"**.js"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -23,6 +28,10 @@
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-explicit-any": ["warn"]
"@typescript-eslint/no-explicit-any": [
"warn"
],
// allow prettier to use SmartTabs
"no-mixed-spaces-and-tabs": "off"
}
}
}
46 changes: 31 additions & 15 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
name: GitHub Actions
run-name: Unit testing ${{ github.actor }} changes
on: [push]
run-name: ${{ github.event.pull_request }} CI Checks
on:
push:
pull_request:
types: [opened, synchronize]
jobs:
"run-unit-tests":
name: "Run unit tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Use node version"
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: "Install dependencies"
run: npm install
- name: Run tests
run: npm run test
"run-unit-tests":
name: "Run unit tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Use node version"
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: "Install dependencies"
run: npm install
- name: Run tests
run: npm run test
"lint":
name: "Checking for linting errors"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: "Use node version"
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: "Install dependencies"
run: npm install
- name: Checking linter
run: npm run lint
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.11
20.6.0
15 changes: 10 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const DEFAULT_SETTINGS: DigitalGardenSettings = {
};

export default class DigitalGarden extends Plugin {
settings: DigitalGardenSettings;
appVersion: string;
settings!: DigitalGardenSettings;
appVersion!: string;

publishModal: PublishModal;
publishModal!: PublishModal;

async onload() {
this.appVersion = this.manifest.version;
Expand Down Expand Up @@ -115,7 +115,7 @@ export default class DigitalGarden extends Plugin {
const event = this.app.metadataCache.on(
"changed",
async (file, _data, _cache) => {
if (file.path === activeFile.path) {
if (file.path === activeFile?.path) {
const successfullyPublished =
await this.publishSingleNote();
if (successfullyPublished) {
Expand Down Expand Up @@ -338,10 +338,15 @@ export default class DigitalGarden extends Plugin {
}
}
async addPublishFlag() {
const activeFile = this.app.workspace.getActiveFile();
if (activeFile === null) {
new Notice("No active file!");
return;
}
const engine = new ObsidianFrontMatterEngine(
this.app.vault,
this.app.metadataCache,
this.app.workspace.getActiveFile(),
activeFile,
);
engine.set("dg-publish", true).apply();
}
Expand Down
Loading

0 comments on commit 587360c

Please sign in to comment.