Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ yarn.lock
_accessibility-reports/
**/.taskkey
.gdnsuppress
packages/**/build
56 changes: 56 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import tseslint from '@typescript-eslint/eslint-plugin';
import security from 'eslint-plugin-security';
import tsParser from '@typescript-eslint/parser';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default [
{
ignores: ['**/build/**', '**/dist/**', '**/lib/**', '**/node_modules/**'],
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: ['./tsconfig.json', './packages/ado-extension/tsconfig.json', './packages/shared/tsconfig.json'],
tsconfigRootDir: __dirname,
sourceType: 'module',
},
globals: {
...globals.node,
},
},
plugins: {
'@typescript-eslint': tseslint,
security: security,
},

rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',

'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
{
files: ['packages/ado-extension/**/*.{ts,js}'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.node,
},
},
},
];
5 changes: 3 additions & 2 deletions license-check-and-add-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"**/yarn.lock",
"cred-scan-suppressions.json",
"package.json",
"guardian"
"guardian",
"**/build/**"
],
"license": "./copyright-header.txt",
"licenseFormats": {
Expand All @@ -26,7 +27,7 @@
"prepend": "# "
}
},
"ts|tsx|d.ts|js|scss|css": {
"ts|tsx|d.ts|js|scss|css|mjs": {
"eachLine": {
"prepend": "// "
}
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@typescript-eslint/parser": "^6.18.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"codecov": "^3.8.3",
"eslint": "^8.57.0",
"eslint-plugin-security": "^1.7.1",
"eslint": "9.24.0",
"eslint-plugin-security": "^3.0.1",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
Expand All @@ -67,7 +67,7 @@
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"typemoq": "^2.1.0",
"typescript": "^5.6.3",
"typescript": "5.3.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4"
},
Expand All @@ -83,6 +83,8 @@
"path-to-regexp": "^1.9.0",
"express": "^4.21.0",
"serve-static": "^1.16.0",
"send": "^0.19.0"
"send": "^0.19.0",
"@types/express": "^4.17.21",
"@types/express-serve-static-core": "^4.17.37"
}
}
1 change: 0 additions & 1 deletion packages/ado-extension/e2e/mock-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class MockTestRunner {
}

public ran(cmdline: string): boolean {
// eslint-disable-next-line no-prototype-builtins
return this.cmdlines.hasOwnProperty(cmdline.trim());
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ado-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build": "webpack --config ./webpack.config.js && node prepare-package-dir.js",
"cbuild": "npm-run-all --serial clean build",
"clean": "rimraf dist",
"lint:check": "eslint -c ../../.eslintrc.js \"{src,e2e}/**/*.{js,ts}\"",
"lint:fix": "eslint -c ../../.eslintrc.js \"{src,e2e}/**/*.{js,ts}\" --quiet --fix",
"lint:check": "eslint -c ../../eslint.config.mjs \"{src,e2e}/**/*.{js,ts}\"",
"lint:fix": "eslint -c ../../eslint.config.mjs \"{src,e2e}/**/*.{js,ts}\" --quiet --fix",
"package": "cd dist && tfx extension create --manifest-globs ado-extension.json",
"start": "node scripts/run-locally.js",
"test": "jest --rootDir src",
Expand Down Expand Up @@ -39,7 +39,7 @@
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
"eslint": "^8.57.0",
"eslint": "9.24.0",
"eslint-plugin-security": "^1.7.1",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"jest": "^29.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ describe(ADOArtifactsInfoProvider, () => {
({ collectionUri, teamProject, runId, expectedUrl }) => {
adoTaskConfigMock
.setup((atc) => atc.getCollectionUri())
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

.returns(() => collectionUri)
.verifiable(Times.once());
adoTaskConfigMock
.setup((atc) => atc.getTeamProject())
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

.returns(() => teamProject)
.verifiable(Times.once());
adoTaskConfigMock
.setup((atc) => atc.getRunId())
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

.returns(() => runId)
.verifiable(Times.once());

Expand All @@ -84,7 +84,7 @@ describe(ADOArtifactsInfoProvider, () => {
`(`getCommitHash with hash value '$hashValue' returns '$expectedValue'`, ({ hashValue, expectedValue }) => {
adoTaskConfigMock
.setup((atc) => atc.getCommitHash())
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

.returns(() => hashValue)
.verifiable(Times.once());

Expand Down
2 changes: 0 additions & 2 deletions packages/ado-extension/src/ado-extension-metadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import type * as fs from 'fs';
import * as path from 'path';
import { AdoExtensionMetadataProvider } from './ado-extension-metadata';

/* eslint-disable security/detect-non-literal-fs-filename */

describe(AdoExtensionMetadataProvider, () => {
const metadataFileContentsWithTelemetry = `{
"publisherId": "accessibility-insights",
Expand Down
4 changes: 2 additions & 2 deletions packages/ado-extension/src/ado-extension-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export class AdoExtensionMetadataProvider {

// This is a literal filename, the linter just can't see through the path.join
//
// eslint-disable-next-line security/detect-non-literal-fs-filename

const rawMetadata = this.fileSystemObj.readFileSync(metadataFilePath, { encoding: 'utf8' });

// We allow the unsafe assignment and "as" usage because we trust that
// package-vsix-file.yaml produces a valid metadata file
//
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

const parsedMetadata = JSON.parse(rawMetadata) as AdoExtensionMetadata;

if (parsedMetadata.appInsightsConnectionString === '') {
Expand Down
2 changes: 0 additions & 2 deletions packages/ado-extension/src/ado-extension-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ function mockContainer() {

// Mock get(Scanner), but leave other values like get(Logger) intact
function mockContainerGet(serviceIdentifier: inversify.interfaces.ServiceIdentifier<Scanner | Logger>): { scan: jest.Mock } | Logger {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const originalModule = jest.requireActual('./ioc/setup-ioc-container');

if (serviceIdentifier === Scanner) {
return {
scan: jest.fn().mockImplementationOnce(() => scanResponse),
};
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return
return originalModule.setupIocContainer().get(serviceIdentifier);
}
}
1 change: 0 additions & 1 deletion packages/ado-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { installRuntimeDependencies } from './install-runtime-dependencies';

installRuntimeDependencies();

// eslint-disable-next-line @typescript-eslint/no-floating-promises
import('./ado-extension').then(async (adoExtension) => {
await adoExtension.runScan();
process.exit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const regexTransformations: RegexTransformation[] = [
method: replaceFirstMatchWithEndgroupPrefix,
},
{
// eslint-disable-next-line no-control-regex
regex: new RegExp('^\u001B\\[32mINFO\u001b\\[39m '), // Includes escape characters used for color formatting)
method: replaceFirstMatchWithDebugPrefix,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import * as path from 'path';

import { RecordingTestLogger, ReportConsoleLogConvertor, ReportMarkdownConvertor } from '@accessibility-insights-action/shared';

/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

describe(AdoConsoleCommentCreator, () => {
let adoTaskConfigMock: IMock<ADOTaskConfig>;
let logger: RecordingTestLogger;
Expand Down Expand Up @@ -84,7 +81,6 @@ describe(AdoConsoleCommentCreator, () => {
jobAttempt,
});

// eslint-disable-next-line security/detect-non-literal-fs-filename
fsMock.setup((fsm) => fsm.writeFileSync(expectedSummaryFilePath, reportMarkdownStub)).verifiable(Times.once());

await testSubject.completeRun(reportStub);
Expand Down Expand Up @@ -151,13 +147,13 @@ describe(AdoConsoleCommentCreator, () => {
const snapshotDirectory = `${defaultReportOutDir}/key_value_stores/scan-results`;

fsMock
// eslint-disable-next-line security/detect-non-literal-fs-filename

.setup((fsm) => fsm.existsSync(`${snapshotDirectory}`))
.returns(() => true)
.verifiable(Times.once());

fsMock
// eslint-disable-next-line security/detect-non-literal-fs-filename

.setup((fsm) => fsm.readdirSync(`${snapshotDirectory}`))
.returns(() => ['snapshot1.screenshot.jpg', 'snapshot2.screenshot.jpg', 'this-is-not-a-snapshot.txt'])
.verifiable(Times.once());
Expand Down Expand Up @@ -194,7 +190,7 @@ describe(AdoConsoleCommentCreator, () => {
const snapshotDirectory = `${defaultReportOutDir}/key_value_stores/scan-results`;

fsMock
// eslint-disable-next-line security/detect-non-literal-fs-filename

.setup((fsm) => fsm.existsSync(`${snapshotDirectory}`))
.returns(() => true)
.verifiable(Times.never());
Expand Down Expand Up @@ -242,7 +238,7 @@ describe(AdoConsoleCommentCreator, () => {
const expectedBaselineOutputFilePath = `${defaultReportOutDir}/${baselineFilenameStub}`;

fsMock
// eslint-disable-next-line security/detect-non-literal-fs-filename

.setup((fsm) => fsm.existsSync(`${expectedBaselineOutputFilePath}`))
.returns(() => baselineFileExists as boolean)
.verifiable(Times.once());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class AdoConsoleCommentCreator extends ProgressReporter {
return Promise.resolve();
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public async failRun(): Promise<void> {
// We don't do anything for failed runs
}
Expand All @@ -65,7 +64,6 @@ export class AdoConsoleCommentCreator extends ProgressReporter {

const summaryFilePath = this.pathObj.join(outDirectory, this.summaryMarkdownFileName(artifactName));

// eslint-disable-next-line security/detect-non-literal-fs-filename
this.fileSystemObj.writeFileSync(summaryFilePath, reportMarkdown);
this.logger.logInfo(`##vso[task.uploadsummary]${summaryFilePath}`);
}
Expand Down Expand Up @@ -112,7 +110,6 @@ export class AdoConsoleCommentCreator extends ProgressReporter {

this.logger.logInfo(`##vso[artifact.upload artifactname=${artifactName}]${reportFilePath}`);

// eslint-disable-next-line security/detect-non-literal-fs-filename
if (baselineFilePath !== undefined && this.fileSystemObj.existsSync(baselineFilePath)) {
this.logger.logInfo(`##vso[artifact.upload artifactname=${artifactName}]${baselineFilePath}`);
}
Expand All @@ -135,9 +132,8 @@ export class AdoConsoleCommentCreator extends ProgressReporter {
const outputDirectory = this.taskConfig.getReportOutDir();
const snapshotOutputDirectory = this.pathObj.join(outputDirectory, 'key_value_stores', 'scan-results');
const snapshotFilePaths: string[] = [];
// eslint-disable-next-line security/detect-non-literal-fs-filename

if (this.fileSystemObj.existsSync(snapshotOutputDirectory)) {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const files = this.fileSystemObj.readdirSync(snapshotOutputDirectory);
files.forEach((snapshotFileName) => {
if (snapshotFileName.includes('screenshot')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class AdoWorkflowEnforcer extends ProgressReporter {
// We don't do anything for workflow enforcement
}

// eslint-disable-next-line @typescript-eslint/require-await
public async completeRun(combinedReportResult: CombinedReportParameters, baselineEvaluation?: BaselineEvaluation): Promise<void> {
const baselineFileInput = this.adoTaskConfig.getBaselineFile();

Expand All @@ -33,7 +32,6 @@ export class AdoWorkflowEnforcer extends ProgressReporter {
}
}

// eslint-disable-next-line @typescript-eslint/require-await
public async failRun(): Promise<void> {
this.scanSucceeded = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe(TelemetrySender, () => {
}

function setupTelemetryClientWithEvent(generateWithBaselineEnabled: boolean): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const eventProperties: { [key: string]: any } = {};
const telemetryErrorCollector: { [key: string]: any } = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export class TelemetrySender extends ProgressReporter {
// We don't send anything for telemetry
}

// eslint-disable-next-line @typescript-eslint/require-await
public async completeRun(combinedReportResult: CombinedReportParameters, baselineEvaluation?: BaselineEvaluation): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const eventProperties: { [key: string]: any } = {};
const telemetryErrorCollector = new TelemetryErrorCollector('TelemetrySender');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe(ADOTaskConfig, () => {
.returns(() => inputValue as string)
.verifiable(Times.once());
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call

const retrievedOption: unknown = getInputFunc();
expect(retrievedOption).toStrictEqual(expectedValue);
},
Expand Down
Loading
Loading