Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

135-megalinter-tidy #134

Merged
merged 15 commits into from
Aug 6, 2024
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
53 changes: 53 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"version": "0.2",
"language": "en_US",
"ignorePaths": ["node_modules/**", "styles.**"],
"words": [
"Allstar",
"sidenav",
"telework",
"USAJOBS",
"captioner",
"neurodiversity",
"socio",
"jointts",
"FASC",
"LUOTR",
"SYSANALYSIS",
"ohrm",
"endunless",
"skillset",
"skillsets",
"skinless",
"wireframe",
"wireframes",
"toolkit",
"toolkits",
"OPM",
"refactorization",
"USWDS",
"uswds",
"subnav",
"endfor",
"USDA",
"usda",
"exfiltrate",
"browsersync",
"outdir",
"Snyk",
"sitrep",
"ISSO",
"SDLC",
"automations",
"ISSM",
"timeframe",
"pdate",
"sitreps",
"Joomla",
"dependency",
"Grype",
"dependencies",
"hotfixes",
"Nygard"
]
}
103 changes: 53 additions & 50 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
const { DateTime } = require('luxon');
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const pluginRss = require('@11ty/eleventy-plugin-rss');
const pluginNavigation = require('@11ty/eleventy-navigation');
const markdownIt = require('markdown-it');
const markdownItAnchor = require('markdown-it-anchor');
const { DateTime } = require("luxon");
const esbuild = require("esbuild");
const fs = require("fs");
const path = require("path");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const pluginNavigation = require("@11ty/eleventy-navigation");
const markdownIt = require("markdown-it");
const markdownItAnchor = require("markdown-it-anchor");
const yaml = require("js-yaml");
const { sassPlugin } = require('esbuild-sass-plugin');
const { sassPlugin } = require("esbuild-sass-plugin");
const svgSprite = require("eleventy-plugin-svg-sprite");
const { imageShortcode, imageWithClassShortcode } = require('./config');
const { imageShortcode, imageWithClassShortcode } = require("./config");

module.exports = function (config) {
// Set pathPrefix for site
let pathPrefix = '/';
let pathPrefix = "/";
// Copy the `admin` folders to the output
config.addPassthroughCopy('admin');
config.addPassthroughCopy("admin");

// for #80 (update site favicon)
// copy files from `_img/favicon/` to `_site/`
config.addPassthroughCopy({ "_img/favicon/": "/assets/" });

// Copy USWDS init JS so we can load it in HEAD to prevent banner flashing
config.addPassthroughCopy({'./node_modules/@uswds/uswds/dist/js/uswds-init.js': 'assets/js/uswds-init.js'});
config.addPassthroughCopy({
"./node_modules/@uswds/uswds/dist/js/uswds-init.js":
"assets/js/uswds-init.js",
});

// Add plugins
config.addPlugin(pluginRss);
Expand All @@ -31,23 +34,23 @@ module.exports = function (config) {
//// SVG Sprite Plugin for USWDS USWDS icons
config.addPlugin(svgSprite, {
path: "./node_modules/@uswds/uswds/dist/img/uswds-icons",
svgSpriteShortcode: 'uswds_icons_sprite',
svgShortcode: 'uswds_icons'
svgSpriteShortcode: "uswds_icons_sprite",
svgShortcode: "uswds_icons",
});

//// SVG Sprite Plugin for USWDS USA icons
config.addPlugin(svgSprite, {
path: "./node_modules/@uswds/uswds/dist/img/usa-icons",
svgSpriteShortcode: 'usa_icons_sprite',
svgShortcode: 'usa_icons'
svgSpriteShortcode: "usa_icons_sprite",
svgShortcode: "usa_icons",
});

// Allow yaml to be used in the _data dir
config.addDataExtension("yaml", contents => yaml.load(contents));
config.addDataExtension("yaml", (contents) => yaml.load(contents));

// This is an example of creating an Eleventy collection from
// a data file, in this case it's _data/services.yml
config.addCollection('services', (collection) => {
config.addCollection("services", (collection) => {
const allServices = collection.getAll()[0].data.services;
return allServices;
});
Expand All @@ -57,29 +60,29 @@ module.exports = function (config) {
function sortByProp(values, prop) {
let vals = [...values];
return vals.sort((a, b) => {
if (typeof a[prop] == 'string' && typeof b[prop] == 'string') {
if (typeof a[prop] == "string" && typeof b[prop] == "string") {
return a[prop].localeCompare(b[prop]);
} else {
return Math.sign(a[prop] - b[prop]);
}
});
}

config.addFilter('sortByProp', sortByProp);
config.addFilter("sortByProp", sortByProp);

config.addFilter('readableDate', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat(
'dd LLL yyyy'
config.addFilter("readableDate", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(
"dd LLL yyyy",
);
});

// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
config.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
config.addFilter("htmlDateString", (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
});

// Get the first `n` elements of a collection.
config.addFilter('head', (array, n) => {
config.addFilter("head", (array, n) => {
if (!Array.isArray(array) || array.length === 0) {
return [];
}
Expand All @@ -91,20 +94,20 @@ module.exports = function (config) {
});

// Return the smallest number argument
config.addFilter('min', (...numbers) => {
config.addFilter("min", (...numbers) => {
return Math.min.apply(null, numbers);
});

function filterTagList(tags) {
return (tags || []).filter(
(tag) => ['all', 'nav', 'post', 'posts'].indexOf(tag) === -1
(tag) => ["all", "nav", "post", "posts"].indexOf(tag) === -1,
);
}

config.addFilter('filterTagList', filterTagList);
config.addFilter("filterTagList", filterTagList);

// Create an array of all tags
config.addCollection('tagList', function (collection) {
config.addCollection("tagList", function (collection) {
let tagSet = new Set();
collection.getAll().forEach((item) => {
(item.data.tags || []).forEach((tag) => tagSet.add(tag));
Expand All @@ -120,26 +123,26 @@ module.exports = function (config) {
linkify: true,
}).use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.ariaHidden({
placement: 'after',
class: 'direct-link',
symbol: '',
placement: "after",
class: "direct-link",
symbol: "",
level: [1, 2, 3, 4],
}),
slugify: config.getFilter('slug'),
slugify: config.getFilter("slug"),
});
config.setLibrary('md', markdownLibrary);
config.setLibrary("md", markdownLibrary);

// Override Browsersync defaults (used only with --serve)
config.setBrowserSyncConfig({
callbacks: {
ready: function (err, browserSync) {
const content_404 = fs.readFileSync('_site/404/index.html');
const content_404 = fs.readFileSync("_site/404/index.html");

browserSync.addMiddleware('*', (req, res) => {
browserSync.addMiddleware("*", (req, res) => {
// Provides the 404 content without redirect.
res.writeHead(404, { 'Content-Type': 'text/html; charset=UTF-8' });
res.writeHead(404, { "Content-Type": "text/html; charset=UTF-8" });
res.write(content_404);
const svgSprite = require("eleventy-plugin-svg-sprite");
const svgSprite = require("eleventy-plugin-svg-sprite");
res.end();
});
},
Expand All @@ -149,8 +152,8 @@ const svgSprite = require("eleventy-plugin-svg-sprite");
});

// Set image shortcodes
config.addLiquidShortcode('image', imageShortcode);
config.addLiquidShortcode('image_with_class', imageWithClassShortcode);
config.addLiquidShortcode("image", imageShortcode);
config.addLiquidShortcode("image_with_class", imageWithClassShortcode);
config.addLiquidShortcode("uswds_icon", function (name) {
return `
<svg class="usa-icon" aria-hidden="true" role="img">
Expand All @@ -168,25 +171,25 @@ const svgSprite = require("eleventy-plugin-svg-sprite");

// If BASEURL env variable exists, update pathPrefix to the BASEURL
if (process.env.BASEURL) {
pathPrefix = process.env.BASEURL
pathPrefix = process.env.BASEURL;
}

return {
dataTemplateEngine: "liquid",

// Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid
templateFormats: ['md', 'njk', 'html', 'liquid'],
templateFormats: ["md", "njk", "html", "liquid"],

// Pre-process *.md files with: (default: `liquid`)
// Other template engines are available
// See https://www.11ty.dev/docs/languages/ for other engines.
markdownTemplateEngine: 'liquid',
markdownTemplateEngine: "liquid",

// Pre-process *.html files with: (default: `liquid`)
// Other template engines are available
// See https://www.11ty.dev/docs/languages/ for other engines.
htmlTemplateEngine: 'liquid',
htmlTemplateEngine: "liquid",

// -----------------------------------------------------------------
// If your site deploys to a subdirectory, change `pathPrefix`.
Expand All @@ -204,10 +207,10 @@ const svgSprite = require("eleventy-plugin-svg-sprite");

// These are all optional (defaults are shown):
dir: {
input: '.',
includes: '_includes',
data: '_data',
output: '_site',
input: ".",
includes: "_includes",
data: "_data",
output: "_site",
},
};
};
5 changes: 4 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## Changes proposed in this pull request:
<!-- markdownlint-disable-next-line MD041 -->
## Changes proposed in this pull request

-
-
-

## security considerations

[Note the any security considerations here, or make note of why there are none]
1 change: 0 additions & 1 deletion .github/workflows/megalinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- main
workflow_dispatch:


permissions:
contents: write
issues: write
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/pa11y.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: Pa11y Testing


# yamllint disable-line rule:truthy
on:
pull_request:
Expand All @@ -22,7 +21,6 @@ jobs:
pull-requests: write

steps:

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # [email protected]

- name: Install Chrome
Expand All @@ -37,7 +35,7 @@ jobs:
- name: Use Node
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # pin@v3
with:
node-version: '18'
node-version: "18"

- name: Install Pa11y
run: npm install pa11y
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '43 7 * * 3'
- cron: "43 7 * * 3"
push:
branches:
- "main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: Build and Test
on:
pull_request:

permissions: read-all

jobs:
build:
Expand All @@ -28,6 +29,5 @@ jobs:

- name: Build site
run: npm run build

# - name: Run tests
# run: npm run test
9 changes: 4 additions & 5 deletions .grype.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
fail-on-severity: "high"

exclude:
- './node_modules/**'
- './.git/**'
- './.github/**'
- './_site/**'
- "./node_modules/**"
- "./.git/**"
- "./.github/**"
- "./_site/**"

ignore:

# Ignored by default; disputed and unwarranted CVE that causes Megalinter to fail
# @link https://nvd.nist.gov/vuln/detail/CVE-2018-20225
- vulnerability: CVE-2018-20225
1 change: 1 addition & 0 deletions .markdown-link-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"retryOn429": true,
"retryCount": 5,
"aliveStatusCodes": [200, 203],
"projectBaseUrl": "https://github.com/GSA-TTS/tts-website/",
"ignorePatterns": [
{
"pattern": "^https?://github.com/"
Expand Down
Loading
Loading