Skip to content

Commit

Permalink
Fix lint (#16)
Browse files Browse the repository at this point in the history
* update prettierrc

* remove rules to simplify

* update
  • Loading branch information
tnyo43 authored Mar 10, 2024
1 parent df4e69d commit 1416075
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 1,241 deletions.
49 changes: 0 additions & 49 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,4 @@ extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended

rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility':
['error', { 'accessibility': 'no-public' }],
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }],
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
}
15 changes: 3 additions & 12 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{

Check warning on line 1 in .prettierrc.json

View workflow job for this annotation

GitHub Actions / lint

File ignored by default.
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
"trailingComma": "all",
"arrowParens": "always"
}
12 changes: 6 additions & 6 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* Unit tests for the action's entrypoint, src/index.ts
*/

import * as main from '../src/main'
import * as main from '../src/main';

// Mock the action's entrypoint
const runMock = jest.spyOn(main, 'run').mockImplementation()
const runMock = jest.spyOn(main, 'run').mockImplementation();

describe('index', () => {
it('calls run when imported', async () => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('../src/index')
require('../src/index');

expect(runMock).toHaveBeenCalled()
})
})
expect(runMock).toHaveBeenCalled();
});
});
89 changes: 46 additions & 43 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test.todo('implement test')
test.todo('implement test');

// /**
// * Unit tests for the action's main functionality, src/main.ts
Expand All @@ -8,84 +8,87 @@ test.todo('implement test')
// * variables following the pattern `INPUT_<INPUT_NAME>`.
// */

// import * as core from '@actions/core'
// import * as main from '../src/main'
// import * as core from '@actions/core';
// import * as main from '../src/main';

// // Mock the action's main function
// const runMock = jest.spyOn(main, 'run')
// const runMock = jest.spyOn(main, 'run');

// // Other utilities
// const timeRegex = /^\d{2}:\d{2}:\d{2}/
// const timeRegex = /^\d{2}:\d{2}:\d{2}/;

// // Mock the GitHub Actions core library
// let debugMock: jest.SpiedFunction<typeof core.debug>
// let errorMock: jest.SpiedFunction<typeof core.error>
// let getInputMock: jest.SpiedFunction<typeof core.getInput>
// let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
// let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
// let debugMock: jest.SpiedFunction<typeof core.debug>;
// let errorMock: jest.SpiedFunction<typeof core.error>;
// let getInputMock: jest.SpiedFunction<typeof core.getInput>;
// let setFailedMock: jest.SpiedFunction<typeof core.setFailed>;
// let setOutputMock: jest.SpiedFunction<typeof core.setOutput>;

// describe('action', () => {

Check warning on line 27 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / lint

Some tests seem to be commented

Check warning on line 27 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / test-typescript

Some tests seem to be commented
// beforeEach(() => {
// jest.clearAllMocks()
// jest.clearAllMocks();

// debugMock = jest.spyOn(core, 'debug').mockImplementation()
// errorMock = jest.spyOn(core, 'error').mockImplementation()
// getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
// setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
// setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
// })
// debugMock = jest.spyOn(core, 'debug').mockImplementation();
// errorMock = jest.spyOn(core, 'error').mockImplementation();
// getInputMock = jest.spyOn(core, 'getInput').mockImplementation();
// setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation();
// setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation();
// });

// it('sets the time output', async () => {

Check warning on line 38 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / lint

Some tests seem to be commented

Check warning on line 38 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / test-typescript

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// getInputMock.mockImplementation((name) => {
// switch (name) {
// case 'milliseconds':
// return '500'
// return '500';
// default:
// return ''
// return '';
// }
// })
// });

// await main.run()
// expect(runMock).toHaveReturned()
// await main.run();
// expect(runMock).toHaveReturned();

// // Verify that all of the core library functions were called correctly
// expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
// expect(debugMock).toHaveBeenNthCalledWith(
// 1,
// 'Waiting 500 milliseconds ...',
// );
// expect(debugMock).toHaveBeenNthCalledWith(
// 2,
// expect.stringMatching(timeRegex)
// )
// expect.stringMatching(timeRegex),
// );
// expect(debugMock).toHaveBeenNthCalledWith(
// 3,
// expect.stringMatching(timeRegex)
// )
// expect.stringMatching(timeRegex),
// );
// expect(setOutputMock).toHaveBeenNthCalledWith(
// 1,
// 'time',
// expect.stringMatching(timeRegex)
// )
// expect(errorMock).not.toHaveBeenCalled()
// })
// expect.stringMatching(timeRegex),
// );
// expect(errorMock).not.toHaveBeenCalled();
// });

// it('sets a failed status', async () => {

Check warning on line 73 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / lint

Some tests seem to be commented

Check warning on line 73 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / test-typescript

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// getInputMock.mockImplementation((name) => {
// switch (name) {
// case 'milliseconds':
// return 'this is not a number'
// return 'this is not a number';
// default:
// return ''
// return '';
// }
// })
// });

// await main.run()
// expect(runMock).toHaveReturned()
// await main.run();
// expect(runMock).toHaveReturned();

// // Verify that all of the core library functions were called correctly
// expect(setFailedMock).toHaveBeenNthCalledWith(
// 1,
// 'milliseconds not a number'
// )
// expect(errorMock).not.toHaveBeenCalled()
// })
// })
// 'milliseconds not a number',
// );
// expect(errorMock).not.toHaveBeenCalled();
// });
// });
24 changes: 12 additions & 12 deletions __tests__/wait.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
* Unit tests for src/wait.ts
*/

import { wait } from '../src/wait'
import { wait } from '../src/wait';

describe('wait.ts', () => {
it('throws an invalid number', async () => {
const input = parseInt('foo', 10)
expect(isNaN(input)).toBe(true)
const input = parseInt('foo', 10);
expect(isNaN(input)).toBe(true);

await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})
await expect(wait(input)).rejects.toThrow('milliseconds not a number');
});

it('waits with a valid number', async () => {
const start = new Date()
await wait(500)
const end = new Date()
const start = new Date();
await wait(500);
const end = new Date();

const delta = Math.abs(end.getTime() - start.getTime())
const delta = Math.abs(end.getTime() - start.getTime());

expect(delta).toBeGreaterThan(450)
})
})
expect(delta).toBeGreaterThan(450);
});
});
20 changes: 10 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"@typescript-eslint/parser": "^7.1.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.56.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsonc": "^2.13.0",
"eslint-plugin-prettier": "^5.1.3",
Expand Down
Loading

0 comments on commit 1416075

Please sign in to comment.