Skip to content
Closed

Biome #573

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [ 16.x, 18.x, 20.x, 22.x ]
node-version: [ 20.x, 22.x, 24.x ]
os: [ windows-latest, ubuntu-latest, macOS-latest ]

# Go
Expand All @@ -40,14 +40,7 @@ jobs:
- name: Install
run: npm install

- name: Test (Node.js <= 16.x)
if: matrix.node-version <= '16.x'
run: npm run test:nolint
env:
CI: true

- name: Test
if: matrix.node-version > '16.x'
run: npm test
env:
CI: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ scratch/
test/mock/*/src/*/*/vendor/
test/mock/tmp/
yarn.lock
.kiro
56 changes: 56 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": [
".nyc_output/",
"arc-proxy-*",
"coverage/",
"dist.js",
"scratch/",
"src/http/get-index",
"types/",
"node_modules/",
"test/mock/*/src/*/*/vendor/",
"test/mock/tmp/"
]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noVar": "error",
"useConst": "error",
"noParameterAssign": "off",
"useDefaultParameterLast": "off"
},
"complexity": {
"noForEach": "off"
},
"performance": {
"noDelete": "off"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
"javascript": {
"formatter": {
"semicolons": "asNeeded",
"quoteStyle": "single"
}
}
}
10 changes: 1 addition & 9 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ const arc = require('@architect/eslint-config')
module.exports = [
...arc,
{
ignores: [
'.nyc_output/',
'arc-proxy-*',
'coverage/',
'dist.js',
'scratch/',
'src/http/get-index',
'types/',
],
ignores: ['.nyc_output/', 'arc-proxy-*', 'coverage/', 'dist.js', 'scratch/', 'src/http/get-index', 'types/'],
},
]
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@architect/functions",
"version": "8.1.9",
"version": "8.1.10-RC.0",
"description": "Runtime utility library for Functional Web Apps (FWAs) built with Architect (https://arc.codes)",
"homepage": "https://github.com/architect/functions",
"repository": {
Expand All @@ -12,7 +12,8 @@
"types": "types/index.d.ts",
"scripts": {
"test:one": "cross-env tape 'test/unit/src/http/csrf/*-test.js' | tap-arc",
"lint": "eslint --fix .",
"lint": "biome check --write .",
"lint:fmt": "biome format --write .",
"test": "npm run lint && npm run test:integration && npm run coverage && npm run test:types",
"test:nolint": "npm run test:integration && npm run coverage && npm run test:types",
"test:unit": "cross-env tape 'test/unit/**/*-test.js' | tap-arc",
Expand All @@ -22,13 +23,13 @@
"rc": "npm version prerelease --preid RC"
},
"engines": {
"node": ">=16"
"node": ">=20"
},
"author": "Brian LeRoux <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"@aws-lite/apigatewaymanagementapi": "^0.0.10",
"@aws-lite/client": "^0.22.4",
"@aws-lite/client": "^0.23.2",
"@aws-lite/dynamodb": "^0.3.9",
"@aws-lite/sns": "^0.0.8",
"@aws-lite/sqs": "^0.2.4",
Expand All @@ -45,27 +46,25 @@
"@architect/asap": "^7.0.10",
"@architect/eslint-config": "^3.0.0",
"@architect/req-res-fixtures": "git+https://github.com/architect/req-res-fixtures.git",
"@architect/sandbox": "^6.0.5",
"@architect/sandbox": "^8.0.0-RC.2",
"@aws-lite/apigatewaymanagementapi-types": "^0.0.13",
"@aws-lite/dynamodb-types": "^0.3.11",
"@aws-lite/sns-types": "^0.0.10",
"@aws-lite/sqs-types": "^0.2.6",
"@biomejs/biome": "^1.9.4",
"@types/aws-lambda": "^8.10.147",
"@types/node": "18",
"cross-env": "~7.0.3",
"@types/node": "^24.5.2",
"cross-env": "^10.0.0",
"eslint": "^9.19.0",
"nyc": "~17.1.0",
"proxyquire": "~2.1.3",
"sinon": "^19.0.2",
"sinon": "^21.0.0",
"tap-arc": "^1.3.2",
"tape": "^5.9.0",
"tiny-json-http": "^7.5.1",
"tsd": "^0.31.2"
"tsd": "^0.33.0"
},
"files": [
"types/*",
"src/*"
],
"files": ["types/*", "src/*"],
"keywords": [
"aws",
"lambda",
Expand Down
47 changes: 23 additions & 24 deletions src/discovery/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
let { getAwsClient, useAWS } = require('../lib')
const { getAwsClient, useAWS } = require('../lib')

/**
* @param {string} type - events, queues, or tables
* @returns {object} {name: value}
*/
module.exports = function lookup (callback) {

module.exports = function lookup(callback) {
let { ARC_APP_NAME: app, ARC_ENV: env, ARC_SANDBOX, ARC_STACK_NAME: stack } = process.env

let local = !useAWS()
const local = !useAWS()

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

let plugins = [ import('@aws-lite/ssm') ]
let config = { plugins }
const plugins = [import('@aws-lite/ssm')]
const config = { plugins }
if (local) {
let port = 2222
if (ARC_SANDBOX) {
let { ports } = JSON.parse(ARC_SANDBOX)
const { ports } = JSON.parse(ARC_SANDBOX)
if (!ports._arc) {
return callback(ReferenceError('Sandbox internal port not found'))
}
Expand All @@ -35,19 +34,22 @@ module.exports = function lookup (callback) {
getAwsClient(config, (err, client) => {
if (err) callback(err)
else {
let Path = `/${stack || toLogicalID(`${app}-${env}`)}`
client.ssm.GetParametersByPath({ Path, Recursive: true, paginate: true })
.then(result => {
let services = result.Parameters.reduce((a, b) => {
let hierarchy = b.Name.split('/')
const Path = `/${stack || toLogicalID(`${app}-${env}`)}`
client.ssm
.GetParametersByPath({ Path, Recursive: true, paginate: true })
.then((result) => {
const services = result.Parameters.reduce((a, b) => {
const hierarchy = b.Name.split('/')
hierarchy.shift() // leading slash
hierarchy.shift() // stack name
let type = hierarchy.shift() // i.e. tables, events, queues, plugins
const type = hierarchy.shift() // i.e. tables, events, queues, plugins
if (!a[type]) a[type] = {}
let parent = a[type]
let child, lastChild, lastParent
/* eslint-disable-next-line */
while (child = hierarchy.shift()) {
let child
let lastChild
let lastParent
// biome-ignore lint/suspicious/noAssignInExpressions: we know what we are doing here
while ((child = hierarchy.shift())) {
if (!parent[child]) parent[child] = {}
lastParent = parent
parent = parent[child]
Expand All @@ -58,22 +60,19 @@ module.exports = function lookup (callback) {
}, {})
callback(null, services)
})
.catch(err => {
if (err && local &&
err.message.includes('Inaccessible host') &&
err.message.includes('localhost')) {
let msg = 'Sandbox internal services are unavailable, please ensure Sandbox is running'
.catch((err) => {
if (err && local && err.message.includes('Inaccessible host') && err.message.includes('localhost')) {
const msg = 'Sandbox internal services are unavailable, please ensure Sandbox is running'
callback(ReferenceError(msg))
}
else {
} else {
callback(err)
}
})
}
})
}

function toLogicalID (str) {
function toLogicalID(str) {
str = str.replace(/([A-Z])/g, ' $1')
if (str.length === 1) {
return str.toUpperCase()
Expand Down
10 changes: 5 additions & 5 deletions src/events/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
let pubFactory = require('./publish')
let subFactory = require('./subscribe')
const pubFactory = require('./publish')
const subFactory = require('./subscribe')

module.exports = function eventsAndQueuesFactory (arc, type) {
let publish = pubFactory(arc, type)
let subscribe = subFactory(type)
module.exports = function eventsAndQueuesFactory(arc, type) {
const publish = pubFactory(arc, type)
const subscribe = subFactory(type)
return { publish, subscribe }
}
Loading
Loading