diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f32a8ab..0000000 --- a/.eslintrc +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parser": "babel-eslint", - "env": { - "browser": true, - "es6": true, - "mocha": true, - "node": true, - "jest/globals": true - }, - "extends": [ - "eslint:recommended", - "prettier", - "plugin:prettier/recommended", - "plugin:import/errors", - "plugin:import/warnings" - ], - "plugins": ["prettier", "jest"], - "rules": { - "prettier/prettier": ["error"], - "import/no-extraneous-dependencies": "off", - "no-console": [ - "error", - { - "allow": ["warn", "error"] - } - ], - "no-unused-vars": [ - "error", - { - "ignoreRestSiblings": true - } - ] - } -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4e84da..1d2561c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,8 @@ jobs: - uses: bahmutov/npm-install@v1 with: install-command: yarn --immutable + - name: Code quality + run: make lint format - name: Unit Tests run: make test env: diff --git a/Makefile b/Makefile index e0875d8..15aa1f1 100644 --- a/Makefile +++ b/Makefile @@ -13,18 +13,22 @@ watch: ## continuously compile ES6 files to JS @yarn vite build --watch test: ## Launch unit tests - @NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest + @yarn run test watch-test: ## Launch unit tests and watch for changes - @NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest --watch + @yarn run watch-test + +check: ## Lint and format the source code + @yarn run check + +lint: ## Lint the source code + @yarn run lint format: ## Format the source code - @./node_modules/.bin/eslint --fix ./src + @yarn run format run: ## Launch server with example data - @node ./bin/json-graphql-server.cjs example/data.js + @yarn run server build: ## Build production release - @yarn vite build - @yarn vite build -c ./vite.config.node.js - @yarn vite build -c ./vite.config.umd.js + @yarn run build diff --git a/README.md b/README.md index 2bf1fff..55e3feb 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Note that the server is [GraphiQL](https://github.com/graphql/graphiql) enabled, ## Install ```sh -npm install json-graphql-server +npm install -D json-graphql-server ``` ## Generated Types and Queries @@ -460,7 +460,7 @@ const data = { // ... your data }; -app.use('/graphql', jsonGraphqlExpress.default(data)); +app.use('/graphql', jsonGraphqlExpress(data)); app.listen(PORT); ``` diff --git a/bin/json-graphql-server.cjs b/bin/json-graphql-server.cjs index 86db521..2938661 100755 --- a/bin/json-graphql-server.cjs +++ b/bin/json-graphql-server.cjs @@ -1,9 +1,8 @@ #!/usr/bin/env node -require('reify'); var path = require('path'); var express = require('express'); var cors = require('cors'); -var JsonGraphqlServer = require('../dist/json-graphql-server-node.cjs').default; +var { jsonGraphqlExpress } = require('../dist/json-graphql-server-node.cjs'); var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json'; var data = require(path.resolve(process.cwd(), dataFilePath)); var PORT = process.env.NODE_PORT || 3000; @@ -22,7 +21,7 @@ process.argv.forEach((arg, index) => { }); app.use(cors()); -app.use('/', JsonGraphqlServer(data)); +app.use('/', jsonGraphqlExpress(data)); app.listen(PORT, HOST); var msg = `GraphQL server running with your data at http://${HOST}:${PORT}/`; console.log(msg); // eslint-disable-line no-console diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..9a45182 --- /dev/null +++ b/biome.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.7.0/schema.json", + "organizeImports": { + "enabled": true + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 4, + "ignore": ["public/*.js"] + }, + "javascript": { + "formatter": { + "quoteStyle": "single" + } + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "off" + } + }, + "ignore": ["public/*.js"] + } +} diff --git a/example/index.html b/example/browser/index.html similarity index 96% rename from example/index.html rename to example/browser/index.html index b54e7b3..7f5e9f5 100644 --- a/example/index.html +++ b/example/browser/index.html @@ -5,7 +5,7 @@
- + -