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 33fa9a0 commit 0d6dfe8
Show file tree
Hide file tree
Showing 35 changed files with 91 additions and 96 deletions.
2 changes: 1 addition & 1 deletion src/config/pragmas/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function configureHTTP ({ arc, inventory, errors }) {
arcStaticAssetProxy: true,
pragma: 'http',
method: 'get',
path: '/*'
path: '/*',
}
asap.config.shared = false
asap.config.views = false
Expand Down
1 change: 0 additions & 1 deletion src/config/pragmas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ let { all: allPragmas } = pragmas
// Get all pragmas except special cases
let isSpecial = p => [ 'plugins', 'shared', 'views' ].includes(p)
let visitors = allPragmas.map(p => {
// eslint-disable-next-line
if (!isSpecial(p)) return require(`./${p}`)
}).filter(Boolean)

Expand Down
2 changes: 0 additions & 2 deletions src/config/pragmas/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) {
/* istanbul ignore next: idk why but for some reason nyc isn't picking up the catches; all cases are covered in tests, though! */
if (type === 'plugin') {
try {
// eslint-disable-next-line
plugins[name] = require(pluginPath)
}
catch (err) {
Expand All @@ -69,7 +68,6 @@ module.exports = async function getPluginModules ({ arc, inventory, errors }) {
}
// Remap @macros to deploy.start
if (type === 'macro') {
// eslint-disable-next-line
plugins[name] = { deploy: { start: require(pluginPath) } }
}
// Walk each plugin and build the method tree
Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/populate-lambda/_scheduled.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let get = {
dayOfWeek: bits[4],
year: bits[5],
}
}
},
}

module.exports = function populateScheduled (params) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/populate-lambda/get-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function getExt ({ runtime, src, errors }) {
}
}

function findHandler (arr, src){
function findHandler (arr, src) {
for (let handler of arr) {
if (existsSync(join(src, handler))) {
let bits = handler.split('.')
Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function configureShared ({ arc, pragmas, inventory, errors })
let src = join(projSrc, 'shared')
let shared = {
src: null,
shared: []
shared: [],
}

let foundPluginSrc, foundArcSrc, required = false
Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/tables-indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function configureTablesIndexes ({ arc, inventory, errors }) {
plugins: indexesSetters,
inventory,
type: 'indexes',
valid: { name: 'string' }
valid: { name: 'string' },
})
if (plugins) indexes.push(...plugins)

Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function configureTables ({ arc, inventory, errors }) {
plugins: tablesSetters,
inventory,
type: 'tables',
valid: { name: 'string' }
valid: { name: 'string' },
})
if (plugins) tables.push(...plugins)

Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/validate/_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function validateProxy (proxy, errors) {
errors.push(`Invalid @proxy protocol: ${url}`)
}
}
catch (e) {
catch {
errors.push(`Invalid @proxy URL: ${url}`)
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/config/pragmas/validate/_tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function validateTablesAndIndexes (pragma, pragmaName, errors)
deepStrictEqual(index, expect)
return true
}
catch (err) {
catch {
return false
}
})
Expand Down
3 changes: 1 addition & 2 deletions src/config/pragmas/validate/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable global-require */
module.exports = {
// Pragmas and project validation
aws: require('./_aws'),
Expand All @@ -15,5 +14,5 @@ module.exports = {
websockets: require('./_websockets'),

// Misc
validate: require('./_lib')
validate: require('./_lib'),
}
2 changes: 1 addition & 1 deletion src/config/pragmas/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function configureViews ({ arc, pragmas, inventory, errors }) {
let src = join(projSrc, 'views')
let views = {
src: null,
views: []
views: [],
}

let foundPluginSrc, foundArcSrc, required = false
Expand Down
2 changes: 1 addition & 1 deletion src/config/project/prefs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ module.exports = function getPrefs ({ scope, inventory, errors }) {
_arc: prefs.arc,
_raw: prefs.raw,
},
preferencesFile: prefs.filepath
preferencesFile: prefs.filepath,
}
}
5 changes: 2 additions & 3 deletions src/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ module.exports = function env (params, inventory, callback) {
let name = inventory.app
let { profile, region } = inventory.aws
let result = []
// eslint-disable-next-line
let awsLite = require('@aws-lite/client')
/* istanbul ignore next */ // eslint-disable-next-line
/* istanbul ignore next */
awsLite({ profile, region, plugins: [ import('@aws-lite/ssm') ] }).then(_aws => {
aws = _aws

Expand All @@ -24,7 +23,7 @@ module.exports = function env (params, inventory, callback) {
Recursive: true,
MaxResults: 10,
WithDecryption: true,
paginate: true
paginate: true,
}
aws.ssm.GetParametersByPath(params).then(data => {
// Tidy up the response
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = function architectInventory (params = {}, callback) {
// Userland: fill out the pragmas, starting with @plugins
inventory = {
...inventory,
...config.pragmas(project)
...config.pragmas(project),
}

// End here if first-pass validation failed
Expand All @@ -107,7 +107,7 @@ module.exports = function architectInventory (params = {}, callback) {
else {
callback(null, {
inv: inventory,
get: get(inventory)
get: get(inventory),
})
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pragmas.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ module.exports = {
'jsonapi',
'text',
'xml',
]
],
}
2 changes: 1 addition & 1 deletion src/read/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let functionConfig = {

// Local preferences
let preferences = {
arc: [ 'preferences.arc', 'prefs.arc', '.preferences.arc', '.prefs.arc', ],
arc: [ 'preferences.arc', 'prefs.arc', '.preferences.arc', '.prefs.arc' ],
// TODO add json, yaml later if folks want it?
}

Expand Down
2 changes: 1 addition & 1 deletion src/validate/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function validateARN ({ layers, region, config }) {
if (region !== layerRegion) {
badRegions.push(
` - Layer ARN: ${arn}\n` +
` - Layer region: ${layerRegion}`
` - Layer region: ${layerRegion}`,
)
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/validate/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function checkFilePaths (inventory, errors) {
if (proj.build && !ascii.test(proj.build)) return err('Build')

let { lambdasBySrcDir } = inventory
if (lambdasBySrcDir){
if (lambdasBySrcDir) {
Object.values(lambdasBySrcDir).forEach(lambdae => {
if (!Array.isArray(lambdae)) lambdae = [ lambdae ] // Normalize possible multi-tenant Lambdas
lambdae.forEach(lambda => {
Expand Down
18 changes: 9 additions & 9 deletions test/integration/preferences-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ testing
env_var_2 bar
`
let tmp = mockTmp({
[globalPrefsFile]: prefsText
[globalPrefsFile]: prefsText,
})
overrideHomedir(tmp)
inv({ cwd }, (err, result) => {
Expand Down Expand Up @@ -113,7 +113,7 @@ test('Get local preferences', t => {
env: {
testing: { 'env_var_1': 'foo', 'env_var_2': 'bar' },
staging: { 'env_var_1': 'fiz', 'env_var_2': 'buz' },
production: { 'env_var_1': 'qix qix', 'env_var_2': 'qux qux' }
production: { 'env_var_1': 'qix qix', 'env_var_2': 'qux qux' },
},
}
inv({ cwd }, (err, result) => {
Expand Down Expand Up @@ -159,42 +159,42 @@ testing
let globalPrefs = {
sandbox: {
environment: 'testing',
quiet: true
quiet: true,
},
deploy: false,
env: {
testing: { 'env_var_1': 'foo', 'env_var_2': 'bar' },
staging: null,
production: null,
}
},
}
let localPrefs = {
sandbox: {
environment: 'staging',
},
create: {
autocreate: true
autocreate: true,
},
env: {
testing: { 'env_var_2': 'bar' },
staging: { 'env_var_3': 'fiz' },
production: null,
}
},
}
let prefs = {
sandbox: {
environment: 'staging',
quiet: true
quiet: true,
},
deploy: false,
create: {
autocreate: true
autocreate: true,
},
env: {
testing: { 'env_var_2': 'bar' },
staging: { 'env_var_3': 'fiz' },
production: null,
}
},
}
let tmp = mockTmp({
[globalPrefsFile]: globalPrefsText,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/src/config/pragmas/events-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test('@events population: complex format', t => {
`${values[0]}
src ${values[0]}/path`,
`${values[1]}
src ${values[1]}/path`
src ${values[1]}/path`,
]
let arc = parse(`
@events
Expand All @@ -75,7 +75,7 @@ test('@events population: complex format + fallback to default paths', t => {
`${values[0]}
whatever thingo`,
`${values[1]}
whatever thingo`
whatever thingo`,
]
let arc = parse(`
@events
Expand Down
20 changes: 10 additions & 10 deletions test/unit/src/config/pragmas/meta/src-dirs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ test('Lambda source dir population', t => {
let pragmas = {
http: [
{ src: values[0] },
{ src: values[1] }
{ src: values[1] },
],
events: [
{ src: values[2] },
{ src: values[3] }
{ src: values[3] },
],
scheduled: null
scheduled: null,
}

let { lambdaSrcDirs, lambdasBySrcDir } = populateSrcDirs({ pragmas })
Expand All @@ -52,8 +52,8 @@ test('Multiple Lambdas mapped to the same source dir', t => {
{ src: values[1] },
],
events: [
{ src: values[2] }
]
{ src: values[2] },
],
}

let { lambdaSrcDirs, lambdasBySrcDir } = populateSrcDirs({ pragmas })
Expand All @@ -80,9 +80,9 @@ test('HTTP Arc Static Asset Proxy handler', t => {
{
name: 'get /*',
arcStaticAssetProxy: true,
src: null
}
]
src: null,
},
],
}

let { lambdaSrcDirs, lambdasBySrcDir } = populateSrcDirs({ pragmas })
Expand All @@ -95,8 +95,8 @@ test('Lambdas missing src errors', t => {
t.plan(1)
let pragmas = {
http: [
{ name: 'get /' }
]
{ name: 'get /' },
],
}
let errors = []
populateSrcDirs({ pragmas, errors })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ test('Handler properties (Node.js module systems)', t => {
errors = []
cwd = mockTmp({ [src]: {
[`${file}.mjs`]: 'hi',
'package.json': JSON.stringify({})
'package.json': JSON.stringify({}),
} })
result = getHandler({ config, src: join(cwd, src), errors })
t.notOk(errors.length, 'Did not get handler errors')
Expand Down
4 changes: 2 additions & 2 deletions test/unit/src/config/pragmas/queues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test('@queues population: complex format', t => {
`${values[0]}
src ${values[0]}/path`,
`${values[1]}
src ${values[1]}/path`
src ${values[1]}/path`,
]
let arc = parse(`
@queues
Expand All @@ -106,7 +106,7 @@ test('@queues population: complex format + fallback to default paths', t => {
`${values[0]}
whatever thingo`,
`${values[1]}
whatever thingo`
whatever thingo`,
]
let arc = parse(`
@queues
Expand Down
Loading

0 comments on commit 0d6dfe8

Please sign in to comment.