diff --git a/.gitignore b/.gitignore index 50505302..64046a71 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,6 @@ junit .env.test.local .env.production.local .@tablecheck -/Users/simeon.cheeseman/Development/tablecheck-react-system/.@tablecheck tsconfig.compound.json /packages/quality/build.config.ts /packages/utils/build.config.ts diff --git a/packages/nx/src/generators/quality/files/.eslintrc.cjs b/packages/nx/src/generators/quality/files/.eslintrc.cjs new file mode 100644 index 00000000..3ac5c87c --- /dev/null +++ b/packages/nx/src/generators/quality/files/.eslintrc.cjs @@ -0,0 +1,7 @@ +module.exports = { + extends: ['@tablecheck/eslint-config'], + parserOptions: { + project: './tsconfig.json', + }, + rules: {}, +}; diff --git a/packages/nx/src/generators/quality/files/.husky/pre-commit b/packages/nx/src/generators/quality/files/.husky/pre-commit index 4a29adc0..aff44b8d 100644 --- a/packages/nx/src/generators/quality/files/.husky/pre-commit +++ b/packages/nx/src/generators/quality/files/.husky/pre-commit @@ -1,11 +1,6 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -# revert this back to using nx format:check when https://github.com/nrwl/nx/issues/17990 is fixed -# echo "Running nx format:check - any files output below are formatted incorrectly" -# echo "To fix formatting, run: \`npx nx format:write\` or configure prettier in your IDE" -# npx nx format:check - echo "Running 'prettier --check .' - any files output below are formatted incorrectly" echo "To fix formatting, run: \`npx prettier --write .\` or configure prettier in your IDE" npx prettier -v diff --git a/packages/nx/src/generators/quality/files/commitlint.config.ts b/packages/nx/src/generators/quality/files/commitlint.config.cts similarity index 100% rename from packages/nx/src/generators/quality/files/commitlint.config.ts rename to packages/nx/src/generators/quality/files/commitlint.config.cts diff --git a/packages/nx/src/generators/quality/generator.ts b/packages/nx/src/generators/quality/generator.ts index 9078fca4..634a243b 100644 --- a/packages/nx/src/generators/quality/generator.ts +++ b/packages/nx/src/generators/quality/generator.ts @@ -22,13 +22,17 @@ import { FileTypesGeneratorSchema } from '../ts-file-types/schema'; import generateConfig from '../ts-node-config/generator'; function updateProjectConfig(tree: Tree, projectName: string) { - const { projectSourceRoot } = getNxProjectRoot(tree, projectName); + const { projectSourceRoot, projectRoot } = getNxProjectRoot( + tree, + projectName, + ); const lintTarget = { executor: '@tablecheck/nx:quality', outputs: ['{options.outputFile}'], options: { lintFilePatterns: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'].map( - (pattern) => path.join(projectSourceRoot, pattern), + (pattern) => + path.relative(projectRoot, path.join(projectSourceRoot, pattern)), ), }, }; @@ -77,6 +81,7 @@ export async function qualityGenerator( 'husky', 'commitlint', 'eslint', + '@tablecheck/frontend-audit', '@tablecheck/commitlint-config', '@tablecheck/eslint-config', '@tablecheck/prettier-config', @@ -89,6 +94,8 @@ export async function qualityGenerator( json.scripts.lint = 'nx affected --target=quality && prettier -c .'; json.scripts.format = 'nx affected --target=quality:format && prettier -w --loglevel warn .'; + json.scripts.prepare = 'husky install'; + json.type = 'module'; return json; }); updateProjectConfig(tree, schema.project); diff --git a/packages/nx/src/generators/ts-file-types/generator.ts b/packages/nx/src/generators/ts-file-types/generator.ts index 2f7cbbca..d6d6641b 100644 --- a/packages/nx/src/generators/ts-file-types/generator.ts +++ b/packages/nx/src/generators/ts-file-types/generator.ts @@ -9,10 +9,11 @@ export async function tsFileTypesGenerator( tree: Tree, schema: FileTypesGeneratorSchema, ) { + const { projectSourceRoot } = getNxProjectRoot(tree, schema.project); generateFiles( tree, path.join(__dirname, 'files', schema.svgAsComponent ? 'srcWithSvg' : 'src'), - getNxProjectRoot(tree, schema.project).projectSourceRoot, + path.relative(process.cwd(), projectSourceRoot), {}, ); await formatFiles(tree); diff --git a/packages/nx/tsconfig.json b/packages/nx/tsconfig.json index 547e3c7f..09a11c71 100644 --- a/packages/nx/tsconfig.json +++ b/packages/nx/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "include": [ "src/**/*.ts", + "src/**/*.cts", "src/**/*.tsx", "src/*.ts", "src/*.tsx",