mirror of
https://github.com/danog/sass-site.git
synced 2024-11-26 12:04:40 +01:00
Remove old eslint/prettier rules
This commit is contained in:
parent
792513028a
commit
97e4f71a0c
54
.eslintrc.js
54
.eslintrc.js
@ -1,54 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
sourceType: 'script',
|
||||
ecmaVersion: 2021,
|
||||
tsconfigRootDir: __dirname,
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
node: true,
|
||||
},
|
||||
plugins: ['import', 'simple-import-sort', '@typescript-eslint'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:import/recommended',
|
||||
'plugin:import/typescript',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
],
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
project: ['tsconfig.json'],
|
||||
},
|
||||
},
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts'],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
project: ['tsconfig.json'],
|
||||
},
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
],
|
||||
rules: {
|
||||
'import/order': 0,
|
||||
'sort-imports': 0,
|
||||
'simple-import-sort/imports': 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
rules: {
|
||||
'import/order': 1,
|
||||
'simple-import-sort/imports': 0,
|
||||
'@typescript-eslint/no-var-requires': 0,
|
||||
'no-console': 1,
|
||||
'no-warning-comments': [1, { terms: ['todo', 'fixme', '@@@'] }],
|
||||
},
|
||||
};
|
@ -1,3 +1,11 @@
|
||||
{
|
||||
"extends": "./node_modules/gts/"
|
||||
"extends": "./node_modules/gts/",
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2021
|
||||
},
|
||||
"rules": {
|
||||
"node/no-unpublished-import": "off",
|
||||
"node/no-unpublished-require": "off"
|
||||
}
|
||||
}
|
||||
|
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
- package-ecosystem: 'yarn'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'weekly'
|
@ -1,2 +0,0 @@
|
||||
singleQuote: true
|
||||
trailingComma: all
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { EleventyRenderPlugin } = require('@11ty/eleventy');
|
||||
const {EleventyRenderPlugin} = require('@11ty/eleventy');
|
||||
const {
|
||||
absoluteUrl,
|
||||
convertHtmlToAbsoluteUrls,
|
||||
@ -13,13 +13,13 @@ const yaml = require('js-yaml');
|
||||
const componentsPlugin =
|
||||
require('./source/helpers/components/index.ts').default;
|
||||
const datesPlugin = require('./source/helpers/dates.ts').default;
|
||||
const { liquidEngine, markdownEngine } = require('./source/helpers/engines.ts');
|
||||
const {liquidEngine, markdownEngine} = require('./source/helpers/engines.ts');
|
||||
const pagesPlugin = require('./source/helpers/pages.ts').default;
|
||||
const typePlugin = require('./source/helpers/type.ts').default;
|
||||
const functionPlugin = require('./source/helpers/function.ts').default;
|
||||
|
||||
/** @param {import('@11ty/eleventy').UserConfig} eleventyConfig */
|
||||
module.exports = (eleventyConfig) => {
|
||||
module.exports = eleventyConfig => {
|
||||
eleventyConfig.addPassthroughCopy('source/assets/dist');
|
||||
eleventyConfig.addPassthroughCopy('source/assets/img');
|
||||
eleventyConfig.addPassthroughCopy('source/favicon.ico');
|
||||
@ -34,9 +34,7 @@ module.exports = (eleventyConfig) => {
|
||||
|
||||
eleventyConfig.setLibrary('liquid', liquidEngine);
|
||||
eleventyConfig.setLibrary('md', markdownEngine);
|
||||
eleventyConfig.addDataExtension('yml, yaml', (contents) =>
|
||||
yaml.load(contents),
|
||||
);
|
||||
eleventyConfig.addDataExtension('yml, yaml', contents => yaml.load(contents));
|
||||
eleventyConfig.addDataExtension('ts', (_, filepath) => require(filepath));
|
||||
|
||||
// register filters and shortcodes
|
||||
@ -50,12 +48,12 @@ module.exports = (eleventyConfig) => {
|
||||
eleventyConfig.addLiquidFilter('absoluteUrl', absoluteUrl);
|
||||
eleventyConfig.addLiquidFilter(
|
||||
'getNewestCollectionItemDate',
|
||||
getNewestCollectionItemDate,
|
||||
getNewestCollectionItemDate
|
||||
);
|
||||
eleventyConfig.addLiquidFilter('dateToRfc3339', dateToRfc3339);
|
||||
eleventyConfig.addLiquidFilter(
|
||||
'htmlToAbsoluteUrls',
|
||||
convertHtmlToAbsoluteUrls,
|
||||
convertHtmlToAbsoluteUrls
|
||||
);
|
||||
|
||||
// other plugins
|
||||
|
16
package.json
16
package.json
@ -62,21 +62,16 @@
|
||||
"@types/markdown-it-footnote": "^3.0.0",
|
||||
"@types/node": "^16",
|
||||
"@types/prismjs": "^1.26.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
||||
"@typescript-eslint/parser": "^5.60.0",
|
||||
"@types/semver": "^7.5.0",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"date-fns": "^2.30.0",
|
||||
"deep-equal": "^2.2.1",
|
||||
"eslint": "^8.43.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.5",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-simple-import-sort": "^10.0.0",
|
||||
"gts": "^3.1.1",
|
||||
"jquery": "^3.7.0",
|
||||
"jquery-ui": "^1.13.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kleur": "^4.1.5",
|
||||
"liquidjs": "^10.8.3",
|
||||
"lorem-ipsum": "^2.0.8",
|
||||
"markdown-it": "^13.0.1",
|
||||
"markdown-it-anchor": "^8.6.7",
|
||||
@ -100,12 +95,5 @@
|
||||
},
|
||||
"resolutions": {
|
||||
"tslib": ">=2"
|
||||
},
|
||||
"yarn-upgrade-all": {
|
||||
"ignore": [
|
||||
"@sindresorhus/slugify",
|
||||
"@types/node",
|
||||
"strip-indent"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
const { babel } = require('@rollup/plugin-babel');
|
||||
const {babel} = require('@rollup/plugin-babel');
|
||||
const commonjs = require('@rollup/plugin-commonjs');
|
||||
const inject = require('@rollup/plugin-inject');
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
||||
const {nodeResolve} = require('@rollup/plugin-node-resolve');
|
||||
const terser = require('@rollup/plugin-terser');
|
||||
const { defineConfig } = require('rollup');
|
||||
const {defineConfig} = require('rollup');
|
||||
|
||||
const prod = process.env.BABEL_ENV === 'production';
|
||||
|
||||
@ -13,7 +13,7 @@ const plugins = [
|
||||
browser: true,
|
||||
}),
|
||||
commonjs(),
|
||||
babel({ extensions: ['.js', '.ts'], babelHelpers: 'bundled' }),
|
||||
babel({extensions: ['.js', '.ts'], babelHelpers: 'bundled'}),
|
||||
inject({
|
||||
$: 'jquery',
|
||||
jQuery: 'jquery',
|
||||
|
@ -1,12 +1,9 @@
|
||||
import {
|
||||
spawn as nodeSpawn,
|
||||
SpawnOptionsWithoutStdio,
|
||||
} from 'node:child_process';
|
||||
import {spawn as nodeSpawn, SpawnOptionsWithoutStdio} from 'node:child_process';
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
import deepEqual from 'deep-equal';
|
||||
import kleur from 'kleur';
|
||||
import { compare, parse } from 'semver';
|
||||
import {compare, parse} from 'semver';
|
||||
|
||||
type VersionCache = Record<string, string>;
|
||||
|
||||
@ -19,7 +16,7 @@ const VERSION_CACHE_PATH = './source/_data/versionCache.json';
|
||||
const spawn = (
|
||||
cmd: string,
|
||||
args: string[],
|
||||
options: SpawnOptionsWithoutStdio,
|
||||
options: SpawnOptionsWithoutStdio
|
||||
) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = nodeSpawn(cmd, args, options);
|
||||
@ -64,7 +61,7 @@ const getCacheFile = async () => {
|
||||
*/
|
||||
const writeCacheFile = async (cache: VersionCache) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(kleur.green(`[11ty] Writing version cache file...`));
|
||||
console.info(kleur.green('[11ty] Writing version cache file...'));
|
||||
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
|
||||
};
|
||||
|
||||
@ -79,7 +76,7 @@ const getLatestVersion = async (repo: string) => {
|
||||
stdout = (await spawn(
|
||||
'git',
|
||||
['ls-remote', '--tags', '--refs', `https://github.com/${repo}`],
|
||||
{ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } },
|
||||
{env: {...process.env, GIT_TERMINAL_PROMPT: '0'}}
|
||||
)) as string;
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
@ -92,7 +89,7 @@ const getLatestVersion = async (repo: string) => {
|
||||
};
|
||||
const version = stdout
|
||||
.split('\n')
|
||||
.map((line) => line.split('refs/tags/').at(-1) ?? '')
|
||||
.map(line => line.split('refs/tags/').at(-1) ?? '')
|
||||
.filter(isNotPreRelease)
|
||||
.sort(compare)
|
||||
.at(-1);
|
||||
@ -108,16 +105,16 @@ module.exports = async () => {
|
||||
const cache = await getCacheFile();
|
||||
|
||||
const versions = await Promise.all(
|
||||
repos.map(async (repo) => [
|
||||
repos.map(async repo => [
|
||||
repo,
|
||||
cache[repo] ?? (await getLatestVersion(repo)),
|
||||
]),
|
||||
])
|
||||
);
|
||||
const data = Object.fromEntries(
|
||||
versions.map(([repo, version]) => [
|
||||
repo.replace('sass/', ''),
|
||||
{ version, url: `https://github.com/${repo}/releases/tag/${version}` },
|
||||
]),
|
||||
{version, url: `https://github.com/${repo}/releases/tag/${version}`},
|
||||
])
|
||||
);
|
||||
|
||||
const nextCache = Object.fromEntries(versions) as VersionCache;
|
||||
|
@ -1,7 +1,8 @@
|
||||
$(function () {
|
||||
$(() => {
|
||||
$('.impl-status').each(function () {
|
||||
const statusBar = $(this);
|
||||
const expandLink = statusBar.find('a');
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (expandLink == null) {
|
||||
return;
|
||||
}
|
||||
@ -12,7 +13,7 @@ $(function () {
|
||||
}
|
||||
|
||||
details.hide();
|
||||
expandLink.on('click', function () {
|
||||
expandLink.on('click', () => {
|
||||
details.toggle();
|
||||
expandLink.toggleClass('expanded');
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
$(function () {
|
||||
$(() => {
|
||||
$('.sl-c-list-navigation-wrapper--collapsible li > ul')
|
||||
.parent()
|
||||
.children('a')
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Documentation Nav Scroll
|
||||
$(function () {
|
||||
$(() => {
|
||||
// Vars
|
||||
const nav = $('.sl-c-list-navigation-wrapper');
|
||||
const sticky = nav.offset();
|
||||
@ -18,7 +18,7 @@ $(function () {
|
||||
};
|
||||
|
||||
// When scrolling the page, execute stickyNav
|
||||
$(window).on('scroll', function () {
|
||||
$(window).on('scroll', () => {
|
||||
stickyNav();
|
||||
});
|
||||
|
||||
|
@ -339,7 +339,7 @@ const redirects: Record<string, Record<string, string>> = {
|
||||
},
|
||||
};
|
||||
|
||||
const { pathname, hash } = window.location;
|
||||
const {pathname, hash} = window.location;
|
||||
const match = redirects[pathname]?.[hash];
|
||||
if (match) {
|
||||
window.location.href = match;
|
||||
|
@ -1,4 +1,4 @@
|
||||
$(function () {
|
||||
$(() => {
|
||||
$('.code-example').each(function () {
|
||||
const figure = $(this);
|
||||
|
||||
|
@ -11,12 +11,12 @@ export const renderPermalink: anchor.PermalinkGenerator = (
|
||||
slug,
|
||||
opts: anchor.LinkInsideHeaderPermalinkOptions,
|
||||
state,
|
||||
idx,
|
||||
idx
|
||||
) => {
|
||||
// https://github.com/valeriangalliat/markdown-it-anchor/blob/649582d58185b00cfb2ceee9b6b4cd6aafc645b7/permalink.js#L148-L151
|
||||
const title = state.tokens[idx + 1]?.children
|
||||
?.filter(
|
||||
(token: Token) => token.type === 'text' || token.type === 'code_inline',
|
||||
(token: Token) => token.type === 'text' || token.type === 'code_inline'
|
||||
)
|
||||
.reduce((acc, t) => acc + t.content, '');
|
||||
|
||||
@ -37,7 +37,7 @@ export const renderPermalink: anchor.PermalinkGenerator = (
|
||||
}),
|
||||
Object.assign(new state.Token('html_inline', '', 0), {
|
||||
content: opts.symbol,
|
||||
meta: { isPermalinkSymbol: true },
|
||||
meta: {isPermalinkSymbol: true},
|
||||
}),
|
||||
new state.Token('link_close', 'a', -1),
|
||||
];
|
||||
|
@ -1,7 +1,7 @@
|
||||
import sass from 'sass';
|
||||
import stripIndent from 'strip-indent';
|
||||
|
||||
import { liquidEngine } from '../engines';
|
||||
import {liquidEngine} from '../engines';
|
||||
|
||||
/**
|
||||
* Renders a code example.
|
||||
@ -55,7 +55,7 @@ export default async function codeExample(
|
||||
contents: string,
|
||||
exampleName: string,
|
||||
autogenCSS = true,
|
||||
syntax: 'sass' | 'scss' | null = null,
|
||||
syntax: 'sass' | 'scss' | null = null
|
||||
) {
|
||||
if (!exampleName) {
|
||||
throw new Error('`{% codeExample %}` tags require a unique name.');
|
||||
@ -70,7 +70,7 @@ export default async function codeExample(
|
||||
const generateCodeExample = (
|
||||
text: string,
|
||||
autogenCSS: boolean,
|
||||
syntax: 'sass' | 'scss' | null,
|
||||
syntax: 'sass' | 'scss' | null
|
||||
) => {
|
||||
const contents = stripIndent(text);
|
||||
const splitContents = contents.split('\n===\n');
|
||||
@ -96,9 +96,9 @@ const generateCodeExample = (
|
||||
}
|
||||
|
||||
const scssExamples =
|
||||
scssContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
||||
scssContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||
const sassExamples =
|
||||
sassContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
||||
sassContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||
|
||||
if (!cssContents && autogenCSS) {
|
||||
const sections = scssContents ? scssExamples : sassExamples;
|
||||
@ -114,18 +114,18 @@ const generateCodeExample = (
|
||||
}
|
||||
|
||||
const cssExamples =
|
||||
cssContents?.split('\n---\n').map((str) => str.trim()) ?? [];
|
||||
cssContents?.split('\n---\n').map(str => str.trim()) ?? [];
|
||||
|
||||
const { scssPaddings, sassPaddings, cssPaddings } = getPaddings(
|
||||
const {scssPaddings, sassPaddings, cssPaddings} = getPaddings(
|
||||
scssExamples,
|
||||
sassExamples,
|
||||
cssExamples,
|
||||
cssExamples
|
||||
);
|
||||
|
||||
const { canSplit, maxSourceWidth, maxCSSWidth } = getCanSplit(
|
||||
const {canSplit, maxSourceWidth, maxCSSWidth} = getCanSplit(
|
||||
scssExamples,
|
||||
sassExamples,
|
||||
cssExamples,
|
||||
cssExamples
|
||||
);
|
||||
let splitLocation: number | null = null;
|
||||
if (canSplit) {
|
||||
@ -156,7 +156,7 @@ const generateCodeExample = (
|
||||
const getPaddings = (
|
||||
scssExamples: string[],
|
||||
sassExamples: string[],
|
||||
cssExamples: string[],
|
||||
cssExamples: string[]
|
||||
) => {
|
||||
const scssPaddings: number[] = [];
|
||||
const sassPaddings: number[] = [];
|
||||
@ -164,9 +164,9 @@ const getPaddings = (
|
||||
const maxSections = Math.max(
|
||||
scssExamples.length,
|
||||
sassExamples.length,
|
||||
cssExamples.length,
|
||||
cssExamples.length
|
||||
);
|
||||
Array.from({ length: maxSections }).forEach((_, i) => {
|
||||
Array.from({length: maxSections}).forEach((_, i) => {
|
||||
const scssLines = (scssExamples[i] || '').split('\n').length;
|
||||
const sassLines = (sassExamples[i] || '').split('\n').length;
|
||||
const cssLines = (cssExamples[i] || '').split('\n').length;
|
||||
@ -181,7 +181,7 @@ const getPaddings = (
|
||||
const maxLines = Math.max(
|
||||
isLastScssSection ? 0 : scssLines,
|
||||
isLastSassSection ? 0 : sassLines,
|
||||
isLastCssSection ? 0 : cssLines,
|
||||
isLastCssSection ? 0 : cssLines
|
||||
);
|
||||
|
||||
scssPaddings.push(
|
||||
@ -191,7 +191,7 @@ const getPaddings = (
|
||||
comparisonB: cssExamples.slice(i),
|
||||
lines: scssLines,
|
||||
maxLines,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
sassPaddings.push(
|
||||
@ -201,7 +201,7 @@ const getPaddings = (
|
||||
comparisonB: cssExamples.slice(i),
|
||||
lines: sassLines,
|
||||
maxLines,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
cssPaddings.push(
|
||||
@ -211,11 +211,11 @@ const getPaddings = (
|
||||
comparisonB: sassExamples.slice(i),
|
||||
lines: cssLines,
|
||||
maxLines,
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return { scssPaddings, sassPaddings, cssPaddings };
|
||||
return {scssPaddings, sassPaddings, cssPaddings};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -260,7 +260,7 @@ const getTotalPadding = (sections1: string[], sections2: string[]) => {
|
||||
sum +
|
||||
Math.max(
|
||||
(sections1[i] || '').split('\n').length,
|
||||
(sections2[i] || '').split('\n').length,
|
||||
(sections2[i] || '').split('\n').length
|
||||
) +
|
||||
2
|
||||
);
|
||||
@ -270,15 +270,13 @@ const getTotalPadding = (sections1: string[], sections2: string[]) => {
|
||||
const getCanSplit = (
|
||||
scssExamples: string[],
|
||||
sassExamples: string[],
|
||||
cssExamples: string[],
|
||||
cssExamples: string[]
|
||||
) => {
|
||||
const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap(
|
||||
(source) => source.split('\n').map((line) => line.length),
|
||||
source => source.split('\n').map(line => line.length)
|
||||
);
|
||||
const cssSourceLengths = cssExamples.length
|
||||
? cssExamples.flatMap((source) =>
|
||||
source.split('\n').map((line) => line.length),
|
||||
)
|
||||
? cssExamples.flatMap(source => source.split('\n').map(line => line.length))
|
||||
: [0];
|
||||
|
||||
const maxSourceWidth = Math.max(...exampleSourceLengths);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import stripIndent from 'strip-indent';
|
||||
|
||||
import { liquidEngine } from '../engines';
|
||||
import {liquidEngine} from '../engines';
|
||||
|
||||
/**
|
||||
* Renders a status dashboard for each implementation's support for a feature.
|
||||
@ -42,11 +42,11 @@ interface CompatibilityOptions {
|
||||
|
||||
const extend = <
|
||||
K extends keyof CompatibilityOptions,
|
||||
V extends CompatibilityOptions[K],
|
||||
V extends CompatibilityOptions[K]
|
||||
>(
|
||||
value: V,
|
||||
obj: CompatibilityOptions,
|
||||
key: K,
|
||||
key: K
|
||||
) => {
|
||||
obj[key] = value;
|
||||
};
|
||||
@ -72,13 +72,13 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
||||
if (typeof arg !== 'string') {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
`Received non-string argument to {% compatibility %} tag: ${arg}`,
|
||||
`Received non-string argument to {% compatibility %} tag: ${arg}`
|
||||
);
|
||||
}
|
||||
const match = arg.match(keyValueRegex);
|
||||
if (!match) {
|
||||
throw new Error(
|
||||
`Arguments should be in the format 'key:value'; received ${arg}.`,
|
||||
`Arguments should be in the format 'key:value'; received ${arg}.`
|
||||
);
|
||||
}
|
||||
const key: string = match[1].trim();
|
||||
@ -90,7 +90,7 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
||||
throw new Error(
|
||||
`Unable to parse argument ${key} with value ${
|
||||
value as string
|
||||
}. Try wrapping it in double quotes: ${key}:"${value as string}"`,
|
||||
}. Try wrapping it in double quotes: ${key}:"${value as string}"`
|
||||
);
|
||||
}
|
||||
if (key && Object.hasOwn(opts, key)) {
|
||||
@ -98,7 +98,7 @@ const parseCompatibilityOpts = (...args: string[]): CompatibilityOptions => {
|
||||
} else {
|
||||
throw new Error(
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
`Received unexpected argument to {% compatibility %} tag: ${arg}`,
|
||||
`Received unexpected argument to {% compatibility %} tag: ${arg}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { highlight, languages } from 'prismjs';
|
||||
import {highlight, languages} from 'prismjs';
|
||||
import PrismLoader from 'prismjs/components/index';
|
||||
import stripIndent from 'strip-indent';
|
||||
|
||||
import { liquidEngine } from '../engines';
|
||||
import { default as codeExample } from './codeExample';
|
||||
import { compatibility, implStatus } from './compatibility';
|
||||
import { getDocTocData, getToc } from './toc';
|
||||
import {liquidEngine} from '../engines';
|
||||
import {default as codeExample} from './codeExample';
|
||||
import {compatibility, implStatus} from './compatibility';
|
||||
import {getDocTocData, getToc} from './toc';
|
||||
|
||||
export { codeExample };
|
||||
export { compatibility, implStatus };
|
||||
export { getDocTocData, getToc };
|
||||
export {codeExample};
|
||||
export {compatibility, implStatus};
|
||||
export {getDocTocData, getToc};
|
||||
|
||||
/**
|
||||
* Returns HTML for a fun fact that's not directly relevant to the main
|
||||
|
@ -9,11 +9,11 @@ type TOCItem = {
|
||||
*/
|
||||
export const getDocTocData = (data: TOCItem) => {
|
||||
const text = Object.keys(data).filter(
|
||||
(key) => ![':children', ':expanded'].includes(key),
|
||||
key => ![':children', ':expanded'].includes(key)
|
||||
)[0];
|
||||
const href = data[text] as string;
|
||||
const expanded = Boolean(data[':expanded']);
|
||||
return { text, href, expanded };
|
||||
return {text, href, expanded};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ export const getToc = (html: string, topLevelTotal: number): TOCItem[] => {
|
||||
const level = parseInt(h.name[1], 10);
|
||||
const title = $(h).html() as string;
|
||||
const id = $(h).attr('id') as string;
|
||||
const tocItem: TOCItem = { [title]: `#${id}` };
|
||||
const tocItem: TOCItem = {[title]: `#${id}`};
|
||||
byLevel[level].push(tocItem);
|
||||
if (level === 2) {
|
||||
toc.push(tocItem);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import slugify from '@sindresorhus/slugify';
|
||||
import { Liquid } from 'liquidjs';
|
||||
import {Liquid} from 'liquidjs';
|
||||
import markdown from 'markdown-it';
|
||||
import markdownAnchor from 'markdown-it-anchor';
|
||||
import markdownItAttrs from 'markdown-it-attrs';
|
||||
@ -7,7 +7,7 @@ import markdownDefList from 'markdown-it-deflist';
|
||||
import markdownItFootnote from 'markdown-it-footnote';
|
||||
import path from 'path';
|
||||
|
||||
import { renderPermalink } from './components/anchors';
|
||||
import {renderPermalink} from './components/anchors';
|
||||
|
||||
/**
|
||||
* Returns Markdown engine with custom configuration and plugins.
|
||||
@ -27,7 +27,7 @@ export const markdownEngine = markdown({
|
||||
.use(markdownAnchor, {
|
||||
level: 2,
|
||||
permalink: renderPermalink,
|
||||
slugify: (s) => slugify(s),
|
||||
slugify: s => slugify(s),
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as cheerio from 'cheerio';
|
||||
import stripIndent from 'strip-indent';
|
||||
|
||||
import { codeBlock } from './components';
|
||||
import { liquidEngine } from './engines';
|
||||
import {codeBlock} from './components';
|
||||
import {liquidEngine} from './engines';
|
||||
|
||||
const links: Record<string, string> = {
|
||||
number: '/documentation/values/numbers',
|
||||
@ -21,7 +21,7 @@ const links: Record<string, string> = {
|
||||
const returnTypeLink = (returnType: string) =>
|
||||
returnType
|
||||
.split('|')
|
||||
.map((type) => {
|
||||
.map(type => {
|
||||
type = type.trim();
|
||||
const link = links[type];
|
||||
if (!link) {
|
||||
@ -49,7 +49,7 @@ export function _function(content: string, ...signatures: string[]) {
|
||||
|
||||
// Highlight each signature
|
||||
const names: string[] = [];
|
||||
const highlightedSignatures = signatures.map((signature) => {
|
||||
const highlightedSignatures = signatures.map(signature => {
|
||||
signature = stripIndent(signature).trim();
|
||||
const [name] = signature.split('(', 2);
|
||||
const nameWithoutNamespace = name.split('.').at(-1) || name;
|
||||
@ -63,7 +63,7 @@ export function _function(content: string, ...signatures: string[]) {
|
||||
names.push(nameWithoutNamespace);
|
||||
const nameEl = signatureElements
|
||||
.filter((index, element) => {
|
||||
return $(element).text() == nameWithoutNamespace;
|
||||
return $(element).text() === nameWithoutNamespace;
|
||||
})
|
||||
.eq(0);
|
||||
nameEl.addClass('docSearch-function');
|
||||
@ -71,7 +71,7 @@ export function _function(content: string, ...signatures: string[]) {
|
||||
}
|
||||
return signatureElements
|
||||
.toArray()
|
||||
.map((el) => $.html(el))
|
||||
.map(el => $.html(el))
|
||||
.join('')
|
||||
.trim();
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { LoremIpsum } from 'lorem-ipsum';
|
||||
import {LoremIpsum} from 'lorem-ipsum';
|
||||
import stripIndent from 'strip-indent';
|
||||
import truncate from 'truncate-html';
|
||||
import { typogrify } from 'typogr';
|
||||
import {typogrify} from 'typogr';
|
||||
|
||||
import { markdownEngine } from './engines';
|
||||
import {markdownEngine} from './engines';
|
||||
|
||||
const lorem = new LoremIpsum();
|
||||
|
||||
@ -33,7 +33,7 @@ export const getLorem = (type: string, number = 1) => {
|
||||
* @see https://github.com/oe/truncate-html
|
||||
*/
|
||||
export const truncateHTML = (html: string, words = 170) =>
|
||||
truncate(html, words, { byWords: true, keepWhitespaces: true });
|
||||
truncate(html, words, {byWords: true, keepWhitespaces: true});
|
||||
|
||||
/**
|
||||
* Renders block of Markdown into HTML.
|
||||
|
@ -1,4 +1,5 @@
|
||||
const { DefaultTheme, DefaultThemeRenderContext, JSX } = require('typedoc');
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const {DefaultTheme, DefaultThemeRenderContext, JSX} = require('typedoc');
|
||||
|
||||
function bind(fn, first) {
|
||||
return (...r) => fn(first, ...r);
|
||||
@ -11,7 +12,7 @@ function bind(fn, first) {
|
||||
function parseCompatibility(input) {
|
||||
return input
|
||||
.split(',')
|
||||
.map((arg) => `'${arg.trim()}'`)
|
||||
.map(arg => `'${arg.trim()}'`)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
@ -21,16 +22,16 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
// doesn't work. Instead, we emit each overload as a separate entry with its
|
||||
// own panel.
|
||||
oldMember = this.member;
|
||||
member = bind(function (context, props) {
|
||||
member = bind((context, props) => {
|
||||
const signatures = props?.signatures;
|
||||
if (signatures && signatures.length > 1) {
|
||||
const element = JSX.createElement(
|
||||
JSX.Fragment,
|
||||
null,
|
||||
...signatures.map((signature) => {
|
||||
...signatures.map(signature => {
|
||||
props.signatures = [signature];
|
||||
return context.oldMember(props);
|
||||
}),
|
||||
})
|
||||
);
|
||||
props.signatures = signatures;
|
||||
return element;
|
||||
@ -44,7 +45,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
comment = bind((context, props) => {
|
||||
if (!props.comment) return;
|
||||
const compatibilityTags = props.comment.blockTags.filter(
|
||||
(tag) => tag.tag === '@compatibility',
|
||||
tag => tag.tag === '@compatibility'
|
||||
);
|
||||
props.comment.removeTags('@compatibility');
|
||||
|
||||
@ -52,7 +53,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
if (!parent) return;
|
||||
|
||||
parent.children.unshift(
|
||||
...compatibilityTags.map((compat) => {
|
||||
...compatibilityTags.map(compat => {
|
||||
// Compatibility tags should have a single text block.
|
||||
const text = compat.content[0].text;
|
||||
|
||||
@ -60,13 +61,13 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
// after that is the contents of the block.
|
||||
const lineBreak = text.indexOf('\n');
|
||||
const compatibilityArgs = parseCompatibility(
|
||||
lineBreak === -1 ? text : text.substring(0, lineBreak),
|
||||
lineBreak === -1 ? text : text.substring(0, lineBreak)
|
||||
);
|
||||
const restOfFirst =
|
||||
lineBreak === -1 ? null : text.substring(lineBreak + 1);
|
||||
|
||||
const rest = [
|
||||
...(restOfFirst ? [{ kind: 'text', text: restOfFirst }] : []),
|
||||
...(restOfFirst ? [{kind: 'text', text: restOfFirst}] : []),
|
||||
...compat.content.slice(1),
|
||||
];
|
||||
|
||||
@ -76,7 +77,7 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
(rest ? context.markdown(rest) : '') +
|
||||
'{% endcompatibility %}',
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
return parent;
|
||||
@ -91,25 +92,25 @@ class SassSiteRenderContext extends DefaultThemeRenderContext {
|
||||
.oldMarkdown(text)
|
||||
.replace(
|
||||
/<p><strong>Heads up!<\/strong>([^]*?)<\/p>/g,
|
||||
'{% headsUp %}$1{% endheadsUp %}',
|
||||
'{% headsUp %}$1{% endheadsUp %}'
|
||||
)
|
||||
.replace(
|
||||
/<p><strong>Fun fact!<\/strong>([^]*?)<\/p>/g,
|
||||
'{% funFact %}$1{% endfunFact %}',
|
||||
'{% funFact %}$1{% endfunFact %}'
|
||||
),
|
||||
this,
|
||||
this
|
||||
);
|
||||
|
||||
// Relative URLs don't work well for index pages since they can be rendered at
|
||||
// different directory levels, so we just convert all URLs to absolute to be
|
||||
// safe.
|
||||
oldUrlTo = this.urlTo;
|
||||
urlTo = bind(function (context, reflection) {
|
||||
urlTo = bind((context, reflection) => {
|
||||
const relative = context.oldUrlTo(reflection);
|
||||
|
||||
const absolute = new URL(
|
||||
relative,
|
||||
`relative:///documentation/js-api/${context.theme.markedPlugin.location}`,
|
||||
`relative:///documentation/js-api/${context.theme.markedPlugin.location}`
|
||||
);
|
||||
absolute.pathname = absolute.pathname
|
||||
.replace(/\.html$/, '')
|
||||
@ -123,7 +124,7 @@ class SassSiteTheme extends DefaultTheme {
|
||||
this.contextCache ??= new SassSiteRenderContext(
|
||||
this,
|
||||
page,
|
||||
this.application.options,
|
||||
this.application.options
|
||||
);
|
||||
return this.contextCache;
|
||||
}
|
||||
@ -135,7 +136,7 @@ class SassSiteTheme extends DefaultTheme {
|
||||
// render title on its own.
|
||||
const breadcrumb = page.model.parent
|
||||
? `<ul class="tsd-breadcrumb">${JSX.renderElement(
|
||||
context.breadcrumb(page.model),
|
||||
context.breadcrumb(page.model)
|
||||
)}</ul>`
|
||||
: '';
|
||||
const heading =
|
||||
@ -145,7 +146,7 @@ class SassSiteTheme extends DefaultTheme {
|
||||
page.model.name +
|
||||
(page.model.typeParameters
|
||||
? `<${page.model.typeParameters
|
||||
.map((item) => item.name)
|
||||
.map(item => item.name)
|
||||
.join(', ')}>`
|
||||
: '');
|
||||
|
||||
@ -182,7 +183,7 @@ title: ${JSON.stringify(`${page.model.name} | JS API`)}
|
||||
}
|
||||
}
|
||||
|
||||
exports.load = (app) => {
|
||||
exports.load = app => {
|
||||
app.converter.addUnknownSymbolResolver((ref, refl, part, symbolId) => {
|
||||
if (!symbolId) return;
|
||||
const name = symbolId.qualifiedName;
|
||||
|
Loading…
Reference in New Issue
Block a user