Skip to content
Merged
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
13 changes: 12 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ module.exports = [
},
],
'import-x/no-unresolved': ['error', { commonjs: true }],
'no-unused-vars': ['error', { caughtErrors: 'none' }],
'no-unused-vars': [
'error',
{
caughtErrors: 'all',
},
],
'n/no-unsupported-features/node-builtins': ['error', { allowExperimental: true }],
'n/no-extraneous-require': 'off',
'n/no-unpublished-require': 'off',
Expand All @@ -56,6 +61,12 @@ module.exports = [
'n/hashbang': 'off',
},
},
{
files: ['bin/serverless.js', 'commands/**/*.js', 'lib/**/*.js', 'scripts/serverless.js'],
rules: {
'n/no-unpublished-require': 'error',
},
},
{
files: ['**/*.mjs'],
languageOptions: {
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/run-compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const resolveGlobalNpmPath = async () => {
const npmNodeModulesPath = await (async () => {
try {
return String((await spawn('npm', ['root', '-g'])).stdoutBuffer).trim();
} catch (error) {
} catch {
return null;
}
})();

if (!npmNodeModulesPath) return null;
try {
return require.resolve(`${npmNodeModulesPath}/${relativeBinPath}`);
} catch (globalDepError) {
} catch {
return null;
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/configuration/variables/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ Object.defineProperties(
let normalizedResultValue;
try {
normalizedResultValue = JSON.parse(JSON.stringify(resultValue));
} catch (error) {
} catch {
throw new VariableSourceResolutionError(
`Source "${sourceData.type}" returned not supported result: "${util.inspect(
resultValue
Expand Down
2 changes: 1 addition & 1 deletion lib/configuration/variables/sources/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = {
case '.cjs': {
try {
require.resolve(filePath);
} catch (error) {
} catch {
return null;
}
let result;
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ module.exports = {
if (getTemplateResult.TemplateBody) {
try {
templateBody = JSON.parse(getTemplateResult.TemplateBody);
} catch (error) {
} catch {
try {
templateBody = jsyaml.load(getTemplateResult.TemplateBody);
} catch (error2) {
} catch {
throw new ServerlessError(
'Could not parse CloudFormation template',
'CLOUDFORMATION_TEMPLATE_PARSE_FAILED'
Expand Down
8 changes: 4 additions & 4 deletions lib/plugins/aws/invoke-local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class AwsInvokeLocal {
this.options.context = JSON.parse(this.options.context);
}
}
} catch (exception) {
} catch {
// do nothing if it's a simple string or object already
}
}
Expand Down Expand Up @@ -704,7 +704,7 @@ class AwsInvokeLocal {

try {
await fsp.stat(executablePath);
} catch (err) {
} catch {
return new Promise((resolve, reject) => {
const javaBridgeProgress = progress.get('javaBridge');
javaBridgeProgress.notice('Building Java bridge', { isMainEvent: true });
Expand Down Expand Up @@ -883,7 +883,7 @@ class AwsInvokeLocal {
}
try {
JSON.stringify(result);
} catch (error) {
} catch {
throw new ServerlessError(
`Function returned invalid (not a JSON stringifiable) value: ${inspect(result)}`,
'INVALID_INVOKE_LOCAL_RESULT'
Expand All @@ -896,7 +896,7 @@ class AwsInvokeLocal {
Object.assign(result, {
body: JSON.parse(result.body),
});
} catch (e) {
} catch {
throw new ServerlessError(
'Content-Type of response is application/json but body is not json',
'INVOKE_LOCAL_RESPONSE_TYPE_MISMATCH'
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/aws/invoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ class AwsInvoke {
if (!this.options.raw) {
this.options.data = JSON.parse(this.options.data);
}
} catch (exception) {
} catch {
// do nothing if it's a simple string or object already
}

try {
if (!this.options.raw && this.options.context) {
this.options.context = JSON.parse(this.options.context);
}
} catch (exception) {
} catch {
// do nothing if it's a simple string or object already
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ Object.defineProperties(
async () => {
try {
await spawnExt('docker', ['--version']);
} catch (err) {
} catch {
throw new ServerlessError(
'Could not find Docker installation. Ensure Docker is installed before continuing.',
'DOCKER_COMMAND_NOT_AVAILABLE'
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/package/lib/zip-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async function excludeNodeDevDependencies(serviceDir) {
fsp.unlink(nodeProdDepFile).catch(() => {}),
]);
return exAndIn;
} catch (e) {
} catch {
// fail silently
return exAndIn;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/fs/dir-exists-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function dirExistsSync(dirPath) {
try {
const stats = fse.statSync(dirPath);
return stats.isDirectory();
} catch (e) {
} catch {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/fs/file-exists-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function fileExistsSync(filePath) {
try {
const stats = fse.statSync(filePath);
return stats.isFile();
} catch (e) {
} catch {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ module.exports = class TestPlugin {

try {
this.serverless.extendConfiguration([], { custom: {} });
} catch (error) {
} catch {
// ignore this
}

try {
this.serverless.extendConfiguration('custom.target.invalid', {});
} catch (error) {
} catch {
// ignore this
}
}

extendAfterInit() {
try {
this.serverless.extendConfiguration(pluginConfig.afterInitValuePath, 'value');
} catch (error) {
} catch {
// ignore this
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/aws/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('AWS - API Gateway Websocket Integration Test', function () {
promiseReject(error);
try {
ws.close();
} catch (closeError) {
} catch {
// safe to ignore
}
})(reject);
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('AWS - API Gateway Websocket Integration Test', function () {
promiseReject(error);
try {
ws.close();
} catch (closeError) {
} catch {
// safe to ignore
}
})(reject);
Expand Down
2 changes: 1 addition & 1 deletion test/lib/setup-fixtures-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = memoizee((fixturesPath) => {
(() => {
try {
return loadYaml(configContent, { schema: cloudformationSchema });
} catch (error) {
} catch {
return null;
}
})();
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/classes/plugin-manager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ describe('PluginManager', () => {
process.chdir(cwd);
try {
fse.removeSync(tmpDir);
} catch (e) {
} catch {
// Couldn't delete temporary file
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/config-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('test/unit/lib/configSchema.test.js', () => {
(err) => {
try {
expect(err.message).to.include(someCase.errorMessage);
} catch (error) {
} catch {
throw err;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/plugins/aws/invoke-local/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => {
const executable = process.platform === 'win32' ? 'python.exe' : 'python';
try {
await spawnExt(executable, ['--version']);
} catch (err) {
} catch {
skipWithNotice(this, 'Python runtime is not installed');
}
});
Expand All @@ -1815,7 +1815,7 @@ describe('test/unit/lib/plugins/aws/invokeLocal/index.test.js', () => {
const executable = process.platform === 'win32' ? 'ruby.exe' : 'ruby';
try {
await spawnExt(executable, ['--version']);
} catch (err) {
} catch {
skipWithNotice(this, 'Ruby runtime is not installed');
}
});
Expand Down
8 changes: 4 additions & 4 deletions test/utils/aws-cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function cleanup() {
const promises = bucketsToRemove.map((bucket) => deleteBucket(bucket.PhysicalResourceId));
try {
await Promise.all(promises);
} catch (error) {
} catch {
// do nothing... try to continue with cleanup
}
}
Expand All @@ -72,7 +72,7 @@ async function cleanup() {
const promises = stacksToRemove.map((stack) => deleteStack(stack.StackName));
try {
await Promise.all(promises);
} catch (error) {
} catch {
// do nothing... try to continue with cleanup
}
}
Expand All @@ -82,7 +82,7 @@ async function cleanup() {
const promises = apisToRemove.map((api) => deleteRestApi(api.id));
try {
await Promise.all(promises);
} catch (error) {
} catch {
// do nothing... try to continue with cleanup
}
}
Expand All @@ -92,7 +92,7 @@ async function cleanup() {
const promises = userPoolsToRemove.map((userPool) => deleteUserPoolById(userPool.Id));
try {
await Promise.all(promises);
} catch (error) {
} catch {
// do nothing... try to continue with cleanup
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function resolveServiceName(cwd) {
const configObject = (() => {
try {
return loadYaml(configContent);
} catch (error) {
} catch {
return null;
}
})();
Expand Down