Skip to content

Commit 8d81f88

Browse files
authored
Add and configure ESLint and update configuration for Prettier (actions#508)
* Add ESLint and update Prettier * Rebuild action * Update package.json
1 parent ba790c8 commit 8d81f88

17 files changed

+2397
-190
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ignore list
2+
/*
3+
4+
# Do not ignore these folders:
5+
!__tests__/
6+
!__mocks__/
7+
!src/

.eslintrc.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/recommended',
5+
'plugin:eslint-plugin-jest/recommended',
6+
'eslint-config-prettier'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
10+
rules: {
11+
'@typescript-eslint/no-require-imports': 'error',
12+
'@typescript-eslint/no-non-null-assertion': 'off',
13+
'@typescript-eslint/no-explicit-any': 'off',
14+
'@typescript-eslint/no-empty-function': 'off',
15+
'@typescript-eslint/ban-ts-comment': [
16+
'error',
17+
{
18+
'ts-ignore': 'allow-with-description'
19+
}
20+
],
21+
'no-console': 'error',
22+
'yoda': 'error',
23+
'prefer-const': [
24+
'error',
25+
{
26+
destructuring: 'all'
27+
}
28+
],
29+
'no-control-regex': 'off',
30+
'no-constant-condition': ['error', {checkLoops: false}]
31+
},
32+
overrides: [
33+
{
34+
files: ['**/*{test,spec}.ts'],
35+
rules: {
36+
'@typescript-eslint/no-unused-vars': 'off',
37+
'jest/no-standalone-expect': 'off',
38+
'jest/no-conditional-expect': 'off',
39+
'no-console': 'off',
40+
41+
}
42+
}
43+
],
44+
env: {
45+
node: true,
46+
es6: true,
47+
'jest/globals': true
48+
}
49+
};

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* text=auto
1+
* text=auto eol=lf
22
.licenses/** -diff linguist-generated=true
33

44
# don't diff machine generated files

.github/ISSUE_TEMPLATE/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
blank_issues_enabled: false
1+
blank_issues_enabled: false

.github/workflows/basic-validation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ on:
1414
jobs:
1515
call-basic-validation:
1616
name: Basic validation
17-
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
17+
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main

.github/workflows/check-dist.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ on:
1414
jobs:
1515
call-check-dist:
1616
name: Check dist/
17-
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
17+
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main

.github/workflows/codeql-analysis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: CodeQL analysis
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88
schedule:
99
- cron: '0 3 * * 0'
1010

1111
jobs:
1212
call-codeQL-analysis:
13-
name: CodeQL analysis
14-
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
13+
name: CodeQL analysis
14+
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main

.github/workflows/licensed.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ on:
1212
jobs:
1313
call-licensed:
1414
name: Licensed
15-
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
15+
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main

.github/workflows/release-new-action-version.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
name: releaseNewActionVersion
2222
runs-on: ubuntu-latest
2323
steps:
24-
- name: Update the ${{ env.TAG_NAME }} tag
25-
uses: actions/[email protected]
26-
with:
27-
source-tag: ${{ env.TAG_NAME }}
28-
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
24+
- name: Update the ${{ env.TAG_NAME }} tag
25+
uses: actions/[email protected]
26+
with:
27+
source-tag: ${{ env.TAG_NAME }}
28+
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore list
2+
/*
3+
4+
# Do not ignore these folders:
5+
!__tests__/
6+
!__mocks__/
7+
!.github/
8+
!src/

.prettierrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
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+
};

.prettierrc.json

-12
This file was deleted.

__tests__/main.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('run', () => {
4848
});
4949

5050
it('(with sync-labels: true) it deletes preexisting PR labels that no longer match the glob pattern', async () => {
51-
let mockInput = {
51+
const mockInput = {
5252
'repo-token': 'foo',
5353
'configuration-path': 'bar',
5454
'sync-labels': true
@@ -79,7 +79,7 @@ describe('run', () => {
7979
});
8080

8181
it('(with sync-labels: false) it issues no delete calls even when there are preexisting PR labels that no longer match the glob pattern', async () => {
82-
let mockInput = {
82+
const mockInput = {
8383
'repo-token': 'foo',
8484
'configuration-path': 'bar',
8585
'sync-labels': false

dist/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function run() {
5252
const syncLabels = !!core.getInput('sync-labels', { required: false });
5353
const prNumber = getPrNumber();
5454
if (!prNumber) {
55-
console.log('Could not get pull request number from context, exiting');
55+
core.info('Could not get pull request number from context, exiting');
5656
return;
5757
}
5858
const client = github.getOctokit(token);

0 commit comments

Comments
 (0)