mirror of
https://github.com/danog/sass-site.git
synced 2024-11-26 20:14:53 +01:00
lint
This commit is contained in:
parent
943a958faa
commit
2e97aaf8d8
@ -10,7 +10,7 @@ const VERSION_CACHE_PATH = './source/_data/versionCache.json';
|
||||
* Promise version of `spawn` to avoid blocking the main thread while waiting
|
||||
* for the child processes.
|
||||
*/
|
||||
function spawn(cmd, args, options) {
|
||||
const spawn = (cmd, args, options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = nodeSpawn(cmd, args, options);
|
||||
const stderr = [];
|
||||
@ -22,17 +22,22 @@ function spawn(cmd, args, options) {
|
||||
stderr.push(e.toString());
|
||||
});
|
||||
child.on('close', () => {
|
||||
if (stderr.length) reject(stderr.join(''));
|
||||
else resolve(stdout.join(''));
|
||||
if (stderr.length) {
|
||||
reject(stderr.join(''));
|
||||
} else {
|
||||
resolve(stdout.join(''));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves cached version object from cache file.
|
||||
*/
|
||||
async function getCacheFile() {
|
||||
if (process.env.NETLIFY || process.env.REBUILD_VERSION_CACHE) return {};
|
||||
const getCacheFile = async () => {
|
||||
if (process.env.NETLIFY || process.env.REBUILD_VERSION_CACHE) {
|
||||
return {};
|
||||
}
|
||||
let versionCache;
|
||||
try {
|
||||
versionCache = JSON.parse(await fs.readFile(VERSION_CACHE_PATH));
|
||||
@ -44,21 +49,21 @@ async function getCacheFile() {
|
||||
}
|
||||
}
|
||||
return versionCache;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes version object to cache file.
|
||||
*/
|
||||
async function writeCacheFile(cache) {
|
||||
const writeCacheFile = async (cache) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(chalk.green(`[11ty] Writing version cache file...`));
|
||||
await fs.writeFile(VERSION_CACHE_PATH, JSON.stringify(cache));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the highest stable version of `repo`, based on its git tags.
|
||||
*/
|
||||
async function getLatestVersion(repo) {
|
||||
const getLatestVersion = async (repo) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(chalk.cyan(`[11ty] Fetching version information for ${repo}`));
|
||||
const { parseSemVer, compareSemVer } = await import('semver-parser');
|
||||
@ -86,7 +91,7 @@ async function getLatestVersion(repo) {
|
||||
.at(-1);
|
||||
|
||||
return version;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the version and URL for the latest release of the given
|
||||
@ -110,7 +115,9 @@ module.exports = async () => {
|
||||
);
|
||||
|
||||
const nextCache = Object.fromEntries(versions);
|
||||
if (!deepEqual(cache, nextCache)) await writeCacheFile(nextCache);
|
||||
if (!deepEqual(cache, nextCache)) {
|
||||
await writeCacheFile(nextCache);
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
@ -2,10 +2,14 @@ $(function () {
|
||||
$('.impl-status').each(function () {
|
||||
const statusBar = $(this);
|
||||
const expandLink = statusBar.find('a');
|
||||
if (expandLink == null) return;
|
||||
if (expandLink == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const details = statusBar.next();
|
||||
if (!details.hasClass('sl-c-callout')) return;
|
||||
if (!details.hasClass('sl-c-callout')) {
|
||||
return;
|
||||
}
|
||||
|
||||
details.hide();
|
||||
expandLink.on('click', function () {
|
||||
|
@ -5,7 +5,7 @@ $(function () {
|
||||
const sticky = nav.offset();
|
||||
|
||||
// Added sticky class when window top is great than nav top
|
||||
function stickyNav() {
|
||||
const stickyNav = () => {
|
||||
if (
|
||||
nav.length > 0 &&
|
||||
sticky &&
|
||||
@ -15,7 +15,7 @@ $(function () {
|
||||
} else {
|
||||
$('.sl-l-medium-holy-grail__body').removeClass('sl-js-nav--is-sticky');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// When scrolling the page, execute stickyNav
|
||||
$(window).on('scroll', function () {
|
||||
|
@ -110,7 +110,9 @@ if (window.location.hash) {
|
||||
redirect = '/ruby-sass';
|
||||
}
|
||||
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (window.location.pathname == '/documentation/modules') {
|
||||
const redirects: Record<string, string> = {
|
||||
'#declare-class_method': '/ruby-sass',
|
||||
@ -219,7 +221,9 @@ if (window.location.hash) {
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (window.location.pathname == '/documentation/modules/color') {
|
||||
const redirects: Record<string, string> = {
|
||||
'#rgb': '/documentation/modules#rgb',
|
||||
@ -229,21 +233,27 @@ if (window.location.hash) {
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (window.location.pathname == '/documentation/modules/map') {
|
||||
const redirects: Record<string, string> = {
|
||||
'#keywords': '/documentation/modules/meta#keywords',
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (window.location.pathname == '/documentation/at-rules/use') {
|
||||
const redirects: Record<string, string> = {
|
||||
'#configuring-modules': '/documentation/at-rules/use#configuration',
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (
|
||||
window.location.pathname == '/documentation/syntax/special-functions'
|
||||
) {
|
||||
@ -254,7 +264,9 @@ if (window.location.hash) {
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
} else if (window.location.pathname == '/documentation/js-api') {
|
||||
const redirects: Record<string, string> = {
|
||||
'#rendersync': '/documentation/js-api/modules#renderSync',
|
||||
@ -391,6 +403,8 @@ if (window.location.hash) {
|
||||
};
|
||||
|
||||
const redirect: string | undefined = redirects[window.location.hash];
|
||||
if (redirect) window.location.href = redirect;
|
||||
if (redirect) {
|
||||
window.location.href = redirect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
// Avoid `console` errors in browsers that lack a console.
|
||||
(function() {
|
||||
var method;
|
||||
var noop = function () {};
|
||||
var methods = [
|
||||
let method;
|
||||
const noop = function () {};
|
||||
const methods = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
|
||||
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
|
||||
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
|
||||
'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
var length = methods.length;
|
||||
var console = (window.console = window.console || {});
|
||||
let length = methods.length;
|
||||
const console = (window.console = window.console || {});
|
||||
|
||||
while (length--) {
|
||||
method = methods[length];
|
||||
|
@ -1,10 +1,4 @@
|
||||
{% comment %}
|
||||
Ideally this would use named args, but that's not supported yet:
|
||||
https://github.com/11ty/eleventy/issues/2679
|
||||
|
||||
In the meantime, the args are (in order): `dart`, `libsass`, `ruby`, `feature`
|
||||
{% endcomment %}
|
||||
|
||||
{% # Arguments are (in order): `dart`, `libsass`, `ruby` %}
|
||||
{% compatibility '1.23.0', false, false %}
|
||||
Only Dart Sass currently supports `@use`. Users of other implementations must
|
||||
use the [`@import` rule][] instead.
|
||||
|
@ -59,11 +59,11 @@ export default async function codeExample(
|
||||
});
|
||||
}
|
||||
|
||||
function generateCodeExample(
|
||||
const generateCodeExample = (
|
||||
contents: string,
|
||||
autogenCSS: boolean,
|
||||
syntax: 'sass' | 'scss' | null,
|
||||
) {
|
||||
) => {
|
||||
const splitContents = contents.split('\n===\n');
|
||||
|
||||
let scssContents, sassContents, cssContents;
|
||||
@ -126,13 +126,13 @@ function generateCodeExample(
|
||||
canSplit,
|
||||
splitLocation,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
function getCanSplit(
|
||||
const getCanSplit = (
|
||||
scssExamples: string[],
|
||||
sassExamples: string[],
|
||||
cssExamples: string[],
|
||||
) {
|
||||
) => {
|
||||
const exampleSourceLengths = [...scssExamples, ...sassExamples].flatMap(
|
||||
(source) => source.split('\n').map((line) => line.length),
|
||||
);
|
||||
@ -150,4 +150,4 @@ function getCanSplit(
|
||||
maxSourceWidth,
|
||||
maxCSSWidth,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user