Skip to content

Commit d5cf318

Browse files
authored
style: adding stricter linting checks with prettier (cdklabs#92)
1 parent 9f3033a commit d5cf318

Some content is hidden

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

70 files changed

+903
-834
lines changed

.eslintrc.json

+8-94
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/build.yml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ repos:
88
- id: trailing-whitespace
99
exclude: ^API.md||.github/$
1010
- repo: https://github.com/pre-commit/mirrors-eslint
11-
rev: v7.28.0
11+
rev: v7.31.0
1212
hooks:
1313
- id: eslint
1414
files: \.[jt]sx?$
1515
types: [file]
16+
- repo: https://github.com/pre-commit/mirrors-prettier
17+
rev: 'v2.3.2'
18+
hooks:
19+
- id: prettier
20+
exclude: |
21+
(?x)(
22+
^.github/|
23+
^.projen/|
24+
^.mergify.yml|
25+
^.*.json
26+
)

.projen/deps.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ const project = new AwsCdkConstructLibrary({
6363
'@aws-cdk/aws-wafv2',
6464
'@aws-cdk/core',
6565
],
66-
6766
pullRequestTemplateContents: [
6867
'',
6968
'----',
7069
'',
7170
'*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*',
7271
],
72+
eslintOptions: { prettier: true },
7373
publishToPypi: {
7474
distName: 'cdk-nag',
7575
module: 'cdk_nag',
@@ -93,6 +93,10 @@ const project = new AwsCdkConstructLibrary({
9393
buildWorkflow: true,
9494
release: true,
9595
});
96+
project.package.addField('prettier', { singleQuote: true, semi: true });
97+
project.eslint.addRules({
98+
'prettier/prettier': ['error', { singleQuote: true, semi: true }],
99+
});
96100
project.package.addField('resolutions', {
97101
'trim-newlines': '3.0.1',
98102
});
@@ -125,7 +129,7 @@ project.buildWorkflow.file.addOverride('jobs.build.steps', [
125129
{
126130
if: 'steps.git_diff.outputs.has_changes',
127131
name: 'Commit and push changes (if changed)',
128-
run: 'git add . && git commit -m "chore: self mutation" \n&& git push origin HEAD:${{ github.event.pull_request.head.ref }}',
132+
run: 'git add . && git commit -m "chore: self mutation" \ngit push origin HEAD:${{ github.event.pull_request.head.ref }}',
129133
},
130134
{
131135
if: 'steps.git_diff.outputs.has_changes',
@@ -144,6 +148,7 @@ project.buildWorkflow.file.addOverride('jobs.build.steps', [
144148
},
145149
},
146150
]);
151+
147152
project.release.addJobs({
148153
release: {
149154
runsOn: 'ubuntu-latest',

CODE_OF_CONDUCT.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
SPDX-License-Identifier: Apache-2.0
44
-->
5+
56
## Code of Conduct
67

78
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).

CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ This repository use [pre-commit](https://pre-commit.com/) hooks for linting and
6868
6. Build
6969
- `npx projen build`
7070
7. Update relevant documentation
71-
8. Create the commit and update files based on `pre-commit` findings
71+
8. Create the commit with relevant files
72+
- Note: you may need to update the commit if `pre-commit` changes/suggests changes to files
7273

7374
### Step 4: Make the pull request
7475

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ user.addToPolicy(
8282
new PolicyStatement({
8383
actions: ['s3:PutObject'],
8484
resources: [new Bucket(this, 'rBucket').arnForObjects('*')],
85-
}),
85+
})
8686
);
8787
const cfnUser = user.node.children;
8888
for (const child of cfnUser) {

package.json

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)