Skip to content

Commit 9878bb3

Browse files
committed
chore: investigate migrating to biome
1 parent 6fda49a commit 9878bb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2087
-1860
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ scratch/
99
test/mock/*/src/*/*/vendor/
1010
test/mock/tmp/
1111
yarn.lock
12+
.kiro

biome.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"ignore": [
11+
".nyc_output/",
12+
"arc-proxy-*",
13+
"coverage/",
14+
"dist.js",
15+
"scratch/",
16+
"src/http/get-index",
17+
"types/",
18+
"node_modules/",
19+
"test/mock/*/src/*/*/vendor/",
20+
"test/mock/tmp/"
21+
]
22+
},
23+
"formatter": {
24+
"enabled": true,
25+
"indentStyle": "space",
26+
"indentWidth": 2,
27+
"lineWidth": 120
28+
},
29+
"linter": {
30+
"enabled": true,
31+
"rules": {
32+
"recommended": true,
33+
"style": {
34+
"noVar": "error",
35+
"useConst": "error",
36+
"noParameterAssign": "off",
37+
"useDefaultParameterLast": "off"
38+
},
39+
"complexity": {
40+
"noForEach": "off"
41+
},
42+
"performance": {
43+
"noDelete": "off"
44+
},
45+
"suspicious": {
46+
"noExplicitAny": "off"
47+
}
48+
}
49+
},
50+
"javascript": {
51+
"formatter": {
52+
"semicolons": "asNeeded",
53+
"quoteStyle": "single"
54+
}
55+
}
56+
}

eslint.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ const arc = require('@architect/eslint-config')
33
module.exports = [
44
...arc,
55
{
6-
ignores: [
7-
'.nyc_output/',
8-
'arc-proxy-*',
9-
'coverage/',
10-
'dist.js',
11-
'scratch/',
12-
'src/http/get-index',
13-
'types/',
14-
],
6+
ignores: ['.nyc_output/', 'arc-proxy-*', 'coverage/', 'dist.js', 'scratch/', 'src/http/get-index', 'types/'],
157
},
168
]

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"types": "types/index.d.ts",
1313
"scripts": {
1414
"test:one": "cross-env tape 'test/unit/src/http/csrf/*-test.js' | tap-arc",
15-
"lint": "eslint --fix .",
15+
"lint": "biome check --write .",
16+
"lint:fmt": "biome format --write .",
1617
"test": "npm run lint && npm run test:integration && npm run coverage && npm run test:types",
1718
"test:nolint": "npm run test:integration && npm run coverage && npm run test:types",
1819
"test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-arc",
@@ -50,6 +51,7 @@
5051
"@aws-lite/dynamodb-types": "^0.3.11",
5152
"@aws-lite/sns-types": "^0.0.10",
5253
"@aws-lite/sqs-types": "^0.2.6",
54+
"@biomejs/biome": "^1.9.4",
5355
"@types/aws-lambda": "^8.10.147",
5456
"@types/node": "^24.5.2",
5557
"cross-env": "^10.0.0",
@@ -62,10 +64,7 @@
6264
"tiny-json-http": "^7.5.1",
6365
"tsd": "^0.33.0"
6466
},
65-
"files": [
66-
"types/*",
67-
"src/*"
68-
],
67+
"files": ["types/*", "src/*"],
6968
"keywords": [
7069
"aws",
7170
"lambda",

src/discovery/index.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
let { getAwsClient, useAWS } = require('../lib')
1+
const { getAwsClient, useAWS } = require('../lib')
22

33
/**
44
* @param {string} type - events, queues, or tables
55
* @returns {object} {name: value}
66
*/
7-
module.exports = function lookup (callback) {
8-
7+
module.exports = function lookup(callback) {
98
let { ARC_APP_NAME: app, ARC_ENV: env, ARC_SANDBOX, ARC_STACK_NAME: stack } = process.env
109

11-
let local = !useAWS()
10+
const local = !useAWS()
1211

1312
if (!local && !app && !stack) {
1413
return callback(ReferenceError('ARC_APP_NAME and ARC_STACK_NAME env vars not found'))
@@ -18,12 +17,12 @@ module.exports = function lookup (callback) {
1817
app = 'arc-app'
1918
}
2019

21-
let plugins = [ import('@aws-lite/ssm') ]
22-
let config = { plugins }
20+
const plugins = [import('@aws-lite/ssm')]
21+
const config = { plugins }
2322
if (local) {
2423
let port = 2222
2524
if (ARC_SANDBOX) {
26-
let { ports } = JSON.parse(ARC_SANDBOX)
25+
const { ports } = JSON.parse(ARC_SANDBOX)
2726
if (!ports._arc) {
2827
return callback(ReferenceError('Sandbox internal port not found'))
2928
}
@@ -35,19 +34,22 @@ module.exports = function lookup (callback) {
3534
getAwsClient(config, (err, client) => {
3635
if (err) callback(err)
3736
else {
38-
let Path = `/${stack || toLogicalID(`${app}-${env}`)}`
39-
client.ssm.GetParametersByPath({ Path, Recursive: true, paginate: true })
40-
.then(result => {
41-
let services = result.Parameters.reduce((a, b) => {
42-
let hierarchy = b.Name.split('/')
37+
const Path = `/${stack || toLogicalID(`${app}-${env}`)}`
38+
client.ssm
39+
.GetParametersByPath({ Path, Recursive: true, paginate: true })
40+
.then((result) => {
41+
const services = result.Parameters.reduce((a, b) => {
42+
const hierarchy = b.Name.split('/')
4343
hierarchy.shift() // leading slash
4444
hierarchy.shift() // stack name
45-
let type = hierarchy.shift() // i.e. tables, events, queues, plugins
45+
const type = hierarchy.shift() // i.e. tables, events, queues, plugins
4646
if (!a[type]) a[type] = {}
4747
let parent = a[type]
48-
let child, lastChild, lastParent
49-
/* eslint-disable-next-line */
50-
while (child = hierarchy.shift()) {
48+
let child
49+
let lastChild
50+
let lastParent
51+
// biome-ignore lint/suspicious/noAssignInExpressions: we know what we are doing here
52+
while ((child = hierarchy.shift())) {
5153
if (!parent[child]) parent[child] = {}
5254
lastParent = parent
5355
parent = parent[child]
@@ -58,22 +60,19 @@ module.exports = function lookup (callback) {
5860
}, {})
5961
callback(null, services)
6062
})
61-
.catch(err => {
62-
if (err && local &&
63-
err.message.includes('Inaccessible host') &&
64-
err.message.includes('localhost')) {
65-
let msg = 'Sandbox internal services are unavailable, please ensure Sandbox is running'
63+
.catch((err) => {
64+
if (err && local && err.message.includes('Inaccessible host') && err.message.includes('localhost')) {
65+
const msg = 'Sandbox internal services are unavailable, please ensure Sandbox is running'
6666
callback(ReferenceError(msg))
67-
}
68-
else {
67+
} else {
6968
callback(err)
7069
}
7170
})
7271
}
7372
})
7473
}
7574

76-
function toLogicalID (str) {
75+
function toLogicalID(str) {
7776
str = str.replace(/([A-Z])/g, ' $1')
7877
if (str.length === 1) {
7978
return str.toUpperCase()

src/events/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
let pubFactory = require('./publish')
2-
let subFactory = require('./subscribe')
1+
const pubFactory = require('./publish')
2+
const subFactory = require('./subscribe')
33

4-
module.exports = function eventsAndQueuesFactory (arc, type) {
5-
let publish = pubFactory(arc, type)
6-
let subscribe = subFactory(type)
4+
module.exports = function eventsAndQueuesFactory(arc, type) {
5+
const publish = pubFactory(arc, type)
6+
const subscribe = subFactory(type)
77
return { publish, subscribe }
88
}

0 commit comments

Comments
 (0)