Skip to content

Commit c150de0

Browse files
committed
wip
1 parent e855d6f commit c150de0

File tree

17 files changed

+286
-134
lines changed

17 files changed

+286
-134
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tseslint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
3+
4+
export default tseslint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Error Code: 7006
3+
* Compiler Option: noImplicitAny
4+
* Description: Parameter 'param' implicitly has an 'any' type.
5+
*/
6+
function noImplicitAnyError(param) {
7+
console.log(param);
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"rootDir": "./src",
4+
"target": "ES6",
5+
"module": "CommonJS"
6+
},
7+
"include": ["src/**/*.ts"],
8+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "plugin-typescript-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "e2e/plugin-typescript-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"lint": {
8+
"executor": "@nx/linter:eslint",
9+
"outputs": ["{options.outputFile}"],
10+
"options": {
11+
"lintFilePatterns": ["e2e/plugin-typescript-e2e/**/*.ts"]
12+
}
13+
},
14+
"e2e": {
15+
"executor": "@nx/vite:test",
16+
"options": {
17+
"configFile": "e2e/plugin-typescript-e2e/vite.config.e2e.ts"
18+
}
19+
}
20+
},
21+
"implicitDependencies": ["cli", "plugin-typescript"],
22+
"tags": ["scope:plugin", "type:e2e"]
23+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {cp} from 'node:fs/promises';
2+
import path from 'node:path';
3+
import {afterAll, beforeAll, expect} from 'vitest';
4+
import {nxTargetProject} from '@code-pushup/test-nx-utils';
5+
import {teardownTestFolder} from '@code-pushup/test-setup';
6+
import {E2E_ENVIRONMENTS_DIR, removeColorCodes, TEST_OUTPUT_DIR,} from '@code-pushup/test-utils';
7+
import {executeProcess, readJsonFile} from '@code-pushup/utils';
8+
import {getCurrentTsVersion} from "@code-pushup/typescript-plugin";
9+
10+
describe('PLUGIN collect report with typescript-plugin NPM package', () => {
11+
const testFileDir = path.join(
12+
E2E_ENVIRONMENTS_DIR,
13+
nxTargetProject(),
14+
TEST_OUTPUT_DIR,
15+
'collect',
16+
);
17+
const defaultSetupDir = path.join(testFileDir, 'default-setup');
18+
19+
const fixturesDir = path.join('e2e', nxTargetProject(), 'mocks/fixtures');
20+
21+
beforeAll(async () => {
22+
await cp(fixturesDir, testFileDir, {recursive: true});
23+
});
24+
25+
afterAll(async () => {
26+
await teardownTestFolder(testFileDir);
27+
});
28+
29+
it('should run plugin over CLI and creates report.json', async () => {
30+
const {code, stdout} = await executeProcess({
31+
command: 'npx',
32+
// verbose exposes audits with perfect scores that are hidden in the default stdout
33+
args: ['@code-pushup/cli', 'collect', '--no-progress', '--verbose'],
34+
cwd: defaultSetupDir,
35+
});
36+
37+
expect(code).toBe(0);
38+
const cleanStdout = removeColorCodes(stdout);
39+
expect(cleanStdout).toContain('● NoImplicitAny');
40+
41+
await expect(readJsonFile(
42+
path.join('node_modules', '.code-pushup', 'plugin-typescript', 'default-ts-configs', await getCurrentTsVersion()),
43+
)).resolves.not.toThrow();
44+
});
45+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"types": ["vitest"]
12+
},
13+
"files": [],
14+
"include": [],
15+
"references": [
16+
{
17+
"path": "./tsconfig.test.json"
18+
}
19+
]
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"],
6+
"target": "ES2020"
7+
},
8+
"include": [
9+
"vite.config.e2e.ts",
10+
"tests/**/*.e2e.test.ts",
11+
"tests/**/*.d.ts",
12+
"mocks/**/*.ts"
13+
]
14+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference types="vitest" />
2+
import { defineConfig } from 'vite';
3+
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';
4+
5+
export default defineConfig({
6+
cacheDir: '../../node_modules/.vite/plugin-typescript-e2e',
7+
test: {
8+
reporters: ['basic'],
9+
testTimeout: 120_000,
10+
globals: true,
11+
alias: tsconfigPathAliases(),
12+
pool: 'threads',
13+
poolOptions: { threads: { singleThread: true } },
14+
cache: {
15+
dir: '../../node_modules/.vitest',
16+
},
17+
environment: 'node',
18+
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
19+
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'],
20+
},
21+
});

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@code-pushup/portal-client": "^0.9.0",
2828
"@isaacs/cliui": "^8.0.2",
2929
"@nx/devkit": "19.8.13",
30-
"@poppinss/cliui": "^6.4.2",
30+
"@poppinss/cliui": "^6.4.1",
3131
"@swc/helpers": "0.5.13",
3232
"ansis": "^3.3.2",
3333
"build-md": "^0.4.2",

0 commit comments

Comments
 (0)