Add and configure ESLint and update configuration for Prettier (#703)

* Add ESLinter and update Prettier

* Update eslint config

* Update dependencies

* Rebuild action

* Update package.json

* Updates docs

* Update docs
This commit is contained in:
Ivan 2023-03-08 10:47:38 +02:00 committed by GitHub
parent 7c29869aec
commit 962678f22c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 3804 additions and 1545 deletions

View file

@ -12,10 +12,10 @@ import * as main from '../src/main';
import * as auth from '../src/authutil';
import {INodeVersion} from '../src/distributions/base-models';
const nodeTestDist = require('./data/node-dist-index.json');
const nodeTestDistNightly = require('./data/node-nightly-index.json');
const nodeTestDistRc = require('./data/node-rc-index.json');
const nodeV8CanaryTestDist = require('./data/v8-canary-dist-index.json');
import nodeTestDist from './data/node-dist-index.json';
import nodeTestDistNightly from './data/node-nightly-index.json';
import nodeTestDistRc from './data/node-rc-index.json';
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
describe('setup-node', () => {
let inputs = {} as any;
@ -86,11 +86,11 @@ describe('setup-node', () => {
getJsonSpy.mockImplementation(url => {
let res: any;
if (url.includes('/rc')) {
res = <INodeVersion>nodeTestDistRc;
res = <INodeVersion[]>nodeTestDistRc;
} else if (url.includes('/nightly')) {
res = <INodeVersion>nodeTestDistNightly;
res = <INodeVersion[]>nodeTestDistNightly;
} else {
res = <INodeVersion>nodeTestDist;
res = <INodeVersion[]>nodeTestDist;
}
return {result: res};
@ -142,7 +142,7 @@ describe('setup-node', () => {
inputs['node-version'] = '12.0.0-rc.1';
inputs.stable = 'true';
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
@ -154,7 +154,7 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
@ -166,16 +166,16 @@ describe('setup-node', () => {
inSpy.mockImplementation(name => inputs[name]);
let toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
findSpy.mockImplementation(() => toolPath);
await main.run();
let expPath = path.join(toolPath, 'bin');
const expPath = path.join(toolPath, 'bin');
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
});
it('handles unhandled find error and reports error', async () => {
let errMsg = 'unhandled error message';
const errMsg = 'unhandled error message';
inputs['node-version'] = '12.0.0-rc.1';
findSpy.mockImplementation(() => {
@ -191,7 +191,7 @@ describe('setup-node', () => {
os.platform = 'linux';
os.arch = 'x64';
let versionSpec = '13.0.0-rc.0';
const versionSpec = '13.0.0-rc.0';
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
@ -201,13 +201,13 @@ describe('setup-node', () => {
findSpy.mockImplementation(() => '');
dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize('/cache/node/13.0.0-rc.0/x64');
const toolPath = path.normalize('/cache/node/13.0.0-rc.0/x64');
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);
await main.run();
let expPath = path.join(toolPath, 'bin');
const expPath = path.join(toolPath, 'bin');
expect(dlSpy).toHaveBeenCalled();
expect(exSpy).toHaveBeenCalled();
@ -220,7 +220,7 @@ describe('setup-node', () => {
os.platform = 'linux';
os.arch = 'x64';
let versionSpec = '9.99.9-rc.1';
const versionSpec = '9.99.9-rc.1';
inputs['node-version'] = versionSpec;
findSpy.mockImplementation(() => '');
@ -232,11 +232,11 @@ describe('setup-node', () => {
});
it('reports a failed download', async () => {
let errMsg = 'unhandled download message';
const errMsg = 'unhandled download message';
os.platform = 'linux';
os.arch = 'x64';
let versionSpec = '14.7.0-rc.1';
const versionSpec = '14.7.0-rc.1';
inputs['node-version'] = versionSpec;
inputs['always-auth'] = false;
@ -271,14 +271,14 @@ describe('setup-node', () => {
inputs['always-auth'] = false;
inputs['token'] = 'faketoken';
let expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
// ... but not in the local cache
findSpy.mockImplementation(() => '');
findAllVersionsSpy.mockImplementation(() => []);
dlSpy.mockImplementation(async () => '/some/temp/path');
let toolPath = path.normalize(`/cache/node/${version}/${arch}`);
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
exSpy.mockImplementation(async () => '/some/other/temp/path');
cacheSpy.mockImplementation(async () => toolPath);