Skip to content

Commit

Permalink
fix: quality generator fixes and cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonC committed Sep 28, 2023
1 parent f409914 commit 5c3b461
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions packages/nx/src/generators/quality/files/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['@tablecheck/eslint-config'],
parserOptions: {
project: './tsconfig.json',
},
rules: {},
};
5 changes: 0 additions & 5 deletions packages/nx/src/generators/quality/files/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 9 additions & 2 deletions packages/nx/src/generators/quality/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
},
};
Expand Down Expand Up @@ -77,6 +81,7 @@ export async function qualityGenerator(
'husky',
'commitlint',
'eslint',
'@tablecheck/frontend-audit',
'@tablecheck/commitlint-config',
'@tablecheck/eslint-config',
'@tablecheck/prettier-config',
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion packages/nx/src/generators/ts-file-types/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions packages/nx/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.base.json",
"include": [
"src/**/*.ts",
"src/**/*.cts",
"src/**/*.tsx",
"src/*.ts",
"src/*.tsx",
Expand Down

0 comments on commit 5c3b461

Please sign in to comment.