-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: eslint needs extra configs to resolve paths correctly
Merged the release CI fixes from another branch here as that one is failing for unknow reasons Fix over-agressive shortest imports
- Loading branch information
Showing
11 changed files
with
135 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ jobs: | |
run: | | ||
git branch --track main origin/main | ||
npm ci --prefer-offline --silent | ||
npm run build | ||
npm run build:ci | ||
- name: Deploy 🚀 | ||
uses: JamesIves/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,6 @@ jobs: | |
|
||
- uses: ./.github/setup | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Run Tests | ||
run: npm test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as path from 'path'; | ||
|
||
import { Tree } from '@nx/devkit'; | ||
import { getNxProjectRoot, outputPrettyFile } from '@tablecheck/frontend-utils'; | ||
import * as fs from 'fs-extra'; | ||
|
||
function getConfigs(projectRoot: string) { | ||
const mapToPath = (filename: string) => path.join(projectRoot, filename); | ||
const nxAppConfigs = ['tsconfig.app.json', 'tsconfig.spec.json'].map( | ||
mapToPath, | ||
); | ||
const defaultConfigs = ['tsconfig.base.json', 'tsconfig.json'].map(mapToPath); | ||
if (nxAppConfigs.every((config) => fs.existsSync(config))) { | ||
return nxAppConfigs; | ||
} | ||
return defaultConfigs.filter((config) => fs.existsSync(config)); | ||
} | ||
|
||
export function generateEslintConfig(tree: Tree, projectName: string) { | ||
const { projectRoot } = getNxProjectRoot(tree, projectName); | ||
const projectTsConfigs = | ||
getConfigs(projectRoot) | ||
.map((tsConfig) => path.relative(tree.root, tsConfig)) | ||
.join(',') || | ||
'/* could not detect tsconfig.json files, manually set them here */'; | ||
const fileContent = ` | ||
module.exports = { | ||
extends: ['@tablecheck/eslint-config'], | ||
parserOptions: { | ||
project: [${projectTsConfigs}], | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
typescript: { | ||
project: [${projectTsConfigs}], | ||
}, | ||
}, | ||
}, | ||
rules: {}, | ||
}; | ||
`; | ||
outputPrettyFile(path.join(projectRoot, '.eslintrc.cjs'), fileContent); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as path from 'path'; | ||
|
||
import { | ||
Tree, | ||
addProjectConfiguration, | ||
readProjectConfiguration, | ||
updateProjectConfiguration, | ||
} from '@nx/devkit'; | ||
import { getNxProjectRoot } from '@tablecheck/frontend-utils'; | ||
import merge from 'lodash/merge'; | ||
|
||
export function updateProjectConfig(tree: Tree, projectName: string) { | ||
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( | ||
'{projectRoot}', | ||
path.relative(projectRoot, path.join(projectSourceRoot, pattern)), | ||
), | ||
), | ||
}, | ||
}; | ||
const lintFormatTarget = merge({}, lintTarget, { | ||
options: { | ||
fix: true, | ||
}, | ||
}); | ||
try { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
updateProjectConfiguration( | ||
tree, | ||
projectName, | ||
merge(projectConfig, { | ||
targets: { | ||
quality: lintTarget, | ||
'quality:format': lintFormatTarget, | ||
}, | ||
}), | ||
); | ||
} catch (e) { | ||
console.error( | ||
'Failed to detect existing project config, generating new project.json to run executors', | ||
e, | ||
); | ||
addProjectConfiguration(tree, projectName, { | ||
root: '.', | ||
sourceRoot: 'src', | ||
targets: { | ||
quality: lintTarget, | ||
'quality:format': lintFormatTarget, | ||
}, | ||
}); | ||
} | ||
} |