Skip to content

Commit

Permalink
Add GH actions (#82)
Browse files Browse the repository at this point in the history
* packages: bump node and add nvmrc

* packages: commit package-lock

* github-actions: add build / lint actions

* lint: ban console

* github-actions: fail build step on warnings
  • Loading branch information
julesvirallinen authored Jan 10, 2024
1 parent 6881879 commit 1604143
Show file tree
Hide file tree
Showing 7 changed files with 4,071 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}
],
"@typescript-eslint/no-explicit-any": ["error"],
"no-console": "error",
"array-callback-return": ["error"],
"padding-line-between-statements": [
"warn",
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
types: [edited, synchronize, opened]
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Use node version'
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: 'Install dependencies'
run: npm install
- name: 'Build'
run: npm run build-ci
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Use node version'
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: 'Install dependencies'
run: npm install
- name: 'Linting with ESLint'
run: npm run lint
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ settings.json

# npm
node_modules
package-lock.json

# build
build
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v21.5.0
8 changes: 7 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const DEFAULT_SETTINGS: CustomJSSettings = {
startupScriptNames: [],
registeredInvocableScriptNames: [],
};

interface Invocable {
invoke: () => Promise<void>;
}
Expand All @@ -38,6 +37,7 @@ export default class CustomJS extends Plugin {
settings: CustomJSSettings;

async onload() {
// eslint-disable-next-line no-console
console.log('Loading CustomJS');
await this.loadSettings();
this.registerEvent(this.app.vault.on('modify', this.reloadIfNeeded, this));
Expand Down Expand Up @@ -84,12 +84,14 @@ export default class CustomJS extends Plugin {
const scriptObj = window.customJS[scriptName];

if (!scriptObj) {
// eslint-disable-next-line no-console
console.warn(`Script '${scriptName}' is not defined`);

return;
}

if (!isInvocable(scriptObj)) {
// eslint-disable-next-line no-console
console.warn(`Script '${scriptName}' is not invocable`);

return;
Expand All @@ -103,7 +105,9 @@ export default class CustomJS extends Plugin {
new Notice(
`${message}\n${e.message}\nSee error console for more details`,
);
// eslint-disable-next-line no-console
console.error(message);
// eslint-disable-next-line no-console
console.error(e);
}
}
Expand Down Expand Up @@ -144,7 +148,9 @@ export default class CustomJS extends Plugin {
// Provide a way to create a new instance
window.customJS[`create${def.name}Instance`] = () => new def();
} catch (e) {
// eslint-disable-next-line no-console
console.error(`CustomJS couldn't import ${f}`);
// eslint-disable-next-line no-console
console.error(e);
}
}
Expand Down
Loading

0 comments on commit 1604143

Please sign in to comment.