Skip to content

Commit 13282a0

Browse files
authored
lint: ban fs-extra import aws#5730
## Problem we want to using the `fs-extra` package. ## Solution Have ESLint do the job for us, error on attempting to import `fs-extra`.
1 parent 1bfd53b commit 13282a0

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

.eslintrc.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,15 @@ module.exports = {
173173
"Avoid importing from the core lib's dist/ folders; please use directly from the core lib defined exports.",
174174
},
175175
],
176+
// The following will place an error on the `fs-extra` import since we do not want it to be used for browser compatibility reasons.
177+
paths: [
178+
{
179+
name: 'fs-extra',
180+
message:
181+
'Avoid fs-extra, use shared/fs/fs.ts. Notify the Toolkit team if your required functionality is not available.',
182+
},
183+
],
176184
},
177-
// The following will place an error on the `fs-extra` import since we do not want it to be used for browser compatibility reasons.
178-
// {
179-
// name: 'fs-extra',
180-
// message:
181-
// 'Avoid fs-extra, use shared/fs/fs.ts. Notify the Toolkit team if your required functionality is not available.',
182-
// },
183185
],
184186
},
185187
}

packages/amazonq/scripts/build/copyFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
/* eslint-disable no-restricted-imports */
67
import * as fs from 'fs-extra'
78
import * as path from 'path'
89

packages/core/scripts/build/copyFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
/* eslint-disable no-restricted-imports */
67
import * as fs from 'fs-extra'
78
import * as path from 'path'
89

packages/core/scripts/build/generateServiceClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
/* eslint-disable no-restricted-imports */
67
import * as proc from 'child_process'
78
import * as fs from 'fs-extra'
89
import * as path from 'path'

packages/core/src/test/lambda/local/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { writeFile } from 'fs-extra'
76
import { EOL } from 'os'
87
import * as CloudFormation from '../../../shared/cloudformation/cloudformation'
8+
import { fs } from '../../../shared'
99

1010
export async function saveTemplate(templatePath: string, runtime: string, ...functionNames: string[]) {
1111
const functionResources = functionNames
@@ -57,5 +57,5 @@ Outputs:
5757
Value: !GetAtt HelloWorldFunctionRole.Arn
5858
`
5959

60-
await writeFile(templatePath, templateContent, 'utf8')
60+
await fs.writeFile(templatePath, templateContent)
6161
}

packages/core/src/test/shared/cloudformation/cloudformationTestUtils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { writeFile } from 'fs-extra'
7-
6+
import { fs } from '../../../shared'
87
import * as CloudFormation from '../../../shared/cloudformation/cloudformation'
98

109
export function createBaseTemplate(): CloudFormation.Template {
@@ -67,7 +66,7 @@ export function createBaseImageResource(): CloudFormation.Resource {
6766
}
6867

6968
export async function strToYamlFile(str: string, file: string): Promise<void> {
70-
await writeFile(file, str, 'utf8')
69+
await fs.writeFile(file, str)
7170
}
7271

7372
export function makeSampleSamTemplateYaml(

packages/toolkit/scripts/build/copyFiles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
/* eslint-disable no-restricted-imports */
67
import * as fs from 'fs-extra'
78
import * as path from 'path'
89

0 commit comments

Comments
 (0)