Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanblock committed Apr 29, 2024
1 parent 8f3d829 commit a727205
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/_cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function cleanup (installed) {
renameSync(join(dir, swap), join(dir, file))
}
}
catch (err) { null } // Swallow errors, we may have to bubble something else
catch { null } // Swallow errors, we may have to bubble something else
})
}
}
2 changes: 1 addition & 1 deletion src/_denoise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Filter out excessive / unhelpful vendor logging that includes any of the following strings
*/
let strings = [
'npm WARN prepare removing existing node_modules/ before installation'
'npm WARN prepare removing existing node_modules/ before installation',
]
let regexes = [
/npm WARN .* No description/g,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/autoinstall/node/get-root-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function getRootDeps ({ inv }) {
let packageJson = join(root, 'package.json')
let packageLock = join(root, 'package-lock.json')

let package = existsSync(packageJson) && JSON.parse(readFileSync(packageJson)) || {}
let package = (existsSync(packageJson) && JSON.parse(readFileSync(packageJson))) || {}
let deps = Object.assign(package.devDependencies || {}, package.dependencies || {})

let lock = existsSync(packageLock) && JSON.parse(readFileSync(packageLock))
Expand Down
2 changes: 1 addition & 1 deletion src/actions/autoinstall/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module.exports = function treeshakeNode (nodeDirs, params) {
dir,
file: 'package.json',
remove: [ 'package.json', 'package-lock.json' ], // Identify files for later removal
data: JSON.stringify(lambdaPackage, null, 2)
data: JSON.stringify(lambdaPackage, null, 2),
}
// Autoinstall can be called on a directory that contains a package.json with `"type": "module"` (and no dependencies)
// If we find such a case, kindly move the existing package.json aside until autoinstall ops are complete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = function getRootRequirementsConfig ({ inv }) {
let root = inv._project.cwd
let requirementsTxt = join(root, 'requirements.txt')

let requirements = existsSync(requirementsTxt) &&
readFileSync(requirementsTxt).toString().split('\n') || []
let requirements = (existsSync(requirementsTxt) &&
readFileSync(requirementsTxt).toString().split('\n')) || []

let requirementsConfig = requirements.filter(r => r.startsWith('--')).join('\n') + '\n'

Expand Down
2 changes: 1 addition & 1 deletion src/actions/autoinstall/python/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ${requirementsConfig}${dependencies}
dir,
file: 'requirements.txt',
remove: [ 'requirements.txt' ], // Identify files for later removal
data: lambdaRequirements
data: lambdaRequirements,
}
installing.push(params)
}
Expand Down
4 changes: 1 addition & 3 deletions src/actions/install-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ module.exports = function hydrator (params, callback) {
prodFlag = isRoot ? '' : '--prod'
let localPnpm
try {
// eslint-disable-next-line
require.resolve('pnpm')
localPnpm = true
}
Expand All @@ -97,7 +96,6 @@ module.exports = function hydrator (params, callback) {
else if (isYarn) {
let localYarn
try {
// eslint-disable-next-line
require.resolve('yarn')
localYarn = true
}
Expand Down Expand Up @@ -170,6 +168,6 @@ module.exports = function hydrator (params, callback) {
else {
callback()
}
}
},
], callback)
}
7 changes: 3 additions & 4 deletions src/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function hydrator (inventory, installing, params, callback) {
verbose,
// Isolation / sandbox
copyShared = true,
hydrateShared = true
hydrateShared = true,
} = params
let updaterParams = { quiet }
let update = updater('Hydrate', updaterParams)
Expand All @@ -77,7 +77,6 @@ function hydrator (inventory, installing, params, callback) {
/**
* Find our dependency manifests
*/
// eslint-disable-next-line
let pattern = p => pathToUnix(`${p}/**/@(${manifestFiles.join('|')})`)
let dir = basepath || '.'
// Get everything except shared
Expand Down Expand Up @@ -136,7 +135,7 @@ function hydrator (inventory, installing, params, callback) {
let pkg = JSON.parse(readFileSync(join(src, 'package.json')))
if (!pkg.dependencies && !pkg.peerDependencies && !pkg.devDependencies) return src
}
catch (err) {
catch {
update.error(`Invalid or unable to read ${src}${sep}package.json`)
}
}
Expand Down Expand Up @@ -182,7 +181,7 @@ function hydrator (inventory, installing, params, callback) {
installing,
update,
inventory,
...params
...params,
}, callback))
})

Expand Down
4 changes: 2 additions & 2 deletions test/integration/_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ let pluginArtifacts = []
.flat()

let sharedArtifactsDisabled = [
join('src', 'http', 'any-time_is_good-catchall', nodeShared, 'shared.md')
join('src', 'http', 'any-time_is_good-catchall', nodeShared, 'shared.md'),
]

// Represents src/views without @views pragma (i.e. all GET fns receive views)
Expand All @@ -145,7 +145,7 @@ let viewsArtifacts = []
.concat(arcCustomPath.map(p => join(p, nodeShared, 'views.md')))

let viewsArtifactsDisabled = [
join('src', 'http', 'any-time_is_good-catchall', nodeShared, 'views.md')
join('src', 'http', 'any-time_is_good-catchall', nodeShared, 'views.md'),
]


Expand Down
6 changes: 3 additions & 3 deletions test/integration/default/install-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let {
existsSync,
mkdirSync,
readFileSync,
writeFileSync
writeFileSync,
} = require('fs')
let test = require('tape')
let {
Expand Down Expand Up @@ -116,7 +116,7 @@ test(`[Default (file copying)] install() hydrates all Functions', shared and vie
let dependencies = {
cpr: 'latest',
'run-series': 'latest',
'tiny-json-http': 'latest'
'tiny-json-http': 'latest',
}
t.deepEqual(autoinstall._parsed, _parsed, 'Autoinstall walked shared + views')
t.deepEqual(autoinstall.dependencies, dependencies, 'Autoinstall installed shared + views deps')
Expand Down Expand Up @@ -256,7 +256,7 @@ test(`[Default (file copying)] install() should not recurse into Functions depen
mkdirSync(subdep, { recursive: true })
writeFileSync(join(subdep, 'package.json'), JSON.stringify({
name: 'poop',
dependencies: { 'tiny-json-http': '*' }
dependencies: { 'tiny-json-http': '*' },
}), 'utf-8')
let basepath = nodeFunctions[0]
hydrate.install({ basepath }, function (err) {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/default/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let {
mkdirSync,
readFileSync,
renameSync,
writeFileSync
writeFileSync,
} = require('fs')
let cp = require('cpr')
let test = require('tape')
Expand Down Expand Up @@ -63,7 +63,7 @@ test(`[Shared file copying (default paths)] shared() copies shared and views (un
sharedArtifacts.length +
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length + 1
viewsArtifactsDisabled.length + 1,
)
resetAndCopyShared(t, function () {
hydrate.shared({}, function (err) {
Expand Down Expand Up @@ -99,7 +99,7 @@ test(`[Shared file copying with plugins (default paths)] shared() copies shared
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length +
pluginArtifacts.length + 1
pluginArtifacts.length + 1,
)
resetAndCopySharedPlugins(t, function () {
cp(join('src', 'app.plugins'), join('.', 'app.arc'), { overwrite: true },
Expand Down Expand Up @@ -144,7 +144,7 @@ test(`[Shared file copying (custom paths)] shared() copies shared and views (unl
sharedArtifacts.length +
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length + 1
viewsArtifactsDisabled.length + 1,
)
resetAndCopySharedCustom(t, function () {
hydrate.shared({}, function (err) {
Expand Down
1 change: 0 additions & 1 deletion test/integration/default/update-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ test(`[Default (file copying)] update() bumps installed dependencies to newer ve
hydrate.update(undefined, function (err) {
if (err) t.fail(err)
else {
// eslint-disable-next-line
let pkgLock = JSON.parse(readFileSync(join(mockTmp, nodeFunctions[0], 'package-lock.json')))
let newVersion = [ 2, 3 ].includes(pkgLock.lockfileVersion)
? pkgLock.packages['node_modules/tiny-json-http'].version
Expand Down
6 changes: 3 additions & 3 deletions test/integration/symlink/install-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let {
existsSync,
mkdirSync,
readFileSync,
writeFileSync
writeFileSync,
} = require('fs')
let test = require('tape')
let {
Expand Down Expand Up @@ -120,7 +120,7 @@ test(`[Symlinking] install() hydrates all Functions', shared and views dependenc
let dependencies = {
cpr: 'latest',
'run-series': 'latest',
'tiny-json-http': 'latest'
'tiny-json-http': 'latest',
}
t.deepEqual(autoinstall._parsed, _parsed, 'Autoinstall walked shared + views')
t.deepEqual(autoinstall.dependencies, dependencies, 'Autoinstall installed shared + views deps')
Expand Down Expand Up @@ -260,7 +260,7 @@ test(`[Symlinking] install() should not recurse into Functions dependencies and
mkdirSync(subdep, { recursive: true })
writeFileSync(join(subdep, 'package.json'), JSON.stringify({
name: 'poop',
dependencies: { 'tiny-json-http': '*' }
dependencies: { 'tiny-json-http': '*' },
}), 'utf-8')
let basepath = nodeFunctions[0]
hydrate.install({ basepath, symlink }, function (err) {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/symlink/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let {
mkdirSync,
readFileSync,
renameSync,
writeFileSync
writeFileSync,
} = require('fs')
let cp = require('cpr')
let test = require('tape')
Expand Down Expand Up @@ -67,7 +67,7 @@ test(`[Shared file symlinking (default paths)] shared() copies shared and views
sharedArtifacts.length +
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length + 1
viewsArtifactsDisabled.length + 1,
)
resetAndCopyShared(t, function () {
hydrate.shared({ symlink }, function (err) {
Expand Down Expand Up @@ -103,7 +103,7 @@ test(`[Shared file symlinking with plugins (default paths)] shared() copies shar
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length +
pluginArtifacts.length + 1
pluginArtifacts.length + 1,
)
resetAndCopySharedPlugins(t, function () {
cp(join('src', 'app.plugins'), join('.', 'app.arc'), { overwrite: true },
Expand Down Expand Up @@ -148,7 +148,7 @@ test(`[Shared file symlinking (custom paths)] shared() copies shared and views (
sharedArtifacts.length +
getViewsArtifacts.length +
sharedArtifactsDisabled.length +
viewsArtifactsDisabled.length + 1
viewsArtifactsDisabled.length + 1,
)
resetAndCopySharedCustom(t, function () {
hydrate.shared({ symlink }, function (err) {
Expand Down
1 change: 0 additions & 1 deletion test/integration/symlink/update-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ test(`[Symlinking] update() bumps installed dependencies to newer versions`, t =
hydrate.update({ symlink }, function (err) {
if (err) t.fail(err)
else {
// eslint-disable-next-line
let pkgLock = JSON.parse(readFileSync(join(mockTmp, nodeFunctions[0], 'package-lock.json')))
let newVersion = [ 2, 3 ].includes(pkgLock.lockfileVersion)
? pkgLock.packages['node_modules/tiny-json-http'].version
Expand Down
26 changes: 13 additions & 13 deletions test/unit/src/shared/get-paths-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ test('inventory with a shared path to hydrate and a single node runtime lambda a
lambdasBySrcDir: {
[path]: {
name: 'get /items',
config: { runtime: 'nodejs12' }
}
}
}
config: { runtime: 'nodejs12' },
},
},
},
}
let paths = getPaths(inventory)
t.equals(paths.all[path], join(path, 'node_modules', '@architect'), 'node runtime lambda returns node_modules path (all)')
Expand All @@ -33,15 +33,15 @@ test('inventory with a shared path to hydrate and a single non-node runtime lamb
let inventory = {
inv: {
shared: {
shared: [ path ]
shared: [ path ],
},
lambdasBySrcDir: {
[path]: {
name: 'get /items',
config: { runtime: 'python3' }
}
}
}
config: { runtime: 'python3' },
},
},
},
}
let paths = getPaths(inventory)
t.equals(paths.all[path], join(path, 'vendor'), 'non-node runtime lambda returns vendor path (all)')
Expand All @@ -58,16 +58,16 @@ test('inventory with a shared path to hydrate and multiple node runtime lambdas
let inventory = {
inv: {
views: {
views: [ path ]
views: [ path ],
},
lambdasBySrcDir: {
[path]: [
{ name: 'get /items', config: { runtime: 'nodejs12' } },
{ name: 'get /api/v1/items', config: { runtime: 'nodejs12' } },
{ name: 'get /api/v2/items', config: { runtime: 'nodejs12' } },
]
}
}
],
},
},
}
let paths = getPaths(inventory)
t.equals(paths.all[path], join(path, 'node_modules', '@architect'), 'node runtime lambda returns node_modules path (all)')
Expand Down

0 comments on commit a727205

Please sign in to comment.