Skip to content

Commit

Permalink
chore: Run prettier (#763)
Browse files Browse the repository at this point in the history
* Run prettier

* Update README toc

* Update README toc

* update lockfiles

---------

Co-authored-by: Akinsola Lawanson <106528085+akinsola-guardian@users.noreply.github.com>
  • Loading branch information
joecowton1 and akinsola-guardian committed Jun 15, 2023
1 parent 7a5547d commit 5b00f71
Show file tree
Hide file tree
Showing 37 changed files with 439 additions and 408 deletions.
1 change: 0 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ jobs:
yarn github-pages-deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
DEBUG: true
ORG: guardian-consent
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
sourcepoint-ui
.vscode
coverage
.yarn
34 changes: 17 additions & 17 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"branches": ["main", { "name": "beta", "prerelease": true }],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
"branches": ["main", { "name": "beta", "prerelease": true }],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
}
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ Will be used to link back to a `browserId` for further reporting; if possible th

```js
cmp.init({
country: 'GB',
pubData: {
pageViewId: 'jkao3u2kcbaqk',
},
country: 'GB',
pubData: {
pageViewId: 'jkao3u2kcbaqk',
},
});
```

Expand Down Expand Up @@ -145,9 +145,9 @@ Throws an error if the CMP has not been initialised.

```js
if (cmp.hasInitialised()) {
if (cmp.willShowPrivacyMessageSync()) {
// do something
}
if (cmp.willShowPrivacyMessageSync()) {
// do something
}
}
```

Expand All @@ -166,9 +166,9 @@ cmp.showPrivacyManager();

```js
import {
onConsent,
onConsentChange,
getConsentFor,
onConsent,
onConsentChange,
getConsentFor,
} from '@guardian/consent-management-platform';
```

Expand Down Expand Up @@ -235,7 +235,7 @@ If the user is not in the USA, it will be `undefined`.

```js
{
doNotSell: Boolean;
doNotSell: Boolean;
}
```

Expand All @@ -262,9 +262,9 @@ If the user can be targeted for personalisation according to the active consent

For example `canTarget` would be `true` in the following scenarios:

- for CCPA if the user has _not_ clicked "do not sell",
- for AUS if the user has _not_ opted out of personalised advertising
- for TCFv2 if the user has given consent for all purposes
- for CCPA if the user has _not_ clicked "do not sell",
- for AUS if the user has _not_ opted out of personalised advertising
- for TCFv2 if the user has given consent for all purposes

##### `consentState.framework`

Expand All @@ -278,17 +278,17 @@ The active consent framework e.g. `"ccpa"`, `"aus"`, `"tcfv2"` or `null`.
import { onConsentChange } from '@guardian/consent-management-platform';

onConsentChange(({ tcfv2, ccpa, aus }) => {
if (tcfv2) {
console.log(tcfv2); // { 1: true || false, 1: true || false, ... }
}
if (tcfv2) {
console.log(tcfv2); // { 1: true || false, 1: true || false, ... }
}

if (ccpa) {
console.log(ccpa); // { doNotSell: true || false }
}
if (ccpa) {
console.log(ccpa); // { doNotSell: true || false }
}

if (aus) {
console.log(aus); // { personalisedAdvertising: true || false }
}
if (aus) {
console.log(aus); // { personalisedAdvertising: true || false }
}
});
```

Expand Down Expand Up @@ -353,22 +353,22 @@ The consent object passed to the `onConsentChange` callback.

```js
import {
onConsentChange,
getConsentFor,
onConsentChange,
getConsentFor,
} from '@guardian/consent-management-platform';

onConsentChange((consentState) => {
const ga = getConsentFor('google-analytics', consentState); // true
const comscore = getConsentFor('comscore', consentState); // false
const ga = getConsentFor('google-analytics', consentState); // true
const comscore = getConsentFor('comscore', consentState); // false

// throws error
const eowifnwoeifjoweinf = getConsentFor(
'eowifnwoeifjoweinf',
consentState,
);
// throws error
const eowifnwoeifjoweinf = getConsentFor(
'eowifnwoeifjoweinf',
consentState,
);

// you can still use the consent state for a more complicated task
const complexConsentCondition = myComplexConsentTask(consentState);
// you can still use the consent state for a more complicated task
const complexConsentCondition = myComplexConsentTask(consentState);
});
```

Expand Down
19 changes: 16 additions & 3 deletions cdk/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# editorconfig.org
; This file is for unifying the coding style for different editors and IDEs
; See editorconfig.org

; top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_size = 2

[makefile]
indent_style = tab

[*.yml]
indent_size = 2
indent_style = space
36 changes: 18 additions & 18 deletions cdk/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module.exports = {
root: true,
env: {
node: true,
jest: true,
},
extends: ["@guardian/eslint-config-typescript"],
parserOptions: {
ecmaVersion: 2020,
tsconfigRootDir: __dirname,
sourceType: "module",
project: ["./tsconfig.eslint.json"],
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-inferrable-types": 0,
"import/no-namespace": 2,
},
ignorePatterns: ["**/*.js", "node_modules"],
root: true,
env: {
node: true,
jest: true,
},
extends: ['@guardian/eslint-config-typescript'],
parserOptions: {
ecmaVersion: 2020,
tsconfigRootDir: __dirname,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-inferrable-types': 0,
'import/no-namespace': 2,
},
ignorePatterns: ['**/*.js', 'node_modules'],
};
18 changes: 9 additions & 9 deletions cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ This directory defines the components to be deployed to AWS
We follow the [`script/task`](https://github.com/github/scripts-to-rule-them-all) pattern,
find useful scripts within the [`script`](./script) directory for common tasks.

- `./script/setup` to install dependencies
- `./script/start` to run the Jest unit tests in watch mode
- `./script/lint` to lint the code using ESLint
- `./script/test` to lint, run tests and generate templates of the CDK stacks
- `./script/diff` to print the diff between a CDK stack and a running CloudFormation stack
- `./script/ci` to run tests and synthesise the CDK template in CI
- `./script/setup` to install dependencies
- `./script/start` to run the Jest unit tests in watch mode
- `./script/lint` to lint the code using ESLint
- `./script/test` to lint, run tests and generate templates of the CDK stacks
- `./script/diff` to print the diff between a CDK stack and a running CloudFormation stack
- `./script/ci` to run tests and synthesise the CDK template in CI

There are also some other commands defined in `package.json`, including:

- `yarn lint --fix` attempt to autofix any linter errors
- `yarn format` format the code using Prettier
- `yarn watch` watch for changes and compile
- `yarn lint --fix` attempt to autofix any linter errors
- `yarn format` format the code using Prettier
- `yarn watch` watch for changes and compile

However, it's advised you configure your IDE to format on save to avoid horrible "correct linting" commits.
4 changes: 2 additions & 2 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const regionNames = [
'ap-southeast-2',
'ca-central-1',
] as const;
type AwsRegion = typeof regionNames[number];
type AwsRegion = (typeof regionNames)[number];

const deployableEnvs = ['CODE', 'PROD'] as const;
type DeployableEnvironments = typeof deployableEnvs[number];
type DeployableEnvironments = (typeof deployableEnvs)[number];

function stackProps(
awsRegion: AwsRegion,
Expand Down
10 changes: 5 additions & 5 deletions cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app": "npx ts-node bin/cdk.ts",
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
"app": "npx ts-node bin/cdk.ts",
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
}
10 changes: 5 additions & 5 deletions cdk/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
testMatch: ['<rootDir>/lib/**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
setupFilesAfterEnv: ["./jest.setup.js"],
testMatch: ['<rootDir>/lib/**/*.test.ts'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
setupFilesAfterEnv: ['./jest.setup.js'],
};
2 changes: 1 addition & 1 deletion cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");
jest.mock('@guardian/cdk/lib/constants/tracking-tag');
3 changes: 2 additions & 1 deletion cdk/lib/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export class Monitoring extends GuStack {

// Error Alarm
new Alarm(this, 'cmp-monitoring-alarms', {
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
comparisonOperator:
ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
threshold: 1,
evaluationPeriods: 1,
metric: errorMetric,
Expand Down
Loading

1 comment on commit 5b00f71

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 92.4% 243/263
🟢 Branches 83.19% 94/113
🟢 Functions 90% 63/70
🟢 Lines 92.13% 234/254

Test suite run success

328 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from 5b00f71

Please sign in to comment.