diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e1c0a5c..f1ed5ad 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,18 +1,20 @@ +/*eslint unicorn/prefer-module: 0 */ + 'use strict' module.exports = { env: { es2021: true, - node: true + node: true, }, - parser: "@babel/eslint-parser", + parser: '@babel/eslint-parser', parserOptions: { ecmaVersion: 12, - sourceType: 'module' + sourceType: 'module', }, extends: [ 'xo', - 'plugin:unicorn/recommended' + 'plugin:unicorn/recommended', ], rules: { indent: ['error', 'tab'], @@ -23,24 +25,30 @@ module.exports = { 'error', { before: false, - after: true - } + after: true, + }, ], 'no-console': 0, + 'no-debugger': 0, + 'no-unused-expressions': [ + 'error', + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], camelcase: 0, 'capitalized-comments': 0, 'spaced-comment': 0, 'padding-line-between-statements': 0, + 'no-undef-init': 0, 'unicorn/filename-case': 0, 'unicorn/prevent-abbreviations': 0, - // 'unicorn/prefer-module': 0, + 'unicorn/no-reduce': 0, + 'unicorn/no-array-reduce': 0, // 'unicorn/no-abusive-eslint-disable': 0, - // Bug do svelte lint - 'no-multiple-empty-lines': [ - 'error', - {max: 2, maxBOF: 2, maxEOF: 0} - ], // Bug no ctx.body Koa - 'require-atomic-updates': 0 - } + 'require-atomic-updates': 0, + }, } diff --git a/README.md b/README.md index dbb77d8..97ee872 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Existem algumas dependĂȘncias. yarn dlx degit lagden/boilerplate-rest#master projeto cd projeto yarn dlx degit lagden/boilerplate-bin/files#main bin +yarn dlx degit lagden/boilerplate-eslint/files/backend#main ./ --force yarn dlx degit lagden/boilerplate-envs/files#main ./ --force yarn dlx degit lagden/boilerplate-docker-nodejs/files#main ./ --force ``` diff --git a/package.json b/package.json index 4de6110..01f6a30 100644 --- a/package.json +++ b/package.json @@ -33,15 +33,15 @@ "local-access": "1.1.0" }, "devDependencies": { - "@babel/core": "7.14.3", - "@babel/eslint-parser": "7.14.3", - "@babel/plugin-syntax-top-level-await": "7.12.13", + "@babel/core": "7.14.6", + "@babel/eslint-parser": "7.14.7", + "@babel/plugin-syntax-top-level-await": "7.14.5", "@tadashi/hex-id": "2.0.0", "ava": "3.15.0", - "c8": "7.7.2", - "eslint": "7.27.0", - "eslint-config-xo": "0.36.0", - "eslint-plugin-unicorn": "32.0.1", + "c8": "7.7.3", + "eslint": "7.29.0", + "eslint-config-xo": "0.37.0", + "eslint-plugin-unicorn": "33.0.1", "got": "11.8.2", "hash-to-port": "1.2.0", "npm-run-all": "4.1.5" diff --git a/server/app.js b/server/app.js index 1c9ab33..c451d57 100644 --- a/server/app.js +++ b/server/app.js @@ -5,8 +5,8 @@ import * as debug from './lib/debug.js' const app = base({ error: true, cors: { - credentials: true - } + credentials: true, + }, }) app diff --git a/server/index.js b/server/index.js index 8ca52b4..8dd3577 100644 --- a/server/index.js +++ b/server/index.js @@ -6,14 +6,14 @@ const { PORT = 5000, PORT_PUBLISHED = 5000, HOSTNAME = '0.0.0.0', - VERSION = 'dev' + VERSION = 'dev', } = process.env const HOSTNAME_CUSTOM = process.env?.HOSTNAME_CUSTOM ?? HOSTNAME const { local, - network + network, } = la({port: PORT_PUBLISHED, hostname: HOSTNAME_CUSTOM}) app.listen(PORT, () => { diff --git a/server/lib/debug.js b/server/lib/debug.js index 874c0bf..ca7bdb8 100644 --- a/server/lib/debug.js +++ b/server/lib/debug.js @@ -15,5 +15,5 @@ error.color = debug.colors[colors[2]] export { error, info, - log + log, } diff --git a/server/routes/_hello.js b/server/routes/_hello.js index 7d6e4f9..a5a13dd 100644 --- a/server/routes/_hello.js +++ b/server/routes/_hello.js @@ -7,7 +7,7 @@ const router = new Router() // GET function hello(ctx) { const { - name = 'World' + name = 'World', } = ctx.params // Debug de exemplo @@ -15,15 +15,15 @@ function hello(ctx) { ctx.body = { data: { - hello: `Hello ${name}` - } + hello: `Hello ${name}`, + }, } } // POST function echo(ctx) { const { - body + body, } = ctx.request // echo do post diff --git a/server/routes/index.js b/server/routes/index.js index cd7c476..54a058c 100644 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -18,7 +18,7 @@ for (const file of files) { for await (const {default: mod} of imports) { middleware.push( mod.routes(), - mod.allowedMethods({throw: true}) + mod.allowedMethods({throw: true}), ) } diff --git a/test/index.js b/test/index.js index ce2b0cd..0c6cbf5 100644 --- a/test/index.js +++ b/test/index.js @@ -9,7 +9,7 @@ test.before(async t => { test('hello', async t => { const response = await got.get(`${t.context.baseUrl}/`, { throwHttpErrors: false, - responseType: 'json' + responseType: 'json', }) t.is(response.statusCode, 200) @@ -19,7 +19,7 @@ test('hello', async t => { test('hello boilerplate', async t => { const response = await got.get(`${t.context.baseUrl}/boilerplate`, { throwHttpErrors: false, - responseType: 'json' + responseType: 'json', }) t.is(response.statusCode, 200) @@ -30,7 +30,7 @@ test('echo json', async t => { const response = await got.post(`${t.context.baseUrl}/echo`, { throwHttpErrors: false, responseType: 'json', - json: {xxx: true} + json: {xxx: true}, }) t.is(response.statusCode, 200)