Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typescript plugin poc implementation #902

Open
wants to merge 109 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
da9891e
test(test-setup): add custom path matcher to vitest, add tests
BioPhoton Nov 19, 2024
d166627
format
BioPhoton Nov 19, 2024
332c963
fix build
BioPhoton Nov 19, 2024
dd21bfd
wip
BioPhoton Nov 19, 2024
9d2dcab
test: refactor typings
BioPhoton Nov 19, 2024
619a2bc
refactor: adjust types
BioPhoton Nov 22, 2024
13f9374
Merge branch 'main' into test-custom-matcher-paths-os-agnostic
BioPhoton Nov 22, 2024
b81df43
test(test-setup): fix custom path matchers type definitions
matejchalk Dec 10, 2024
7194c09
Merge branch 'main' into test-custom-matcher-paths-os-agnostic
matejchalk Dec 10, 2024
44aa3ab
Update vite.config.unit.ts
BioPhoton Dec 17, 2024
3703047
Update path.matcher.ts
BioPhoton Dec 17, 2024
1618c11
Update path.matcher.ts
BioPhoton Dec 17, 2024
499a67e
Update path.matcher.ts
BioPhoton Dec 17, 2024
e350aa6
Update path.matcher.ts
BioPhoton Dec 17, 2024
b896dab
wip
BioPhoton Dec 22, 2024
78d6c6c
wip
BioPhoton Dec 22, 2024
ebaebe1
Merge branch 'main' into test-custom-matcher-paths-os-agnostic
BioPhoton Dec 22, 2024
a1642c7
fix lint
BioPhoton Dec 22, 2024
0a75f47
feat: add TypeScript plugin
BioPhoton Dec 23, 2024
63a3129
wip
BioPhoton Dec 23, 2024
1606175
wip
BioPhoton Dec 23, 2024
eead92f
wip
BioPhoton Dec 23, 2024
a92c487
wip
BioPhoton Dec 23, 2024
7abace2
fix lint
BioPhoton Dec 23, 2024
84b0bc6
fix format
BioPhoton Dec 23, 2024
01d044e
wip
BioPhoton Dec 23, 2024
e3c0d48
add category
BioPhoton Dec 23, 2024
7683533
fix: adjust plugin options
BioPhoton Dec 24, 2024
c1cff7b
fix: adjust plugin options for audits
BioPhoton Dec 24, 2024
62e4ba0
wip
BioPhoton Dec 24, 2024
0a48be4
wip
BioPhoton Dec 24, 2024
381ffbb
wip
BioPhoton Dec 24, 2024
a32f9b2
wip
BioPhoton Dec 24, 2024
c7f2d3a
wip
BioPhoton Dec 24, 2024
ba00774
wip
BioPhoton Dec 24, 2024
73232cd
add groups
BioPhoton Dec 25, 2024
ce4daa6
refactor static ts error data
BioPhoton Dec 25, 2024
68f56c8
feat(plugin-typescript): new tests, docs, readme, remove unused asyncโ€ฆ
aramirezj Dec 25, 2024
7c67433
merge PR
BioPhoton Dec 25, 2024
7ecb376
wip
BioPhoton Dec 25, 2024
8bd94f6
wip
BioPhoton Dec 25, 2024
e229455
wip
BioPhoton Dec 25, 2024
1b4d4bb
feat: add ts config default generator
BioPhoton Dec 26, 2024
cee894f
wip
BioPhoton Dec 26, 2024
e8ab0e4
wip
BioPhoton Dec 26, 2024
9ee6857
wip
BioPhoton Dec 26, 2024
f02dd08
wip
BioPhoton Dec 26, 2024
26c12d0
cleanup config and imports
BioPhoton Dec 26, 2024
4c71a2b
wip
BioPhoton Dec 27, 2024
233fe92
wip
BioPhoton Dec 27, 2024
039ed97
wip
BioPhoton Dec 27, 2024
bea7105
wip
BioPhoton Dec 27, 2024
05b2504
wip
BioPhoton Dec 27, 2024
1f17b67
wip
BioPhoton Dec 27, 2024
64876ed
wip
BioPhoton Dec 27, 2024
6f702d7
wip
BioPhoton Dec 27, 2024
58bb4f8
wip
BioPhoton Dec 27, 2024
d7d797c
wip
BioPhoton Dec 27, 2024
eda1681
chore(plugin-typescript): wip (#906)
aramirezj Dec 27, 2024
06b39ca
feat: add postinstall to typescript plugin
BioPhoton Dec 27, 2024
f6b8f59
wip
BioPhoton Dec 27, 2024
4ceac7f
fix lint
BioPhoton Dec 27, 2024
396b761
refactor tests
BioPhoton Dec 28, 2024
4092fa0
refactor unit tests
BioPhoton Dec 28, 2024
21ee2fe
refactor unit tests
BioPhoton Dec 28, 2024
1b0a8f3
wip
BioPhoton Dec 28, 2024
e855d6f
Update package.json
BioPhoton Dec 28, 2024
c150de0
wip
BioPhoton Dec 28, 2024
b3a38b3
test: setup basic e2e
BioPhoton Dec 28, 2024
430186e
wip
BioPhoton Dec 28, 2024
55f4e2c
wip
BioPhoton Dec 28, 2024
137fe52
wip
BioPhoton Dec 28, 2024
350f971
fix unit and integration tests
BioPhoton Dec 28, 2024
8792092
wip
BioPhoton Dec 28, 2024
0cf36a8
wip
BioPhoton Dec 28, 2024
17ae3b1
wip
BioPhoton Dec 28, 2024
34ba6cc
wip
BioPhoton Dec 28, 2024
3d7ac94
wip
BioPhoton Dec 28, 2024
61a1623
wip
BioPhoton Dec 28, 2024
a87fc03
test: add basic e2e
BioPhoton Dec 29, 2024
a8c252e
wip
BioPhoton Dec 29, 2024
e812e3c
wip
BioPhoton Dec 29, 2024
17ea733
fix e2e
BioPhoton Dec 29, 2024
7bca00e
e2e
BioPhoton Dec 29, 2024
c4a3889
e2e
BioPhoton Dec 29, 2024
0938ffd
wip
BioPhoton Dec 29, 2024
d656b23
wip
BioPhoton Dec 29, 2024
0d06579
fix: refactor types
BioPhoton Dec 30, 2024
5a53391
wip
BioPhoton Dec 30, 2024
a31e15d
wip
BioPhoton Dec 30, 2024
eca4416
refactor to code ranges
BioPhoton Jan 1, 2025
5c80d53
fix tests for to code ranges
BioPhoton Jan 2, 2025
b947f5e
cleanup
BioPhoton Jan 2, 2025
ebd6e8b
cleanup
BioPhoton Jan 2, 2025
51ae9fe
cleanup
BioPhoton Jan 2, 2025
57e33f3
Merge branch 'main' into plugin-typescript
BioPhoton Jan 2, 2025
8146f93
Merge branch 'main' into test-custom-matcher-paths-os-agnostic
BioPhoton Jan 5, 2025
2db3010
wip
BioPhoton Jan 5, 2025
0870140
e2e issues 1
BioPhoton Jan 5, 2025
967280a
e2e issues 2
BioPhoton Jan 5, 2025
bbfeb57
e2e issues 3
BioPhoton Jan 5, 2025
71e0062
Merge branch 'test-custom-matcher-paths-os-agnostic' into plugin-typeโ€ฆ
BioPhoton Jan 5, 2025
c85c44d
wip
BioPhoton Jan 5, 2025
5aacd8d
wip
BioPhoton Jan 5, 2025
4a687f7
wip
BioPhoton Jan 5, 2025
8f3dc47
timeout 1
BioPhoton Jan 5, 2025
9414f47
timeout 2
BioPhoton Jan 5, 2025
2a33c78
timeout 3
BioPhoton Jan 5, 2025
56531e9
Merge branch 'main' into plugin-typescript
BioPhoton Jan 6, 2025
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
5 changes: 5 additions & 0 deletions code-pushup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
eslintCoreConfigNx,
jsPackagesCoreConfig,
lighthouseCoreConfig,
typescriptPluginConfigNx,
} from './code-pushup.preset.js';
import type { CoreConfig } from './packages/models/src/index.js';
import { mergeConfigs } from './packages/utils/src/index.js';
Expand Down Expand Up @@ -38,5 +39,9 @@ export default mergeConfigs(
await lighthouseCoreConfig(
'https://github.com/code-pushup/cli?tab=readme-ov-file#code-pushup-cli/',
),
await typescriptPluginConfigNx({
tsConfigPath:
'packages/plugin-typescript/mocks/fixtures/basic-setup/tsconfig.json',
}),
await eslintCoreConfigNx(),
);
48 changes: 48 additions & 0 deletions code-pushup.preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js';
import lighthousePlugin, {
lighthouseGroupRef,
} from './packages/plugin-lighthouse/src/index.js';
import {
type TypescriptPluginOptions,
typescriptPlugin,
} from './packages/plugin-typescript/src/index.js';
import { getCategoryRefsFromGroups } from './packages/plugin-typescript/src/lib/utils.js';

export const jsPackagesCategories: CategoryConfig[] = [
{
Expand Down Expand Up @@ -129,6 +134,49 @@ export const eslintCoreConfigNx = async (
};
};

export const typescriptPluginConfigNx = async (
options?: TypescriptPluginOptions,
): Promise<CoreConfig> => {
return {
plugins: [await typescriptPlugin(options)],
categories: [
{
slug: 'typescript',
title: 'Typescript - All Groups',
refs: await getCategoryRefsFromGroups(options),
},
{
slug: 'bug-prevention',
title: 'Bug prevention',
refs: await getCategoryRefsFromGroups({
onlyAudits: [
'syntax-errors',
'semantic-errors',
'internal-errors',
'configuration-errors',
],
}),
},
{
slug: 'code-style',
title: 'Code style',
description:
'TypeScript & Lint rules that promote **good practices** and consistency in your code.',
refs: await getCategoryRefsFromGroups({ onlyAudits: ['suggestions'] }),
},
{
slug: 'miscellaneous',
title: 'Miscellaneous',
description:
'Errors that do not bring any specific value to the developer, but are still useful to know.',
refs: await getCategoryRefsFromGroups({
onlyAudits: ['unknown-codes', 'language-service-errors'],
}),
},
],
};
};

export const coverageCoreConfigNx = async (
projectName?: string,
): Promise<CoreConfig> => {
Expand Down
12 changes: 12 additions & 0 deletions e2e/plugin-typescript-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tseslint from 'typescript-eslint';
import baseConfig from '../../eslint.config.js';

export default tseslint.config(...baseConfig, {
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { CoreConfig } from '@code-pushup/models';
import {getCategoryRefsFromGroups, typescriptPlugin} from "@code-pushup/typescript-plugin";

export default {
plugins: [
await typescriptPlugin({
tsConfigPath: 'tsconfig.json',
}),
],
categories: [
{
slug: 'typescript-quality',
title: 'Typescript',
refs: await getCategoryRefsFromGroups({
tsConfigPath: 'tsconfig.json',
})
}
],
} satisfies CoreConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function test() {
return 'test';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const a = { ; // Error: TS1136: Property assignment expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 2683 - NoImplicitThis: 'this' implicitly has type 'any'.
function noImplicitThisTS2683() {
console.log(this.value); // Error 2683
}

// 2531 - StrictNullChecks: Object is possibly 'null'.
const strictNullChecksTS2531: string = null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Standalone {
override method() { // Error: TS4114 - 'override' modifier can only be used in a class derived from a base class.
console.log("Standalone method");
}
}
const s = Standalone;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { test } from '../exclude/utils'; // TS6059:: File 'exclude/utils.ts' is not under 'rootDir' '.../configuration-errors'. 'rootDir' is expected to contain all source files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"rootDir": "./src",
"target": "ES6",
"module": "CommonJS",
"strict": true,
"verbatimModuleSyntax": false
},
"include": ["src/**/*.ts"],
}
23 changes: 23 additions & 0 deletions e2e/plugin-typescript-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "plugin-typescript-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "e2e/plugin-typescript-e2e/src",
"projectType": "application",
"targets": {
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["e2e/plugin-typescript-e2e/**/*.ts"]
}
},
"e2e": {
"executor": "@nx/vite:test",
"options": {
"configFile": "e2e/plugin-typescript-e2e/vite.config.e2e.ts"
}
}
},
"implicitDependencies": ["cli", "plugin-typescript"],
"tags": ["scope:plugin", "type:e2e"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"categories": [
{
"refs": [
{
"plugin": "typescript",
"slug": "problems-group",
"type": "group",
"weight": 1,
},
{
"plugin": "typescript",
"slug": "ts-configuration-group",
"type": "group",
"weight": 1,
},
{
"plugin": "typescript",
"slug": "miscellaneous-group",
"type": "group",
"weight": 1,
},
],
"slug": "typescript-quality",
"title": "Typescript",
},
],
"packageName": "@code-pushup/core",
"plugins": [
{
"audits": [
{
"description": "Errors that occur during parsing and lexing of TypeScript source code",
"slug": "syntax-errors",
"title": "Syntax-Errors",
},
{
"description": "Errors that occur during type checking and type inference",
"slug": "semantic-errors",
"title": "Semantic-Errors",
},
{
"description": "Errors that occur during TypeScript language service operations",
"slug": "language-service-errors",
"title": "Language-Service-Errors",
},
{
"description": "Errors that occur during TypeScript internal operations",
"slug": "internal-errors",
"title": "Internal-Errors",
},
{
"description": "Errors that occur when parsing TypeScript configuration files",
"slug": "configuration-errors",
"title": "Configuration-Errors",
},
{
"description": "Errors that do not match any known TypeScript error code",
"slug": "unknown-codes",
"title": "Unknown-Codes",
},
],
"description": "Official Code PushUp Typescript plugin.",
"docsUrl": "https://www.npmjs.com/package/@code-pushup/typescript-plugin/",
"groups": [
{
"description": "Syntax, semantic, and internal compiler errors are critical for identifying and preventing bugs.",
"refs": [
{
"slug": "syntax-errors",
"weight": 1,
},
{
"slug": "semantic-errors",
"weight": 1,
},
{
"slug": "internal-errors",
"weight": 1,
},
],
"slug": "problems-group",
"title": "Problems",
},
{
"description": "TypeScript configuration and options errors ensure correct project setup, reducing risks from misconfiguration.",
"refs": [
{
"slug": "configuration-errors",
"weight": 1,
},
],
"slug": "ts-configuration-group",
"title": "Configuration",
},
{
"description": "Errors that do not bring any specific value to the developer, but are still useful to know.",
"refs": [
{
"slug": "unknown-codes",
"weight": 1,
},
{
"slug": "language-service-errors",
"weight": 1,
},
],
"slug": "miscellaneous-group",
"title": "Miscellaneous",
},
],
"icon": "typescript",
"packageName": "@code-pushup/typescript-plugin",
"slug": "typescript",
"title": "Typescript",
},
],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Code PushUp CLI
[ info ] Run collect...
Code PushUp Report - @code-pushup/[email protected]


Typescript audits

โ— Semantic-Errors 2
โ— Configuration-Errors 1
โ— Language-Service-Errors 1
โ— Syntax-Errors 1
โ— Internal-Errors 0
โ— Unknown-Codes 0

Categories

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Category โ”‚ Score โ”‚ Audits โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Typescript โ”‚ 28 โ”‚ 6 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Made with โค by code-pushup.dev

[ success ] Generated reports successfully:
[ success ] Collecting report successful!
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ โ”‚
โ”‚ ๐Ÿ’ก Visualize your reports โ”‚
โ”‚ โ”‚
โ”‚ โฏ npx code-pushup upload - Run upload to upload the created report to the server โ”‚
โ”‚ https://github.com/code-pushup/cli/tree/main/packages/cli#upload-command โ”‚
โ”‚ โฏ npx code-pushup autorun - Run collect & upload โ”‚
โ”‚ https://github.com/code-pushup/cli/tree/main/packages/cli#autorun-command โ”‚
โ”‚ โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
Loading
Loading