Skip to content

Commit

Permalink
Add and configure ESLint and update configuration for Prettier (#508)
Browse files Browse the repository at this point in the history
* Add ESLint and update Prettier

* Rebuild action

* Update package.json
  • Loading branch information
IvanZosimov committed Mar 9, 2023
1 parent ba790c8 commit 8d81f88
Show file tree
Hide file tree
Showing 17 changed files with 2,397 additions and 190 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
@@ -0,0 +1,7 @@
# Ignore list
/*

# Do not ignore these folders:
!__tests__/
!__mocks__/
!src/
49 changes: 49 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,49 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}]
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',

}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1,4 +1,4 @@
* text=auto
* text=auto eol=lf
.licenses/** -diff linguist-generated=true

# don't diff machine generated files
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
@@ -1 +1 @@
blank_issues_enabled: false
blank_issues_enabled: false
2 changes: 1 addition & 1 deletion .github/workflows/basic-validation.yml
Expand Up @@ -14,4 +14,4 @@ on:
jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Expand Up @@ -14,4 +14,4 @@ on:
jobs:
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -2,13 +2,13 @@ name: CodeQL analysis

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 3 * * 0'

jobs:
call-codeQL-analysis:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
2 changes: 1 addition & 1 deletion .github/workflows/licensed.yml
Expand Up @@ -12,4 +12,4 @@ on:
jobs:
call-licensed:
name: Licensed
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
10 changes: 5 additions & 5 deletions .github/workflows/release-new-action-version.yml
Expand Up @@ -21,8 +21,8 @@ jobs:
name: releaseNewActionVersion
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.2
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
- name: Update the ${{ env.TAG_NAME }} tag
uses: actions/publish-action@v0.2.2
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
8 changes: 8 additions & 0 deletions .prettierignore
@@ -0,0 +1,8 @@
# Ignore list
/*

# Do not ignore these folders:
!__tests__/
!__mocks__/
!.github/
!src/
10 changes: 10 additions & 0 deletions .prettierrc.js
@@ -0,0 +1,10 @@
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};
12 changes: 0 additions & 12 deletions .prettierrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Expand Up @@ -48,7 +48,7 @@ describe('run', () => {
});

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

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 () => {
let mockInput = {
const mockInput = {
'repo-token': 'foo',
'configuration-path': 'bar',
'sync-labels': false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Expand Up @@ -52,7 +52,7 @@ function run() {
const syncLabels = !!core.getInput('sync-labels', { required: false });
const prNumber = getPrNumber();
if (!prNumber) {
console.log('Could not get pull request number from context, exiting');
core.info('Could not get pull request number from context, exiting');
return;
}
const client = github.getOctokit(token);
Expand Down

1 comment on commit 8d81f88

@Princeprince559
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/Active.

Please sign in to comment.