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(plugin-typescript): setup plugin project base #917

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions packages/plugin-typescript/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import tseslint from 'typescript-eslint';
import baseConfig from '../../eslint.config.js';

export default tseslint.config(
...baseConfig,
{
files: ['**/*.ts', '!**/mocks'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other projects don't have mocks directory excluded this way. Is it needed? The **/mocks/fixtures pattern is globally ignored, BTW.

languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': 'error',
},
},
);
27 changes: 27 additions & 0 deletions packages/plugin-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@code-pushup/typescript-plugin",
"version": "0.57.0",
"license": "MIT",
"description": "Code PushUp plugin to incrementally adopting strict compilation flags in TypeScript projects",
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
"homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-typescript#readme",
"bugs": {
"url": "https://github.com/code-pushup/cli/issues?q=is%3Aissue%20state%3Aopen%20type%3ABug%20label%3A\"🧩%20typescript-plugin\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/code-pushup/cli.git",
"directory": "packages/plugin-typescript"
},
"keywords": [
"CLI",
"Code PushUp",
"plugin",
"typescript"
],
"publishConfig": {
"access": "public"
},
"type": "module",
"dependencies": {},
"scripts": {}
}
41 changes: 41 additions & 0 deletions packages/plugin-typescript/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "plugin-typescript",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/plugin-typescript/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/plugin-typescript",
"main": "packages/plugin-typescript/src/index.ts",
"tsConfig": "packages/plugin-typescript/tsconfig.lib.json",
"assets": ["packages/plugin-typescript/*.md"]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"packages/plugin-typescript/**/*.ts",
"packages/plugin-typescript/package.json"
]
}
},
"unit-test": {
"executor": "@nx/vite:test",
"options": {
"configFile": "packages/plugin-typescript/vite.config.unit.ts"
}
},
"integration-test": {
"executor": "@nx/vite:test",
"options": {
"configFile": "packages/plugin-typescript/vite.config.integration.ts"
}
}
},
"tags": ["scope:plugin", "type:feature", "publishable"]
}
1 change: 1 addition & 0 deletions packages/plugin-typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { TYPESCRIPT_PLUGIN_SLUG } from './lib/constants.js';

Check failure on line 1 in packages/plugin-typescript/src/index.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Branch coverage

1st branch is not taken in any test case.

Check warning on line 1 in packages/plugin-typescript/src/index.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Line coverage

Line 1 is not covered in any test case.
1 change: 1 addition & 0 deletions packages/plugin-typescript/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TYPESCRIPT_PLUGIN_SLUG = 'typescript';

Check failure on line 1 in packages/plugin-typescript/src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Branch coverage

1st branch is not taken in any test case.

Check warning on line 1 in packages/plugin-typescript/src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Code PushUp

<✓> Code coverage | Line coverage

Line 1 is not covered in any test case.
23 changes: 23 additions & 0 deletions packages/plugin-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"types": ["vitest"]
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.test.json"
}
]
}
16 changes: 16 additions & 0 deletions packages/plugin-typescript/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": [
"vite.config.unit.ts",
"vite.config.integration.ts",
"src/**/*.test.ts",
"src/**/*.mock.ts",
"mocks/**/*.ts"
]
}
17 changes: 17 additions & 0 deletions packages/plugin-typescript/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"]
},
"include": [
"vite.config.unit.ts",
"vite.config.integration.ts",
"mocks/**/*.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"src/**/*.test.js",
"src/**/*.test.jsx",
"src/**/*.d.ts"
]
}
30 changes: 30 additions & 0 deletions packages/plugin-typescript/vite.config.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';

export default defineConfig({
cacheDir: '../../node_modules/.vite/plugin-typescript',
test: {
reporters: ['basic'],
globals: true,
cache: {
dir: '../../node_modules/.vitest/plugin-typescript',
},
alias: tsconfigPathAliases(),
pool: 'threads',
poolOptions: { threads: { singleThread: true } },
coverage: {
reporter: ['text', 'lcov'],
reportsDirectory: '../../coverage/plugin-typescript/integration-tests',
exclude: ['mocks/**', '**/types.ts'],
},
environment: 'node',
include: ['src/**/*.integration.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globalSetup: ['../../global-setup.ts'],
setupFiles: [
'../../testing/test-setup/src/lib/cliui.mock.ts',
'../../testing/test-setup/src/lib/reset.mocks.ts',
'../../testing/test-setup/src/lib/chrome-path.setup.ts',
],
},
});
31 changes: 31 additions & 0 deletions packages/plugin-typescript/vite.config.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js';

export default defineConfig({
cacheDir: '../../node_modules/.vite/plugin-typescript',
test: {
reporters: ['basic'],
globals: true,
cache: {
dir: '../../node_modules/.vitest/plugin-typescript',
},
alias: tsconfigPathAliases(),
pool: 'threads',
poolOptions: { threads: { singleThread: true } },
coverage: {
reporter: ['text', 'lcov'],
reportsDirectory: '../../coverage/plugin-typescript/unit-tests',
exclude: ['mocks/**', '**/types.ts'],
},
environment: 'node',
include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
globalSetup: ['../../global-setup.ts'],
setupFiles: [
'../../testing/test-setup/src/lib/cliui.mock.ts',
'../../testing/test-setup/src/lib/fs.mock.ts',
'../../testing/test-setup/src/lib/console.mock.ts',
'../../testing/test-setup/src/lib/reset.mocks.ts',
],
},
});
3 changes: 3 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"@code-pushup/test-nx-utils": ["testing/test-nx-utils/src/index.ts"],
"@code-pushup/test-setup": ["testing/test-setup/src/index.ts"],
"@code-pushup/test-utils": ["testing/test-utils/src/index.ts"],
"@code-pushup/typescript-plugin": [
"packages/plugin-typescript/src/index.ts"
],
"@code-pushup/utils": ["packages/utils/src/index.ts"]
}
},
Expand Down
Loading