Skip to content

Commit

Permalink
update packs and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
lagden committed Jun 24, 2021
1 parent 14aea96 commit 312ca6c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 34 deletions.
36 changes: 22 additions & 14 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -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'],
Expand All @@ -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,
},
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import * as debug from './lib/debug.js'
const app = base({
error: true,
cors: {
credentials: true
}
credentials: true,
},
})

app
Expand Down
4 changes: 2 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand Down
2 changes: 1 addition & 1 deletion server/lib/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ error.color = debug.colors[colors[2]]
export {
error,
info,
log
log,
}
8 changes: 4 additions & 4 deletions server/routes/_hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ const router = new Router()
// GET
function hello(ctx) {
const {
name = 'World'
name = 'World',
} = ctx.params

// Debug de exemplo
debug.log('hello | name', name)

ctx.body = {
data: {
hello: `Hello ${name}`
}
hello: `Hello ${name}`,
},
}
}

// POST
function echo(ctx) {
const {
body
body,
} = ctx.request

// echo do post
Expand Down
2 changes: 1 addition & 1 deletion server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
)
}

Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 312ca6c

Please sign in to comment.