mirror of https://github.com/TriliumNext/Notes
Merge branch 'develop' of https://github.com/TriliumNext/Notes into develop
commit
a694017c87
@ -1,10 +1,37 @@
|
|||||||
.git
|
# ignored Files
|
||||||
.idea
|
.dockerignore
|
||||||
|
.editorconfig
|
||||||
|
.git*
|
||||||
|
.prettier*
|
||||||
|
electron*
|
||||||
|
entitlements.plist
|
||||||
|
forge.config.cjs
|
||||||
|
nodemon.json
|
||||||
|
renovate.json
|
||||||
|
trilium.iml
|
||||||
|
Dockerfile
|
||||||
|
Dockerfile.*
|
||||||
|
npm-debug.log
|
||||||
|
/src/**/*.spec.ts
|
||||||
|
|
||||||
|
# ignored folders
|
||||||
|
/.cache
|
||||||
|
/.git
|
||||||
|
/.github
|
||||||
|
/.idea
|
||||||
|
/.vscode
|
||||||
/bin
|
/bin
|
||||||
|
/build
|
||||||
/dist
|
/dist
|
||||||
/docs
|
/docs
|
||||||
/npm-debug.log
|
/dump-db
|
||||||
node_modules
|
/e2e
|
||||||
|
/integration-tests
|
||||||
|
/spec
|
||||||
|
/test
|
||||||
|
/test-etapi
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
|
||||||
src/**/*.ts
|
# exceptions
|
||||||
!src/services/asset_path.ts
|
!/bin/copy-dist.ts
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,48 @@
|
|||||||
|
import { lint } from "./eslint.js";
|
||||||
|
import { trimIndentation } from "../../../../spec/support/utils.js";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Linter", () => {
|
||||||
|
it("reports some basic errors", async () => {
|
||||||
|
const result = await lint(trimIndentation`
|
||||||
|
for (const i = 0; i<10; i++) {
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{ message: "'i' is constant.", },
|
||||||
|
{ message: "Empty block statement." }
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports no error for correct script", async () => {
|
||||||
|
const result = await lint(trimIndentation`
|
||||||
|
const foo = "bar";
|
||||||
|
console.log(foo.toString());
|
||||||
|
for (const x of [ 1, 2, 3]) {
|
||||||
|
console.log(x?.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
api.showMessage("Hi");
|
||||||
|
`);
|
||||||
|
expect(result.length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports unused functions as warnings", async () => {
|
||||||
|
const result = await lint(trimIndentation`
|
||||||
|
function hello() { }
|
||||||
|
function world() { }
|
||||||
|
|
||||||
|
console.log("Hello world");
|
||||||
|
`);
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
message: "'hello' is defined but never used.",
|
||||||
|
severity: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "'world' is defined but never used.",
|
||||||
|
severity: 1
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
export async function lint(code: string) {
|
||||||
|
|
||||||
|
const Linter = (await import("eslint-linter-browserify")).Linter;
|
||||||
|
const js = (await import("@eslint/js"));
|
||||||
|
const globals = (await import("globals"));
|
||||||
|
|
||||||
|
return new Linter().verify(code, [
|
||||||
|
js.configs.recommended,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2024
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
api: "readonly"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"no-unused-vars": [ "warn", { vars: "local", args: "after-used" }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "NodeNext",
|
||||||
|
"declaration": false,
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*.ts", "./src/**/*.js", "./*.ts"],
|
||||||
|
"exclude": [
|
||||||
|
"./**/*.spec.ts",
|
||||||
|
"./src/public/**/*",
|
||||||
|
"./*.config.ts",
|
||||||
|
],
|
||||||
|
"files": ["src/types.d.ts"]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue