Skip to content

Commit

Permalink
ESLint設定
Browse files Browse the repository at this point in the history
  • Loading branch information
keinuma committed Jan 1, 2020
1 parent 5fa2fff commit cdad50a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
29 changes: 29 additions & 0 deletions functions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",

"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"env": { "node": true, "es6": true },
"parserOptions": {
"sourceType": "module"
},
"rules": {
// 適当なルール
"quotes": ["error", "double", { "avoidEscape": true }],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/array-type": [
"error",
{
"default": "array-simple"
}
]
}
}
8 changes: 8 additions & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .ts,.vue --ignore-path .gitignore .",
"lint:fix": "eslint --fix --ext .ts --ignore-path .gitignore .",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
Expand All @@ -21,7 +23,13 @@
"devDependencies": {
"@types/graphql": "^14.5.0",
"@types/node": "^13.1.2",
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-prettier": "^3.1.2",
"firebase-functions-test": "^0.1.7",
"prettier": "^1.19.1",
"typescript": "^3.7.4"
},
"private": true
Expand Down
26 changes: 13 additions & 13 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApolloServer, gql } from "apollo-server-cloud-functions";
import * as functions from 'firebase-functions';
import * as functions from "firebase-functions";

const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.
Expand All @@ -15,22 +15,22 @@ const typeDefs = gql`
`;

const books = [
{
title: 'Harry Potter and the Chamber of Secrets',
author: 'J.K. Rowling',
},
{
title: 'Jurassic Park',
author: 'Michael Crichton',
},
{
title: "Harry Potter and the Chamber of Secrets",
author: "J.K. Rowling"
},
{
title: "Jurassic Park",
author: "Michael Crichton"
}
];

const resolvers = {
Query: {
books: () => books,
},
Query: {
books: () => books
}
};

const server = new ApolloServer({ typeDefs, resolvers });

exports.handler = functions.https.onRequest(server.createHandler());
exports.graphql = functions.https.onRequest(server.createHandler());

0 comments on commit cdad50a

Please sign in to comment.