Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit a6c11a6

Browse files
authored
Text on external projects (#52)
* Add external tests * Fixes * Tweaks * Tweaks to better test on external repos * Add correct settings * Fix deprecated action * Replace deprecated `::set-output` * Add missing work directory * Update README * Fix README
1 parent c56cac6 commit a6c11a6

10 files changed

+566
-89
lines changed

.github/workflows/external.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Test External
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
9+
pull_request:
10+
branches:
11+
- master
12+
workflow_dispatch:
13+
inputs:
14+
moduleSet:
15+
description: 'Module set'
16+
required: true
17+
default: 'nonCompliant'
18+
type: choice
19+
options:
20+
- compliant
21+
- nonCompliant
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25+
cancel-in-progress: true
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
read_external_projects:
32+
name: Read list of ${{ github.event.inputs.moduleSet || 'compliant' }} external projects
33+
runs-on: ubuntu-latest
34+
outputs:
35+
matrix: ${{ steps.set-matrix.outputs.matrix }}
36+
steps:
37+
- uses: actions/checkout@v3
38+
- id: set-matrix
39+
run: echo "matrix=$(cat workflow-external.json | jq -c '.${{ github.event.inputs.moduleSet || 'compliant' }}')" >> $GITHUB_OUTPUT
40+
test_external:
41+
needs: read_external_projects
42+
name: Test ${{ matrix.project }}
43+
runs-on: ubuntu-latest
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
node_version: [lts/*]
48+
project: ${{ fromJson(needs.read_external_projects.outputs.matrix) }}
49+
steps:
50+
- name: Checkout main project
51+
uses: actions/checkout@v3
52+
with:
53+
path: main
54+
- name: Checkout ${{ matrix.project }}
55+
uses: actions/checkout@v3
56+
with:
57+
repository: ${{ matrix.project }}
58+
path: project
59+
- name: Use Node.js ${{ matrix.node_version }}
60+
uses: actions/setup-node@v3
61+
with:
62+
node-version: ${{ matrix.node_version }}
63+
64+
- name: Determine npm cache directory windows
65+
id: npm-cache-dir-windows
66+
if: runner.os == 'Windows'
67+
run: echo "dir=$(npm config get cache)" >> $env:GITHUB_OUTPUT
68+
- name: Determine npm cache directory non-windows
69+
id: npm-cache-dir
70+
if: runner.os != 'Windows'
71+
run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT
72+
- uses: actions/cache@v3
73+
with:
74+
path: ${{ steps.npm-cache-dir-windows.outputs.dir || steps.npm-cache-dir.outputs.dir }}
75+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/package.json') }}
76+
restore-keys: |
77+
${{ runner.os }}-node-
78+
79+
- name: install main
80+
run: npm ci --no-audit --no-fund
81+
working-directory: ./main
82+
- name: install project
83+
run: '[ -f package-lock.json ] && npm ci --force || npm install --force'
84+
working-directory: ./project
85+
- name: modify project eslint config
86+
run: sed 's/"@socketsecurity"/"..\/main\/test.eslintrc"/' .eslintrc > tmp.eslintrc && rm .eslintrc && mv tmp.eslintrc .eslintrc
87+
working-directory: ./project
88+
- name: modify project eslint config (ESM version)
89+
run: sed 's/"@socketsecurity\/eslint-config\/jsdoc"/"..\/main\/test-jsdoc.eslintrc"/' .eslintrc > tmp.eslintrc && rm .eslintrc && mv tmp.eslintrc .eslintrc
90+
working-directory: ./project
91+
- name: run eslint
92+
run: ../main/node_modules/.bin/eslint --resolve-plugins-relative-to ../main --ext js --ext cjs --ext mjs --report-unused-disable-directives .
93+
working-directory: ./project

.github/workflows/npm-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: CI
33
on:
44
push:
55
branches:
6-
- main
6+
- master
77
tags:
88
- '*'
99
pull_request:
1010
branches:
11-
- main
11+
- master
1212

1313
permissions:
1414
contents: read

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ For projects without a `tsconfig.json`:
2222
"root": true
2323
}
2424
```
25+
26+
For projects being typed with JSDoc:
27+
28+
```json
29+
{
30+
"extends": "@socketsecurity/eslint-config/jsdoc",
31+
"root": true,
32+
"parserOptions": {
33+
"project": "./tsconfig.json"
34+
}
35+
}
36+
```

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports = {
1414
},
1515
'plugins': [
1616
'@typescript-eslint',
17-
'react-hooks'
17+
'react-hooks',
18+
'unicorn'
1819
],
1920
'extends': ['./lib/standard-eslint-ts'],
2021
'settings': {
@@ -64,6 +65,8 @@ module.exports = {
6465
'react-hooks/rules-of-hooks': 'off',
6566
'react-hooks/exhaustive-deps': 'off',
6667

68+
'unicorn/expiring-todo-comments': 'warn',
69+
6770
'@typescript-eslint/consistent-type-imports': [
6871
'error',
6972
{ 'prefer': 'type-imports', 'disallowTypeAnnotations': true }

jsdoc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict'
2+
3+
module.exports = {
4+
plugins: [
5+
'jsdoc'
6+
],
7+
extends: [
8+
'./',
9+
'plugin:jsdoc/recommended'
10+
],
11+
root: true,
12+
settings: {
13+
jsdoc: {
14+
mode: 'typescript'
15+
}
16+
},
17+
rules: {
18+
'jsdoc/check-types': 'off',
19+
'jsdoc/no-undefined-types': 'off',
20+
'jsdoc/require-jsdoc': 'warn',
21+
'jsdoc/require-param-description': 'off',
22+
'jsdoc/require-property-description': 'off',
23+
'jsdoc/require-returns-description': 'off',
24+
'jsdoc/require-yields': 'off',
25+
'jsdoc/valid-types': 'off'
26+
}
27+
}

0 commit comments

Comments
 (0)