Skip to content

Commit

Permalink
Add tests for oldest and newest supported versions of eslint.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Mar 20, 2024
1 parent 2da23eb commit 78e9b57
Show file tree
Hide file tree
Showing 21 changed files with 897 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"suppressions": [
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass.exampleMethod",
"rule": "no-var"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "no-useless-concat"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "dot-notation"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "no-empty"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
"rule": "no-unused-expressions"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "no-empty-pattern"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "no-extra-boolean-cast"
},
{
"file": "src/index.ts",
"scopeId": ".exampleObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".x",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".y",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".z",
"rule": "@typescript-eslint/explicit-function-return-type"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');

module.exports = {
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
ignorePatterns: ['.eslintrc.js'],

overrides: [
/**
* Override the parser from @rushstack/eslint-config. Since the config is coming
* from the workspace instead of the external NPM package, the versions of ESLint
* and TypeScript that the config consumes will be resolved from the devDependencies
* of the config instead of from the eslint-8-test package. Overriding the parser
* ensures that the these dependencies come from the eslint-8-test package. See:
* https://github.com/microsoft/rushstack/issues/3021
*/
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: { project: '../tsconfig.json', tsconfigRootDir: __dirname }
}
]
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

/* Top-level scope code samples */
// scopeId: '.'
let exampleString: string = 5 + '';

const exampleObject = {
exampleString: exampleString
};

/* Function scope code samples */
export function exampleFunction() {
const {}: Object = exampleObject;

// scopeId: '.exampleFunction'
!!!exampleString as Boolean;
}

// scope: '.ArrowFunctionExpression',
export const x = () => {},
// scopeId: '.y'
y = () => {},
// scopeId: '.z'
z = () => {};

/* Class scope code samples */
export class ExampleClass {
// scopeId: '.ExampleClass'
exampleClassProperty: String = exampleString + '4';

exampleMethod() {
// scopeId: '.exampleClass.exampleMethod'
var exampleVar;
return exampleVar;
}
}

/* Variable and anonymous constructs code samples */
export const exampleArrowFunction = () => {
const exampleBoolean = true;
if (exampleBoolean) {
}

exampleObject['exampleString'];
};

export const exampleAnonymousClass = class {
exampleClassProperty = 'x' + 'y';

// scopeId: '.exampleAnonymousClass.constructor'
constructor() {}

set exampleSetGet(val: string) {
// scopeId: '.exampleAnonymousClass.exampleSetGet'
let exampleVariable: Number = 1;
this.exampleClassProperty = val + exampleVariable;
}

get exampleSetGet() {
// scopeId: '.exampleAnonymousClass.exampleSetGet'
return this.exampleClassProperty as String as string;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
16 changes: 16 additions & 0 deletions build-tests/eslint-bulk-suppressions-newest-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "eslint-bulk-suppressions-newest-test",
"description": "Sample code to test eslint bulk suppressions",
"version": "1.0.0",
"private": true,
"scripts": {
"_phase:build": "eslint ."
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"local-node-rig": "workspace:*",
"@typescript-eslint/parser": "~6.19.0",
"eslint": "~8.23.1",
"typescript": "~5.3.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"suppressions": [
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "@typescript-eslint/no-namespace"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-function-return-type"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".AbsurdClass.absurdClassMethod.AbsurdClass2.constructor.absurdObject",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleEnum",
"rule": "dot-notation"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleInterface",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleInterface2",
"rule": "@typescript-eslint/naming-convention"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleObjectType",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleObjectType",
"rule": "@typescript-eslint/consistent-type-definitions"
},
{
"file": "src/index.ts",
"scopeId": ".exampleObject2",
"rule": "@typescript-eslint/typedef"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
require('local-node-rig/profiles/default/includes/eslint/patch/eslint-bulk-suppressions');

module.exports = {
extends: [
'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
],
ignorePatterns: ['.eslintrc.js'],

overrides: [
/**
* Override the parser from @rushstack/eslint-config. Since the config is coming
* from the workspace instead of the external NPM package, the versions of ESLint
* and TypeScript that the config consumes will be resolved from the devDependencies
* of the config instead of from the eslint-8-test package. Overriding the parser
* ensures that the these dependencies come from the eslint-8-test package. See:
* https://github.com/microsoft/rushstack/issues/3021
*/
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
parserOptions: { project: '../tsconfig.json', tsconfigRootDir: __dirname }
}
]
};
Loading

0 comments on commit 78e9b57

Please sign in to comment.