Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d75cd1e

Browse files
JavaScript (v3): Lint - Add eslint-disable to files that haven't been touched since the linter was turned on. (#6900)
1 parent 5053a1c commit d75cd1e

Some content is hidden

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

49 files changed

+238
-197
lines changed

‎javascriptv3/.eslintignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/example_code/reactnative/
22
/example_code/medical-imaging/scenarios/health-image-sets/pixel-data-verification
3-
/example_code/kinesis/kinesis-cdk
3+
/example_code/kinesis/kinesis-cdk
4+
**/dist

‎javascriptv3/example_code/cloudwatch-logs/tests/cloudwatch-query.unit.test.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
54

65
import { describe, it, vi, expect } from "vitest";
76
import { CloudWatchQuery } from "../scenarios/large-query/cloud-watch-query.js";

‎javascriptv3/example_code/cloudwatch/libs/cloudwatch-helper.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
34

45
import {
56
DeleteAlarmsCommand,

‎javascriptv3/example_code/cloudwatch/tests/put-metric-data.integration.test.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import { describe, it, expect } from "vitest";
46
import { v4 as uuidv4 } from "uuid";
57
import { getMetricData } from "../libs/cloudwatch-helper.js";
Lines changed: 108 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,108 @@
1-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
// SPDX-License-Identifier: Apache-2.0
3-
4-
5-
// snippet-start:[codepipeline.javascript.MyCodePipelineFunction.complete]
6-
7-
var assert = require('assert');
8-
var AWS = require('aws-sdk');
9-
var http = require('http');
10-
11-
exports.handler = function(event, context) {
12-
13-
var codepipeline = new AWS.CodePipeline();
14-
15-
// Retrieve the Job ID from the Lambda action
16-
var jobId = event["CodePipeline.job"].id;
17-
18-
// Retrieve the value of UserParameters from the Lambda action configuration in AWS CodePipeline, in this case a URL which will be
19-
// health checked by this function.
20-
var url = event["CodePipeline.job"].data.actionConfiguration.configuration.UserParameters;
21-
22-
// Notify AWS CodePipeline of a successful job
23-
var putJobSuccess = function(message) {
24-
var params = {
25-
jobId: jobId
26-
};
27-
codepipeline.putJobSuccessResult(params, function(err, data) {
28-
if(err) {
29-
context.fail(err);
30-
} else {
31-
context.succeed(message);
32-
}
33-
});
34-
};
35-
36-
// Notify AWS CodePipeline of a failed job
37-
var putJobFailure = function(message) {
38-
var params = {
39-
jobId: jobId,
40-
failureDetails: {
41-
message: JSON.stringify(message),
42-
type: 'JobFailed',
43-
externalExecutionId: context.invokeid
44-
}
45-
};
46-
codepipeline.putJobFailureResult(params, function(err, data) {
47-
context.fail(message);
48-
});
49-
};
50-
51-
// Validate the URL passed in UserParameters
52-
if(!url || url.indexOf('http://') === -1) {
53-
putJobFailure('The UserParameters field must contain a valid URL address to test, including http:// or https://');
54-
return;
55-
}
56-
57-
// Helper function to make a HTTP GET request to the page.
58-
// The helper will test the response and succeed or fail the job accordingly
59-
var getPage = function(url, callback) {
60-
var pageObject = {
61-
body: '',
62-
statusCode: 0,
63-
contains: function(search) {
64-
return this.body.indexOf(search) > -1;
65-
}
66-
};
67-
http.get(url, function(response) {
68-
pageObject.body = '';
69-
pageObject.statusCode = response.statusCode;
70-
71-
response.on('data', function (chunk) {
72-
pageObject.body += chunk;
73-
});
74-
75-
response.on('end', function () {
76-
callback(pageObject);
77-
});
78-
79-
response.resume();
80-
}).on('error', function(error) {
81-
// Fail the job if our request failed
82-
putJobFailure(error);
83-
});
84-
};
85-
86-
getPage(url, function(returnedPage) {
87-
try {
88-
// Check if the HTTP response has a 200 status
89-
assert(returnedPage.statusCode === 200);
90-
// Check if the page contains the text "Congratulations"
91-
// You can change this to check for different text, or add other tests as required
92-
assert(returnedPage.contains('Congratulations'));
93-
94-
// Succeed the job
95-
putJobSuccess("Tests passed.");
96-
} catch (ex) {
97-
// If any of the assertions failed then fail the job
98-
putJobFailure(ex);
99-
}
100-
});
101-
};
102-
103-
// snippet-end:[codepipeline.javascript.MyCodePipelineFunction.complete]
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
5+
// snippet-start:[codepipeline.javascript.MyCodePipelineFunction.complete]
6+
7+
var assert = require("assert");
8+
var AWS = require("aws-sdk");
9+
var http = require("http");
10+
11+
exports.handler = function (event, context) {
12+
var codepipeline = new AWS.CodePipeline();
13+
14+
// Retrieve the Job ID from the Lambda action
15+
var jobId = event["CodePipeline.job"].id;
16+
17+
// Retrieve the value of UserParameters from the Lambda action configuration in AWS CodePipeline, in this case a URL which will be
18+
// health checked by this function.
19+
var url =
20+
event["CodePipeline.job"].data.actionConfiguration.configuration
21+
.UserParameters;
22+
23+
// Notify AWS CodePipeline of a successful job
24+
var putJobSuccess = function (message) {
25+
var params = {
26+
jobId: jobId,
27+
};
28+
codepipeline.putJobSuccessResult(params, function (err, data) {
29+
if (err) {
30+
context.fail(err);
31+
} else {
32+
context.succeed(message);
33+
}
34+
});
35+
};
36+
37+
// Notify AWS CodePipeline of a failed job
38+
var putJobFailure = function (message) {
39+
var params = {
40+
jobId: jobId,
41+
failureDetails: {
42+
message: JSON.stringify(message),
43+
type: "JobFailed",
44+
externalExecutionId: context.invokeid,
45+
},
46+
};
47+
codepipeline.putJobFailureResult(params, function (err, data) {
48+
context.fail(message);
49+
});
50+
};
51+
52+
// Validate the URL passed in UserParameters
53+
if (!url || url.indexOf("http://") === -1) {
54+
putJobFailure(
55+
"The UserParameters field must contain a valid URL address to test, including http:// or https://",
56+
);
57+
return;
58+
}
59+
60+
// Helper function to make a HTTP GET request to the page.
61+
// The helper will test the response and succeed or fail the job accordingly
62+
var getPage = function (url, callback) {
63+
var pageObject = {
64+
body: "",
65+
statusCode: 0,
66+
contains: function (search) {
67+
return this.body.indexOf(search) > -1;
68+
},
69+
};
70+
http
71+
.get(url, function (response) {
72+
pageObject.body = "";
73+
pageObject.statusCode = response.statusCode;
74+
75+
response.on("data", function (chunk) {
76+
pageObject.body += chunk;
77+
});
78+
79+
response.on("end", function () {
80+
callback(pageObject);
81+
});
82+
83+
response.resume();
84+
})
85+
.on("error", function (error) {
86+
// Fail the job if our request failed
87+
putJobFailure(error);
88+
});
89+
};
90+
91+
getPage(url, function (returnedPage) {
92+
try {
93+
// Check if the HTTP response has a 200 status
94+
assert(returnedPage.statusCode === 200);
95+
// Check if the page contains the text "Congratulations"
96+
// You can change this to check for different text, or add other tests as required
97+
assert(returnedPage.contains("Congratulations"));
98+
99+
// Succeed the job
100+
putJobSuccess("Tests passed.");
101+
} catch (ex) {
102+
// If any of the assertions failed then fail the job
103+
putJobFailure(ex);
104+
}
105+
});
106+
};
107+
108+
// snippet-end:[codepipeline.javascript.MyCodePipelineFunction.complete]

‎javascriptv3/example_code/cross-services/aurora-serverless-app/src/handlers/get-items-handler.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import { Handler } from "src/types/handler.js";
46
import { command as getAllItemsCommand } from "../statement-commands/get-all-items.js";
57
import { command as getArchivedItemsCommand } from "../statement-commands/get-archived-items.js";
@@ -18,7 +20,7 @@ const getItemsHandler: Handler = {
1820
};
1921

2022
const response = await rdsDataClient.send<{ records: DBRecords }>(
21-
commands[archived] || getAllItemsCommand
23+
commands[archived] || getAllItemsCommand,
2224
);
2325

2426
res.send(response.records.map(parseItem));

‎javascriptv3/example_code/cross-services/aurora-serverless-app/src/handlers/post-items-handler.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import { v4 as uuidv4 } from "uuid";
46
import { Handler } from "src/types/handler.js";
57
import { Item } from "src/types/item.js";
@@ -12,7 +14,7 @@ const postItemsHandler: Handler = {
1214
const { description, guide, status, name }: Item = req.body;
1315
const command = buildStatementCommand(
1416
"insert into items (iditem, description, guide, status, username, archived)\n" +
15-
`values ("${uuidv4()}", "${description}", "${guide}", "${status}", "${name}", 0)`
17+
`values ("${uuidv4()}", "${description}", "${guide}", "${status}", "${name}", 0)`,
1618
);
1719

1820
await rdsDataClient.send(command);

‎javascriptv3/example_code/cross-services/aurora-serverless-app/src/handlers/post-items-report-handler.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import { SendRawEmailCommand } from "@aws-sdk/client-ses";
46
import { createMimeMessage, TextFormat } from "mimetext";
57
import { format } from "prettier";
@@ -47,7 +49,7 @@ const csvToHtmlTable = (csv: string) => {
4749

4850
const buildSendRawEmailCommand = (
4951
emailAddress: string,
50-
reportData: { csv: string; date: string; itemCount: number }
52+
reportData: { csv: string; date: string; itemCount: number },
5153
) => {
5254
const msg = createMimeMessage();
5355
msg.setSender({ name: emailAddress.split("@")[0], addr: emailAddress });
@@ -56,13 +58,13 @@ const buildSendRawEmailCommand = (
5658
msg.setMessage(
5759
"text/html",
5860
`<h1>Item Report</h1>
59-
${csvToHtmlTable(reportData.csv)}`
61+
${csvToHtmlTable(reportData.csv)}`,
6062
);
6163
msg.setMessage("text/plain", "Report");
6264
msg.setAttachment(
6365
"report.csv",
6466
"text/csv" as TextFormat,
65-
Buffer.from(reportData.csv).toString("base64")
67+
Buffer.from(reportData.csv).toString("base64"),
6668
);
6769

6870
return new SendRawEmailCommand({
@@ -77,7 +79,7 @@ const postItemsReportHandler: Handler = {
7779
({ rdsDataClient, sesClient }) =>
7880
async (req, res) => {
7981
const { records } = await rdsDataClient.send<{ records: DBRecords }>(
80-
getActiveItemsCommand
82+
getActiveItemsCommand,
8183
);
8284
const date = new Date().toLocaleString("en-US");
8385
const csv = makeCsv(records);

‎javascriptv3/example_code/cross-services/aurora-serverless-app/src/handlers/put-items-archive-handler.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import type { Handler } from "src/types/handler.js";
46
import { buildStatementCommand } from "../statement-commands/command-helper.js";
57

@@ -10,7 +12,7 @@ const putItemsArchiveHandler: Handler = {
1012
const { itemId } = req.params;
1113

1214
const command = buildStatementCommand(
13-
"update items\n" + "set archived = 1\n" + `where iditem = "${itemId}"`
15+
"update items\n" + "set archived = 1\n" + `where iditem = "${itemId}"`,
1416
);
1517

1618
await rdsDataClient.send(command);

‎javascriptv3/example_code/cross-services/aurora-serverless-app/src/index.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
/* eslint-disable -- This file existed pre-eslint configuration. Fix the next time the file is touched. */
4+
35
import express from "express";
46
import cors from "cors";
57
import { rdsDataClient, sesClient } from "./client.js";
@@ -22,14 +24,14 @@ exp.get("/api/items", getItemsHandler.withClient({ rdsDataClient }));
2224

2325
exp.post(
2426
"/api/items\\:report",
25-
postItemsReportHandler.withClient({ rdsDataClient, sesClient })
27+
postItemsReportHandler.withClient({ rdsDataClient, sesClient }),
2628
);
2729

2830
exp.post("/api/items", postItemsHandler.withClient({ rdsDataClient }));
2931

3032
exp.put(
3133
"/api/items/:itemId\\:archive",
32-
putItemsArchiveHandler.withClient({ rdsDataClient })
34+
putItemsArchiveHandler.withClient({ rdsDataClient }),
3335
);
3436

3537
exp.listen(port, () => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /