Skip to content

Commit

Permalink
Merge branch 'anuraghazra:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerexbcd authored Nov 6, 2024
2 parents 512bbbd + f86a12b commit 4ff1338
Show file tree
Hide file tree
Showing 31 changed files with 1,475 additions and 1,209 deletions.
466 changes: 233 additions & 233 deletions .eslintrc.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.repository == 'anuraghazra/github-readme-stats'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Deployment Prep
run: python ./.github/workflows/deploy-prep.py
- uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/empty-issues-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# NOTE: Retrieve issue templates.
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Run empty issues closer action
uses: rickstaa/empty-issues-closer-action@e96914613221511279ca25f50fd4acc85e331d99 # v1.1.74
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-theme-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ossf-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -36,7 +36,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: SARIF file
path: results.sarif
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/preview-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm

- uses: bahmutov/npm-install@e5c7e14408aa6089501de32bd16123b41738047e # v1.10.2
- uses: bahmutov/npm-install@dc9579d3dfb9c0e7a1f56c194eefcb8e2c9f0da5 # v1.10.3
with:
useLockFile: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prs-cache-clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Cleanup
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/stale-theme-pr-closer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm

- uses: bahmutov/npm-install@e5c7e14408aa6089501de32bd16123b41738047e # v1.10.2
- uses: bahmutov/npm-install@dc9579d3dfb9c0e7a1f56c194eefcb8e2c9f0da5 # v1.10.3
with:
useLockFile: false

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/top-issues-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run top issues action
uses: rickstaa/top-issues-action@7f58423f68b52b4a310c66217ab8d844596d2cbc # v1.3.100
uses: rickstaa/top-issues-action@7e8dda5d5ae3087670f9094b9724a9a091fc3ba1 # v1.3.101
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update-langs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
node-version: [18.x]

steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand All @@ -53,7 +53,7 @@ jobs:
run: npm run generate-langs-json

- name: Create Pull Request if upstream language file is changed
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
commit-message: "refactor: update languages JSON"
branch: "update_langs/patch"
Expand Down
23 changes: 4 additions & 19 deletions api/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,17 @@ export default async (req, res) => {
const gistData = await fetchGist(id);

let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.SIX_HOURS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
parseInt(cache_seconds || CONSTANTS.TWO_DAY, 10),
CONSTANTS.TWO_DAY,
CONSTANTS.SIX_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;

/*
if star count & fork count is over 1k then we are kFormating the text
and if both are zero we are not showing the stats
so we can just make the cache longer, since there is no need to frequent updates
*/
const stars = gistData.starsCount;
const forks = gistData.forksCount;
const isBothOver1K = stars > 1000 && forks > 1000;
const isBothUnder1 = stars < 1 && forks < 1;
if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
cacheSeconds = CONSTANTS.SIX_HOURS;
}

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}`,
);

return res.send(
Expand Down
8 changes: 3 additions & 5 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,16 @@ export default async (req, res) => {

let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
CONSTANTS.TWELVE_HOURS,
CONSTANTS.TWO_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
);

return res.send(
Expand Down
21 changes: 3 additions & 18 deletions api/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,17 @@ export default async (req, res) => {
const repoData = await fetchRepo(username, repo);

let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
parseInt(cache_seconds || CONSTANTS.PIN_CARD_CACHE_SECONDS, 10),
CONSTANTS.ONE_DAY,
CONSTANTS.TEN_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;

/*
if star count & fork count is over 1k then we are kFormating the text
and if both are zero we are not showing the stats
so we can just make the cache longer, since there is no need to frequent updates
*/
const stars = repoData.starCount;
const forks = repoData.forkCount;
const isBothOver1K = stars > 1000 && forks > 1000;
const isBothUnder1 = stars < 1 && forks < 1;
if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
cacheSeconds = CONSTANTS.SIX_HOURS;
}

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds}, s-maxage=${cacheSeconds}`,
);

return res.send(
Expand Down
3 changes: 3 additions & 0 deletions api/status/up.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export default async (req, res) => {
try {
await retryer(uptimeFetcher, {});
} catch (err) {
// Resolve eslint no-unused-vars
err;

PATsValid = false;
}

Expand Down
12 changes: 4 additions & 8 deletions api/top-langs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { renderTopLanguages } from "../src/cards/top-languages-card.js";
import { blacklist } from "../src/common/blacklist.js";
import {
clampValue,
CONSTANTS,
parseArray,
parseBoolean,
Expand Down Expand Up @@ -70,20 +69,17 @@ export default async (req, res) => {
count_weight,
);

let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
let cacheSeconds = parseInt(
cache_seconds || CONSTANTS.TOP_LANGS_CACHE_SECONDS,
10,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
: cacheSeconds;

res.setHeader(
"Cache-Control",
`max-age=${
cacheSeconds / 2
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
`max-age=${cacheSeconds / 2}, s-maxage=${cacheSeconds}`,
);

return res.send(
Expand Down
2 changes: 1 addition & 1 deletion api/wakatime.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async (req, res) => {
let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.CARD_CACHE_SECONDS, 10),
CONSTANTS.SIX_HOURS,
CONSTANTS.ONE_DAY,
CONSTANTS.TWO_DAY,
);
cacheSeconds = process.env.CACHE_SECONDS
? parseInt(process.env.CACHE_SECONDS, 10) || cacheSeconds
Expand Down
83 changes: 83 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import jsdoc from "eslint-plugin-jsdoc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends("prettier"),
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},

ecmaVersion: 2022,
sourceType: "module",
},
plugins: {
jsdoc,
},
rules: {
"no-unexpected-multiline": "error",
"accessor-pairs": [
"error",
{
getWithoutSet: false,
setWithoutGet: true,
},
],
"block-scoped-var": "warn",
"consistent-return": "error",
curly: "error",
"no-alert": "error",
"no-caller": "error",
"no-warning-comments": [
"warn",
{
terms: ["TODO", "FIXME"],
location: "start",
},
],
"no-with": "warn",
radix: "warn",
"no-delete-var": "error",
"no-undef-init": "off",
"no-undef": "error",
"no-undefined": "off",
"no-unused-vars": "warn",
"no-use-before-define": "error",
"constructor-super": "error",
"no-class-assign": "error",
"no-const-assign": "error",
"no-dupe-class-members": "error",
"no-this-before-super": "error",
"object-shorthand": ["warn"],
"no-mixed-spaces-and-tabs": "warn",
"no-multiple-empty-lines": "warn",
"no-negated-condition": "warn",
"no-unneeded-ternary": "warn",
"keyword-spacing": [
"error",
{
before: true,
after: true,
},
],
"jsdoc/require-returns": "warn",
"jsdoc/require-returns-description": "warn",
"jsdoc/require-param-description": "warn",
"jsdoc/require-jsdoc": "warn",
},
},
];
Loading

0 comments on commit 4ff1338

Please sign in to comment.