Skip to content

Commit

Permalink
feat: run linting before build and deploy
Browse files Browse the repository at this point in the history
Closes #9
  • Loading branch information
mainawycliffe committed Dec 26, 2022
1 parent cb0b7c0 commit 706b9b7
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 16 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"dependencies": {
"@nrwl/nx-plugin": "^15.4.1",
"@swc/helpers": "~0.4.11",
"firebase-admin": "^11.4.1",
"firebase-functions": "^4.1.1",
"tslib": "^2.3.0"
},
"devDependencies": {
Expand All @@ -26,6 +28,7 @@
"@typescript-eslint/parser": "^5.36.1",
"eslint": "~8.15.0",
"eslint-config-prettier": "8.1.0",
"firebase-functions-test": "^3.0.0",
"jest": "28.1.1",
"jest-environment-jsdom": "28.1.1",
"jsonc-eslint-parser": "^2.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ export default function addProjectConfigs(
projectType: 'library',
sourceRoot: `${normalizedOptions.projectRoot}/src`,
targets: {
build: {
executor: '@nrwl/js:tsc',
options: {
outputPath: `dist/${normalizedOptions.projectRoot}`,
tsConfig: `${normalizedOptions.projectRoot}/tsconfig.json`,
main: `${normalizedOptions.projectDirectory}/src/index.ts`,
},
},
serve: {
executor: '@nx-toolkits/firebase:serve',
},
lint: {
executor: '@nrwl/linter:eslint',
outputs: ['{options.outputFile}'],
Expand All @@ -29,9 +18,22 @@ export default function addProjectConfigs(
fix: true,
},
},
// todo: will circle back to this later
// serve: {
// executor: '@nx-toolkits/firebase:serve',
// },
build: {
executor: '@nrwl/js:tsc',
dependsOn: ['lint'],
options: {
outputPath: `dist/${normalizedOptions.projectRoot}`,
tsConfig: `${normalizedOptions.projectRoot}/tsconfig.json`,
main: `${normalizedOptions.projectDirectory}/src/index.ts`,
},
},
deploy: {
executor: '@nx-toolkits/firebase:deploy',
dependsOn: ['build', 'lint'],
dependsOn: ['build'],
},
},
tags: normalizedOptions.parsedTags,
Expand Down
22 changes: 22 additions & 0 deletions packages/functions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"root": true,
"env": {
"es6": true,
"node": true
},
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {}
},
{
"files": ["./package.json", "./generators.json", "./executors.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nrwl/nx/nx-plugin-checks": "error"
}
}
]
}
9 changes: 9 additions & 0 deletions packages/functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiled JavaScript files
lib/**/*.js
lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/
5 changes: 5 additions & 0 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "functions",
"version": "0.0.0",
"main": "src/index.js"
}
30 changes: 30 additions & 0 deletions packages/functions/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "functions",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "packages/functions/src",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/functions/**/*.ts"],
"fix": true
}
},
"build": {
"executor": "@nrwl/js:tsc",
"dependsOn": ["lint"],
"options": {
"outputPath": "dist/packages/functions",
"tsConfig": "packages/functions/tsconfig.json",
"main": "functions/src/index.ts"
}
},
"deploy": {
"executor": "@nx-toolkits/firebase:deploy",
"dependsOn": ["build"]
}
},
"tags": []
}
9 changes: 9 additions & 0 deletions packages/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as functions from 'firebase-functions';

// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript

export const helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info('Hello logs!', { structuredData: true });
response.send('Hello from Firebase - Generated by @nx-toolkits/firebase!');
});
3 changes: 3 additions & 0 deletions packages/functions/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": []
}
13 changes: 13 additions & 0 deletions packages/functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": ["src"]
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 706b9b7

Please sign in to comment.