Skip to content
Draft
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
61 changes: 61 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
'@rushstack/eslint-config/profile/node-trusted-tool',
'plugin:astro/recommended',
'plugin:react-hooks/recommended',
'plugin:unicorn/recommended',
'plugin:sonarjs/recommended-legacy'
],
plugins: ['import'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
sourceType: 'module',
ecmaVersion: 'latest'
},
rules: {
'unicorn/prevent-abbreviations': [
'error',
{
allowList: {
props: true,
Props: true,
ref: true,
Ref: true,
Dev: true
}
}
],
'unicorn/filename-case': 'off',
'react-hooks/exhaustive-deps': 'error',
'no-console': 'error',
'@typescript-eslint/naming-convention': 'off',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal'],
'newlines-between': 'always'
}
],
'@rushstack/typedef-var': 'off',
'unicorn/no-null': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'unicorn/no-useless-undefined': 'off'
},
settings: {
'import/resolver': {
typescript: {}
}
},
overrides: [
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro']
}
}
]
};
53 changes: 53 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org

name: ESLint

on:
push:
branches: ['master']
pull_request:
# The branches below must be a subset of the branches above
branches: ['master']
schedule:
- cron: '35 0 * * 1'

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install PNPM
uses: pnpm/action-setup@v2

- name: Install Dependencies
run: pnpm install

- name: Run ESLint
run: pnpm exec eslint .
--config .eslintrc.cjs
--ext .js,.jsx,.ts,.tsx,.astro
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
env:
SARIF_ESLINT_IGNORE_SUPPRESSED: 'true'
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true
22 changes: 11 additions & 11 deletions astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import react from "@astrojs/react";
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import react from '@astrojs/react';

import { pagefind } from "./integrations/pagefind";
import { remarkReadingTime } from "./integrations/remarkReadingTime.mjs";
import expressiveCode from "./integrations/expressiveCode.mjs";
import { pagefind } from './integrations/pagefind';
import { remarkReadingTime } from './integrations/remarkReadingTime.mjs';
import expressiveCode from './integrations/expressiveCode.mjs';

// https://astro.build/config
export default defineConfig({
site: "https://newesters.github.io",
base: "/hacknote-js",
site: 'https://newesters.github.io',
base: '/hacknote-js',
integrations: [expressiveCode, mdx(), sitemap(), react(), pagefind()],
markdown: {
remarkPlugins: [remarkReadingTime],
remarkPlugins: [remarkReadingTime]
},
scopedStyleStrategy: "where",
scopedStyleStrategy: 'where'
});
26 changes: 13 additions & 13 deletions integrations/pagefind.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { fileURLToPath } from "node:url";
import { execSync } from "node:child_process";
import { fileURLToPath } from 'node:url';
import { execSync } from 'node:child_process';

import { type AstroIntegration } from "astro";
import sirv from "sirv";
import { type AstroIntegration } from 'astro';
import sirv from 'sirv';

export function pagefind(): AstroIntegration {
let outDir: string;

return {
name: "astro-pagefind",
name: 'astro-pagefind',
hooks: {
"astro:config:setup": ({ config }) => {
'astro:config:setup': ({ config }) => {
outDir = fileURLToPath(config.outDir);
},
"astro:server:setup": ({ server }) => {
'astro:server:setup': ({ server }) => {
const serve = sirv(outDir, {
dev: true,
etag: true,
etag: true
});

server.middlewares.use((request, response, next) => {
if (request.url?.startsWith("/pagefind/")) {
if (request.url?.startsWith('/pagefind/')) {
serve(request, response, next);
} else {
next();
}
});
},
"astro:build:done": ({ logger }) => {
'astro:build:done': ({ logger }) => {
if (!outDir) {
logger.warn(
"astro-pagefind couldn't reliably determine the output directory. Search index will not be built."
Expand All @@ -37,9 +37,9 @@ export function pagefind(): AstroIntegration {

const cmd = `npx pagefind --site "${outDir}"`;
execSync(cmd, {
stdio: [process.stdin, process.stdout, process.stderr],
stdio: [process.stdin, process.stdout, process.stderr]
});
},
},
}
}
};
}
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"lint:prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx,astro}\"",
"lint:eslint": "eslint --fix \"src/**/*.{js,ts,jsx,tsx,astro}\"",
"lint": "npm run lint:prettier && npm run lint:eslint"
},
"dependencies": {
"@astro-community/astro-embed-youtube": "^0.5.2",
Expand Down Expand Up @@ -37,7 +40,21 @@
"vite": "^4.4.9"
},
"devDependencies": {
"csstype": "^3.1.2"
"@microsoft/eslint-formatter-sarif": "^3.1.0",
"@rushstack/eslint-config": "^3.6.10",
"@typescript-eslint/parser": "^7.10.0",
"csstype": "^3.1.2",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-astro": "^1.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-sonarjs": "^1.0.3",
"eslint-plugin-unicorn": "^53.0.0",
"prettier": "^3.2.5",
"prettier-config-standard": "^7.0.0",
"prettier-plugin-astro": "^0.14.0"
},
"packageManager": "pnpm@8.15.3"
}
Loading