Skip to content

Commit ff98cfe

Browse files
committed
Update linting and testing process
1 parent 2e88093 commit ff98cfe

18 files changed

+8133
-111
lines changed

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib/
2+
dist/
3+
node_modules/
4+
coverage/

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.licenses/** -diff linguist-generated=true
1+
dist/** -diff linguist-generated=true

.github/linters/.eslintrc.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
env:
2+
node: true
3+
es6: true
4+
jest: true
5+
6+
globals:
7+
Atomics: readonly
8+
SharedArrayBuffer: readonly
9+
10+
ignorePatterns:
11+
- '!.*'
12+
- '**/node_modules/.*'
13+
- '**/dist/.*'
14+
- '**/coverage/.*'
15+
- '*.json'
16+
17+
parser: '@typescript-eslint/parser'
18+
19+
parserOptions:
20+
ecmaVersion: 2023
21+
sourceType: module
22+
project:
23+
- './.github/linters/tsconfig.json'
24+
- './tsconfig.json'
25+
26+
plugins:
27+
- jest
28+
- '@typescript-eslint'
29+
30+
extends:
31+
- eslint:recommended
32+
- plugin:@typescript-eslint/eslint-recommended
33+
- plugin:@typescript-eslint/recommended
34+
- plugin:github/recommended
35+
- plugin:jest/recommended
36+
37+
rules:
38+
{
39+
'camelcase': 'off',
40+
'eslint-comments/no-use': 'off',
41+
'eslint-comments/no-unused-disable': 'off',
42+
'i18n-text/no-en': 'off',
43+
'import/no-namespace': 'off',
44+
'no-console': 'off',
45+
'no-unused-vars': 'off',
46+
'prettier/prettier': 'error',
47+
'semi': 'off',
48+
'@typescript-eslint/array-type': 'error',
49+
'@typescript-eslint/await-thenable': 'error',
50+
'@typescript-eslint/ban-ts-comment': 'error',
51+
'@typescript-eslint/consistent-type-assertions': 'error',
52+
'@typescript-eslint/explicit-member-accessibility':
53+
['error', { 'accessibility': 'no-public' }],
54+
'@typescript-eslint/explicit-function-return-type':
55+
['error', { 'allowExpressions': true }],
56+
'@typescript-eslint/func-call-spacing': ['error', 'never'],
57+
'@typescript-eslint/no-array-constructor': 'error',
58+
'@typescript-eslint/no-empty-interface': 'error',
59+
'@typescript-eslint/no-explicit-any': 'error',
60+
'@typescript-eslint/no-extraneous-class': 'error',
61+
'@typescript-eslint/no-for-in-array': 'error',
62+
'@typescript-eslint/no-inferrable-types': 'error',
63+
'@typescript-eslint/no-misused-new': 'error',
64+
'@typescript-eslint/no-namespace': 'error',
65+
'@typescript-eslint/no-non-null-assertion': 'warn',
66+
'@typescript-eslint/no-require-imports': 'error',
67+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
68+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
69+
'@typescript-eslint/no-unused-vars': 'error',
70+
'@typescript-eslint/no-useless-constructor': 'error',
71+
'@typescript-eslint/no-var-requires': 'error',
72+
'@typescript-eslint/prefer-for-of': 'warn',
73+
'@typescript-eslint/prefer-function-type': 'warn',
74+
'@typescript-eslint/prefer-includes': 'error',
75+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
76+
'@typescript-eslint/promise-function-async': 'error',
77+
'@typescript-eslint/require-array-sort-compare': 'error',
78+
'@typescript-eslint/restrict-plus-operands': 'error',
79+
'@typescript-eslint/semi': ['error', 'never'],
80+
'@typescript-eslint/space-before-function-paren': 'off',
81+
'@typescript-eslint/type-annotation-spacing': 'error',
82+
'@typescript-eslint/unbound-method': 'error'
83+
}

.github/linters/.markdown-lint.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Unordered list style
2+
MD004:
3+
style: dash
4+
5+
# Ordered list item prefix
6+
MD029:
7+
style: one

.github/linters/.yaml-lint.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
document-end: disable
3+
document-start:
4+
level: warning
5+
present: false
6+
line-length:
7+
level: warning
8+
max: 80
9+
allow-non-breakable-words: true
10+
allow-non-breakable-inline-mappings: true

.github/linters/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "../../tsconfig.json",
4+
"compilerOptions": {
5+
"noEmit": true
6+
},
7+
"include": ["../../__tests__/**/*", "../../src/**/*"],
8+
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
9+
}

.github/workflows/check-dist.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# In TypeScript actions, `dist/index.js` is a special file. When you reference
2+
# an action with `uses:`, `dist/index.js` is the code that will be run. For this
3+
# project, the `dist/index.js` file is generated from other source files through
4+
# the build process. We need to make sure that the checked-in `dist/index.js`
5+
# file matches what is expected from the build.
6+
#
7+
# This workflow will fail if the checked-in `dist/index.js` file does not match
8+
# what is expected from the build.
9+
name: Check dist/
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
paths-ignore:
16+
- '**.md'
17+
pull_request:
18+
paths-ignore:
19+
- '**.md'
20+
workflow_dispatch:
21+
22+
jobs:
23+
check-dist:
24+
name: Check dist/
25+
runs-on: ubuntu-latest
26+
27+
permissions:
28+
contents: read
29+
statuses: write
30+
31+
steps:
32+
- name: Checkout
33+
id: checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: 20
40+
cache: npm
41+
42+
- name: Install Dependencies
43+
id: install
44+
run: npm ci
45+
46+
- name: Build dist/ Directory
47+
id: build
48+
run: npm run bundle
49+
50+
- name: Compare Expected and Actual Directories
51+
id: diff
52+
run: |
53+
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
54+
echo "Detected uncommitted changes after build. See status below:"
55+
git diff --ignore-space-at-eol --text dist/
56+
exit 1
57+
fi
58+
59+
# If index.js was different than expected, upload the expected version as
60+
# a workflow artifact.
61+
- uses: actions/upload-artifact@v3
62+
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
63+
with:
64+
name: dist
65+
path: dist/

.github/workflows/linter.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Lint Code Base
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
lint:
13+
name: Lint Code Base
14+
runs-on: ubuntu-latest
15+
16+
permissions:
17+
contents: read
18+
packages: read
19+
statuses: write
20+
21+
steps:
22+
- name: Checkout
23+
id: checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Lint Code Base
27+
id: super-linter
28+
uses: super-linter/super-linter/slim@v5
29+
env:
30+
DEFAULT_BRANCH: main
31+
FILTER_REGEX_EXCLUDE: dist/**/*
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
TYPESCRIPT_DEFAULT_STYLE: prettier
34+
VALIDATE_ALL_CODEBASE: true
35+
VALIDATE_JAVASCRIPT_STANDARD: false
36+
VALIDATE_JSCPD: false

.gitignore

+103-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,103 @@
1-
package-lock.json
2-
node_modules
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
100+
# IDE files
101+
.idea
102+
.vscode
103+
*.code-workspace

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
node_modules/
3+
coverage/

.prettierrc.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
2-
"printWidth": 80,
3-
"tabWidth": 2,
4-
"useTabs": false,
5-
"semi": true,
6-
"singleQuote": true,
7-
"trailingComma": "none",
8-
"bracketSpacing": false,
9-
"arrowParens": "avoid",
10-
"parser": "typescript"
11-
}
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "none",
10+
"bracketSpacing": true,
11+
"bracketSameLine": true,
12+
"arrowParens": "avoid",
13+
"proseWrap": "always",
14+
"htmlWhitespaceSensitivity": "css",
15+
"endOfLine": "lf"
16+
}

__tests__/index.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Unit tests for the action's entrypoint, src/index.ts
3+
*/
4+
5+
import * as main from '../src/main'
6+
7+
// Mock the action's entrypoint
8+
const runMock = jest.spyOn(main, 'run').mockImplementation()
9+
10+
describe('index', () => {
11+
it('calls run when imported', async () => {
12+
// eslint-disable-next-line @typescript-eslint/no-require-imports
13+
require('../src/index')
14+
15+
expect(runMock).toHaveBeenCalled()
16+
})
17+
})

0 commit comments

Comments
 (0)