Skip to content

Commit

Permalink
chore: firebase eslint, prettier 재설정 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakyeonko3 committed Aug 25, 2024
1 parent 27c6093 commit 55bde55
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 80 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,7 @@ stats.html
*.sw?


.firebase
.firebase

premissions.json
serviceAccountKey.json
54 changes: 35 additions & 19 deletions functions/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,48 @@ module.exports = {
es6: true,
node: true,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: 'functions/tsconfig.json',
},
},
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:prettier/recommended',
'google',
'plugin:@typescript-eslint/recommended',
],
parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',
parserOptions: {
project: ["./tsconfig.json", "./tsconfig.dev.json"],
sourceType: "module",
project: ['./tsconfig.json', './tsconfig.dev.json'],
sourceType: 'module',
tsconfigRootDir: __dirname,
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
"/generated/**/*", // Ignore generated files.
".eslintrc.cjs",
],
plugins: [
"@typescript-eslint",
"import",
'/lib/**/*', // Ignore built files.
'/generated/**/*', // Ignore generated files.
'.eslintrc.cjs',
],
plugins: ['@typescript-eslint', 'import', 'prettier'],
rules: {
"quotes": ["error", "double"],
"import/no-unresolved": 0,
"indent": ["error", 2],
'import/no-unresolved': 0,
'object-curly-spacing': ['error', 'always'],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
};
18 changes: 18 additions & 0 deletions functions/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"printWidth": 100,
"trailingComma": "all",
"useTabs": false,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "always",
"quoteProps": "as-needed",
"endOfLine": "lf",
"jsxSingleQuote": false,
"jsxBracketSameLine": false,
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css"
}
Binary file added functions/bun.lockb
Binary file not shown.
121 changes: 117 additions & 4 deletions functions/package-lock.json

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

5 changes: 4 additions & 1 deletion functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"logs": "firebase functions:log"
},
"engines": {
"node": "22.3.0"
"node": "22"
},
"main": "lib/index.js",
"dependencies": {
Expand All @@ -25,6 +25,9 @@
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.25.4",
"firebase-functions-test": "^3.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.3.3",
"typescript": "^4.9.0"
},
"private": true
Expand Down
37 changes: 21 additions & 16 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/**
* Import function triggers from their respective submodules:
*
* import {onCall} from "firebase-functions/v2/https";
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
*
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/
// import * as logger from "firebase-functions/logger";
import * as cors from 'cors';
import * as express from 'express';
import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';

// import { onRequest } from 'firebase-functions/v2/https';
// import * as logger from 'firebase-functions/logger';
import * as serviceAccount from '../lib/serviceAccountKey.json';

// Start writing functions
// https://firebase.google.com/docs/functions/typescript
// Firebase Admin SDK init
admin.initializeApp({
credential: admin.credential.cert(serviceAccount as admin.ServiceAccount),
});

// export const helloWorld = onRequest((request, response) => {
// logger.info("Hello logs!", {structuredData: true});
// response.send("Hello from Firebase!");
// });
// const db = admin.firestore();
const app = express();

app.use(express.json());
app.use(cors({ origin: true }));

app.get('/', (req, res) => {
return res.status(200).send('Hello World!');
});

export const api = functions.https.onRequest(app);
5 changes: 1 addition & 4 deletions functions/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"include": [
".eslintrc.js",
"src"
]
"include": [".eslintrc.js"]
}
12 changes: 8 additions & 4 deletions functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"baseUrl": "./",
"paths": {
"@/server*": ["./src/*"]
},
"resolveJsonModule": true,
"module": "CommonJS",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
Expand All @@ -9,7 +14,6 @@
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
"include": ["src"],
"baseUrl": "."
}
Loading

0 comments on commit 55bde55

Please sign in to comment.