Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint", "import"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
Expand All @@ -17,12 +22,30 @@
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/no-unused-vars": ["error", {"ignoreRestSiblings": true}],
"import/first": "warn",
"import/newline-after-import": "warn",
"import/no-import-module-exports": "warn",
"import/no-namespace": "error",
"import/no-relative-packages": "warn",
"import/no-unresolved": "off",
"import/no-unused-modules": "error",
"import/order": [
"warn",
{
"groups": ["builtin", "external", "parent", "sibling", "index"],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"no-cond-assign": 0,
"no-constant-condition": 0,
"no-sparse-arrays": 0,
"no-unexpected-multiline": 0,
"object-shorthand": ["warn", "always"],
"prettier/prettier": ["warn"]
"prettier/prettier": ["warn"],
"sort-imports": ["warn", {"ignoreDeclarationSort": true}]
},
"overrides": [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"d3-array": "^3.2.4",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.0",
"mocha": "^10.2.0",
"prettier": "^3.0.3",
Expand Down
2 changes: 1 addition & 1 deletion public/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Runtime, Library, Inspector} from "/_observablehq/runtime.js";
import {Inspector, Library, Runtime} from "/_observablehq/runtime.js";

const library = Object.assign(new Library(), {width, Mutable, ...recommendedLibraries()});
const runtime = new Runtime(library);
Expand Down
2 changes: 1 addition & 1 deletion src/files.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {accessSync, constants, statSync, type Stats} from "node:fs";
import {type Stats, accessSync, constants, statSync} from "node:fs";
import {mkdir, readdir, stat} from "node:fs/promises";
import {dirname, extname, join, normalize, relative} from "node:path";
import {isNodeError} from "./error.js";
Expand Down
2 changes: 1 addition & 1 deletion src/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Parser, tokTypes, type Node, type Options} from "acorn";
import {type Node, type Options, Parser, tokTypes} from "acorn";
import mime from "mime";
import {findAwaits} from "./javascript/awaits.js";
import {findDeclarations} from "./javascript/declarations.js";
Expand Down
6 changes: 3 additions & 3 deletions src/javascript/imports.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Parser, type Node} from "acorn";
import {simple} from "acorn-walk";
import {readFileSync} from "node:fs";
import {dirname, join, normalize} from "node:path";
import {parseOptions, type ImportReference, type JavaScriptNode} from "../javascript.js";
import {type Node, Parser} from "acorn";
import {simple} from "acorn-walk";
import {type ImportReference, type JavaScriptNode, parseOptions} from "../javascript.js";
import {getStringLiteralValue, isStringLiteral} from "./features.js";

export function findImports(body: Node, root: string, sourcePath: string) {
Expand Down
12 changes: 6 additions & 6 deletions src/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {getPatch, type Patch, type PatchItem} from "fast-array-diff";
import {readFile} from "node:fs/promises";
import {dirname, join} from "node:path";
import {type Patch, type PatchItem, getPatch} from "fast-array-diff";
import equal from "fast-deep-equal";
import matter from "gray-matter";
import hljs from "highlight.js";
import {parseHTML} from "linkedom";
import MarkdownIt from "markdown-it";
import MarkdownItAnchor from "markdown-it-anchor";
import {type RuleCore} from "markdown-it/lib/parser_core.js";
import {type RuleInline} from "markdown-it/lib/parser_inline.js";
import {type default as Renderer, type RenderRule} from "markdown-it/lib/renderer.js";
import {type RenderRule, type default as Renderer} from "markdown-it/lib/renderer.js";
import MarkdownItAnchor from "markdown-it-anchor";
import mime from "mime";
import {readFile} from "node:fs/promises";
import {isLocalFile, pathFromRoot} from "./files.js";
import {computeHash} from "./hash.js";
import {transpileJavaScript, type FileReference, type ImportReference, type Transpile} from "./javascript.js";
import {type FileReference, type ImportReference, type Transpile, transpileJavaScript} from "./javascript.js";
import {transpileTag} from "./tag.js";
import {dirname, join} from "node:path";

export interface ReadMarkdownResult {
contents: string;
Expand Down
2 changes: 1 addition & 1 deletion src/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {basename, dirname, extname, join} from "node:path";
import {readConfig} from "./config.js";
import {isNodeError} from "./error.js";
import {visitFiles} from "./files.js";
import {parseMarkdown, type ParseResult} from "./markdown.js";
import {type ParseResult, parseMarkdown} from "./markdown.js";
import {type RenderOptions} from "./render.js";

export async function readPages(root: string): Promise<NonNullable<RenderOptions["pages"]>> {
Expand Down
10 changes: 5 additions & 5 deletions src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {existsSync, watch, type FSWatcher, type WatchListener} from "node:fs";
import {type FSWatcher, type WatchListener, existsSync, watch} from "node:fs";
import {access, constants, readFile, stat} from "node:fs/promises";
import {createServer, type IncomingMessage, type RequestListener} from "node:http";
import {type IncomingMessage, type RequestListener, createServer} from "node:http";
import {basename, dirname, extname, join, normalize} from "node:path";
import {fileURLToPath} from "node:url";
import {parseArgs} from "node:util";
import send from "send";
import {WebSocketServer, type WebSocket} from "ws";
import {type WebSocket, WebSocketServer} from "ws";
import {Loader} from "./dataloader.js";
import {HttpError, isHttpError, isNodeError} from "./error.js";
import {maybeStat} from "./files.js";
import {diffMarkdown, readMarkdown, type ParseResult} from "./markdown.js";
import {type ParseResult, diffMarkdown, readMarkdown} from "./markdown.js";
import {readPages} from "./navigation.js";
import {renderPreview} from "./render.js";
import {makeCLIResolver, type CellResolver} from "./resolver.js";
import {type CellResolver, makeCLIResolver} from "./resolver.js";

const publicRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "public");

Expand Down
4 changes: 2 additions & 2 deletions src/render.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {dirname, join} from "node:path";
import {computeHash} from "./hash.js";
import {type FileReference, type ImportReference} from "./javascript.js";
import {resolveImport} from "./javascript/imports.js";
import {parseMarkdown, type CellPiece, type ParseResult} from "./markdown.js";
import {type FileReference, type ImportReference} from "./javascript.js";
import {type CellPiece, type ParseResult, parseMarkdown} from "./markdown.js";

export interface Render {
html: string;
Expand Down
2 changes: 1 addition & 1 deletion test/build-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {difference} from "d3-array";
import assert from "node:assert";
import {existsSync, readdirSync, statSync} from "node:fs";
import {readFile, rm} from "node:fs/promises";
import {join, normalize, relative} from "node:path";
import {difference} from "d3-array";
import {build} from "../src/build.js";

describe("build", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/hash-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {computeHash} from "../src/hash.js";
import assert from "node:assert";
import {computeHash} from "../src/hash.js";

describe("computeHash(content)", () => {
it("returns the expected result", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/markdown-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import assert from "node:assert";
import {readdirSync, statSync} from "node:fs";
import {mkdir, readFile, unlink, writeFile} from "node:fs/promises";
import {basename, join, resolve} from "node:path";
import deepEqual from "fast-deep-equal";
import {isNodeError} from "../src/error.js";
import {type ParseResult, parseMarkdown} from "../src/markdown.js";
import deepEqual from "fast-deep-equal";

describe("parseMarkdown(input)", () => {
const inputRoot = "test/input";
Expand Down
Loading