mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
adbffc0734
* chore: clear mechanical lint warnings Drops 44 oxlint warnings (559 → 515) by fixing easy mechanical rules across the codebase: no-useless-escape, no-duplicate-type-constituents, no-redundant-type-constituents, no-unused-expressions, no-meaningless-void-operator, require-array-sort-compare, await-thenable. * chore: drop callback parameter from useCallback deps The `open` argument is a parameter of the callback, not a closed-over variable, so it doesn't belong in the deps array. * chore: promote cleared lint rules to errors Promotes the rules cleared in this PR from warn to error so future violations fail the lint: - no-unused-expressions - typescript/await-thenable - typescript/no-duplicate-type-constituents - typescript/no-meaningless-void-operator - typescript/require-array-sort-compare Removes the override that suppressed no-useless-escape on source files (the global rule is already error) and fixes the 21 escape violations that this exposed in regex character classes and template literals. * chore: address PR review feedback - usePinnedDocuments: simplify UrlId to plain string instead of the intersection trick. - PlantUML embed: move - to end of character class so it's a literal hyphen rather than a range operator. - checkboxes: type token params as Token | undefined to match the actual call sites that pass tokens[index - 2] etc.
89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
import isMarkdown from "./isMarkdown";
|
|
|
|
test("returns false for an empty string", () => {
|
|
expect(isMarkdown("")).toBe(false);
|
|
});
|
|
|
|
test("returns false for plain text", () => {
|
|
expect(isMarkdown("plain text")).toBe(false);
|
|
});
|
|
|
|
test("returns true for bullet list", () => {
|
|
expect(
|
|
isMarkdown(`- item one
|
|
- item two
|
|
- nested item`)
|
|
).toBe(true);
|
|
});
|
|
|
|
test("returns true for code fence", () => {
|
|
expect(
|
|
isMarkdown(`\`\`\`javascript
|
|
this is code
|
|
\`\`\``)
|
|
).toBe(true);
|
|
});
|
|
|
|
test("returns true for latex fence", () => {
|
|
expect(isMarkdown(`$i$`)).toBe(true);
|
|
expect(
|
|
isMarkdown(`$0.00
|
|
random content
|
|
$1.00`)
|
|
).toBe(false);
|
|
});
|
|
|
|
test("returns false for non-closed fence", () => {
|
|
expect(
|
|
isMarkdown(`\`\`\`
|
|
this is not code
|
|
`)
|
|
).toBe(false);
|
|
});
|
|
|
|
test("returns true for heading", () => {
|
|
expect(isMarkdown(`# Heading 1`)).toBe(true);
|
|
expect(isMarkdown(`## Heading 2`)).toBe(true);
|
|
expect(isMarkdown(`### Heading 3`)).toBe(true);
|
|
});
|
|
|
|
test("returns true for table", () => {
|
|
expect(
|
|
isMarkdown(`
|
|
|NAME|TYPE|CLUSTER-IP|EXTERNAL-IP|PORT(S)|AGE|
|
|
|-|-|-|-|-|-|
|
|
|rancher-webhook|ClusterIP|10.43.198.97|<none>|443/TCP|258d|
|
|
|rancher|ClusterIP|10.43.50.214|<none>|80/TCP,443/TCP|258d|
|
|
`)
|
|
).toBe(true);
|
|
|
|
expect(
|
|
isMarkdown(`
|
|
| Product | Price ($) | Inventory |
|
|
|---------|----------:|----------:|
|
|
| Laptop | 899.99 | 52 |
|
|
| Wireless Mouse | 24.99 | 120 |`)
|
|
).toBe(true);
|
|
});
|
|
|
|
test("returns false for hashtag", () => {
|
|
expect(isMarkdown(`Test #hashtag`)).toBe(false);
|
|
expect(isMarkdown(` #hashtag`)).toBe(false);
|
|
});
|
|
|
|
test("returns true for absolute link", () => {
|
|
expect(isMarkdown(`[title](http://www.google.com)`)).toBe(true);
|
|
});
|
|
|
|
test("returns true for relative link", () => {
|
|
expect(isMarkdown(`[title](/doc/mydoc-234tnes)`)).toBe(true);
|
|
});
|
|
|
|
test("returns true for relative image", () => {
|
|
expect(isMarkdown(``)).toBe(true);
|
|
});
|
|
|
|
test("returns true for absolute image", () => {
|
|
expect(isMarkdown(``)).toBe(true);
|
|
});
|