Skip to content

Commit

Permalink
chore: Apply linting to root of project. (#557)
Browse files Browse the repository at this point in the history
There is a `check` command at the root, it lints things that are out of
scope of the individual linters. After this baseline we may want to
consider updating some of the per-project linting rules.

This linting is in its own chore PR to prevent creating a release for
these changes.
  • Loading branch information
kinyoklion authored Aug 29, 2024
1 parent fd0c144 commit 3a68da3
Show file tree
Hide file tree
Showing 31 changed files with 82 additions and 112 deletions.
30 changes: 6 additions & 24 deletions .sdk_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"name": "Akamai SDK",
"type": "edge",
"path": "packages/sdk/akamai-base",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "akamai-server-base-sdk-"
}
Expand All @@ -17,10 +14,7 @@
"name": "Akamai SDK for EdgeKV",
"type": "edge",
"path": "packages/sdk/akamai-edgekv",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "akamai-server-edgekv-sdk-"
}
Expand All @@ -29,10 +23,7 @@
"name": "Cloudflare SDK",
"type": "edge",
"path": "packages/sdk/cloudflare",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "cloudflare-server-sdk-"
}
Expand All @@ -41,10 +32,7 @@
"name": "React Native SDK",
"type": "client-side",
"path": "packages/sdk/react-native",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "react-native-client-sdk-"
}
Expand All @@ -53,10 +41,7 @@
"name": "Node.js Server SDK",
"type": "server-side",
"path": "packages/sdk/server-node",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "node-server-sdk-"
}
Expand All @@ -65,10 +50,7 @@
"name": "Vercel Edge SDK",
"type": "edge",
"path": "packages/sdk/vercel",
"languages": [
"JavaScript",
"TypeScript"
],
"languages": ["JavaScript", "TypeScript"],
"releases": {
"tag-prefix": "vercel-server-sdk-"
}
Expand Down
4 changes: 2 additions & 2 deletions PROVENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages.

As part of [SLSA requirements for level 3 compliance](https://slsa.dev/spec/v1.0/requirements), LaunchDarkly publishes provenance attestations about our SDK package builds to npm for distribution alongside our packages.
As part of [SLSA requirements for level 3 compliance](https://slsa.dev/spec/v1.0/requirements), LaunchDarkly publishes provenance attestations about our SDK package builds to npm for distribution alongside our packages.

For npm packages that are published with provenance, npm automatically [verifies the authenticity of the package using Sigstore](https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance).
For npm packages that are published with provenance, npm automatically [verifies the authenticity of the package using Sigstore](https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance).
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ This includes shared libraries, used by SDKs and other tools, as well as SDKs.
| [@launchdarkly/node-server-sdk-redis](packages/store/node-server-sdk-redis/README.md) | [![NPM][node-redis-npm-badge]][node-redis-npm-link] | [Node Redis][node-redis-issues] | [![Actions Status][node-redis-ci-badge]][node-redis-ci] |
| [@launchdarkly/node-server-sdk-dynamodb](packages/store/node-server-sdk-dynamodb/README.md) | [![NPM][node-dynamodb-npm-badge]][node-dynamodb-npm-link] | [Node DynamoDB][node-dynamodb-issues] | [![Actions Status][node-dynamodb-ci-badge]][node-dynamodb-ci] |

| Telemetry Packages | npm | issues | tests |
| ------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------- |
| [@launchdarkly/node-server-sdk-otel](packages/telemetry/node-server-sdk-otel/README.md) | [![NPM][node-otel-npm-badge]][node-otel-npm-link] | [Node OTel][node-otel-issues] | [![Actions Status][node-otel-ci-badge]][node-otel-ci] |
| Telemetry Packages | npm | issues | tests |
| --------------------------------------------------------------------------------------- | ------------------------------------------------- | ----------------------------- | ----------------------------------------------------- |
| [@launchdarkly/node-server-sdk-otel](packages/telemetry/node-server-sdk-otel/README.md) | [![NPM][node-otel-npm-badge]][node-otel-npm-link] | [Node OTel][node-otel-issues] | [![Actions Status][node-otel-ci-badge]][node-otel-ci] |

## Organization

Expand Down Expand Up @@ -62,7 +62,7 @@ We encourage pull requests and other contributions from the community. Check out
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
- Explore LaunchDarkly
Expand Down Expand Up @@ -168,4 +168,4 @@ We encourage pull requests and other contributions from the community. Check out
[node-otel-ci]: https://github.com/launchdarkly/js-core/actions/workflows/node-otel.yml
[node-otel-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/node-server-sdk-otel.svg?style=flat-square
[node-otel-npm-link]: https://www.npmjs.com/package/@launchdarkly/node-server-sdk-otel
[node-otel-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+telemetry%2Fnode-server-sdk-otel%22+
[node-otel-issues]: https://github.com/launchdarkly/js-core/issues?q=is%3Aissue+is%3Aopen+label%3A%22package%3A+telemetry%2Fnode-server-sdk-otel%22+
5 changes: 2 additions & 3 deletions contract-tests/TestHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class TestHook {
}

beforeEvaluation(hookContext, data) {
if(this._errors?.beforeEvaluation) {
if (this._errors?.beforeEvaluation) {
throw new Error(this._errors.beforeEvaluation);
}
this._safePost({
Expand All @@ -36,7 +36,7 @@ export default class TestHook {
}

afterEvaluation(hookContext, data, detail) {
if(this._errors?.afterEvaluation) {
if (this._errors?.afterEvaluation) {
throw new Error(this._errors.afterEvaluation);
}
this._safePost({
Expand All @@ -46,7 +46,6 @@ export default class TestHook {
evaluationDetail: detail,
});


return { ...data, ...(this._data?.['afterEvaluation'] || {}) };
}
}
2 changes: 1 addition & 1 deletion contract-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ app.get('/', (req, res) => {
'inline-context',
'anonymous-redaction',
'evaluation-hooks',
'wrapper'
'wrapper',
],
});
});
Expand Down
6 changes: 3 additions & 3 deletions contract-tests/sdkClientEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ export function makeSdkConfig(options, tag) {
);
}
if (options.wrapper) {
if(options.wrapper.name) {
if (options.wrapper.name) {
cf.wrapperName = options.wrapper.name;
}
if(options.wrapper.version) {
if (options.wrapper.version) {
cf.wrapperVersion = options.wrapper.version;
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ export async function newSdkClientEntity(options) {
makeSdkConfig(options.configuration, options.tag),
);
try {
await client.waitForInitialization({timeout: timeout});
await client.waitForInitialization({ timeout: timeout });
} catch (_) {
// if waitForInitialization() rejects, the client failed to initialize, see next line
}
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/akamai-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ yarn test

## Verifying SDK build provenance with the SLSA framework

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).

## About LaunchDarkly

- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
- Explore LaunchDarkly
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/akamai-edgekv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ yarn test

## Verifying SDK build provenance with the SLSA framework

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).

## About LaunchDarkly

- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
- Explore LaunchDarkly
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ yarn test

## Verifying SDK build provenance with the SLSA framework

LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).

## About LaunchDarkly

- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
- Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
- Explore LaunchDarkly
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/cloudflare/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ npx wrangler kv:key get --binding=LD_KV "LD-Env-test-client-side-id" --preview
5. Edit [index.ts](https://github.com/launchdarkly/js-core/blob/main/packages/sdk/cloudflare/example/src/index.ts#L6) to use your clientSideID and a valid flag key from the test data you just inserted.

```ts
const clientSideID = 'test-client-side-id';
const flagKey = 'test-boolean-flag';
const clientSideID = 'test-client-side-id';
const flagKey = 'test-boolean-flag';
```

6. Finally:
Expand Down
12 changes: 2 additions & 10 deletions packages/sdk/cloudflare/jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
"version": "2.5.11",
"exports": "./src/index.ts",
"publish": {
"include": [
"LICENSE",
"README.md",
"package.json",
"jsr.json",
"src/**/*.ts"
],
"exclude": [
"src/**/*.test.ts"
]
"include": ["LICENSE", "README.md", "package.json", "jsr.json", "src/**/*.ts"],
"exclude": ["src/**/*.test.ts"]
}
}
6 changes: 4 additions & 2 deletions packages/sdk/react-native/example/src/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default function Welcome() {
.catch((e: any) => console.error(`error identifying ${userKey}: ${e}`));
};


const setConnectionMode = (m: ConnectionMode) => {
ldc.setConnectionMode(m);
};
Expand Down Expand Up @@ -51,7 +50,10 @@ export default function Welcome() {
testID="flagKey"
/>
<View style={styles.connectionModeContainer}>
<TouchableOpacity style={styles.buttonContainer} onPress={() => setConnectionMode('offline')}>
<TouchableOpacity
style={styles.buttonContainer}
onPress={() => setConnectionMode('offline')}
>
<Text style={styles.buttonText}>Set offline</Text>
</TouchableOpacity>
<TouchableOpacity
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/react-native/example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"jsx": "react-jsx",
"strict": true,
"typeRoots": ["./types"],
"typeRoots": ["./types"]
},
"exclude": ["e2e"],
"exclude": ["e2e"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ describe('EventSource', () => {
.mockImplementationOnce(() => 0.888)
.mockImplementationOnce(() => 0.999);

mockXhr = {
open: jest.fn(),
send: jest.fn(),
setRequestHeader: jest.fn(),
abort: jest.fn(),
};
mockXhr = {
open: jest.fn(),
send: jest.fn(),
setRequestHeader: jest.fn(),
abort: jest.fn(),
};

jest.spyOn(window, 'XMLHttpRequest').mockImplementation(() => mockXhr as XMLHttpRequest);
jest.spyOn(window, 'XMLHttpRequest').mockImplementation(() => mockXhr as XMLHttpRequest);

eventSource = new EventSource<EventName>(uri, { logger });
eventSource.onclose = jest.fn();
Expand Down Expand Up @@ -84,7 +84,9 @@ describe('EventSource', () => {
test('initial connection', () => {
jest.runAllTimers();

expect(logger.debug).toHaveBeenCalledWith(expect.stringMatching(/\[EventSource\] opening new connection./));
expect(logger.debug).toHaveBeenCalledWith(
expect.stringMatching(/\[EventSource\] opening new connection./),
);
expect(mockXhr.open).toHaveBeenCalledTimes(1);
expect(eventSource.onclose).toHaveBeenCalledTimes(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class EventSource<E extends string = never> {
private tryConnect(initialConnection: boolean = false) {
let delay = initialConnection ? 0 : this.getNextRetryDelay();
if (initialConnection) {
this.logger?.debug(`[EventSource] opening new connection.`)
this.logger?.debug(`[EventSource] opening new connection.`);
} else {
this.logger?.debug(`[EventSource] Will open new connection in ${delay} ms.`);
this.dispatch('retry', { type: 'retry', delayMillis: delay });
Expand Down Expand Up @@ -138,7 +138,8 @@ export default class EventSource<E extends string = never> {
}

this.logger?.debug(
`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[this.xhr.readyState] || 'Unknown'
`[EventSource][onreadystatechange] ReadyState: ${
XMLReadyStateMap[this.xhr.readyState] || 'Unknown'
}(${this.xhr.readyState}), status: ${this.xhr.status}`,
);

Expand Down Expand Up @@ -349,8 +350,8 @@ export default class EventSource<E extends string = never> {
return this.status;
}

onopen() { }
onclose() { }
onerror(_err: any) { }
onretrying(_e: any) { }
onopen() {}
onclose() {}
onerror(_err: any) {}
onretrying(_e: any) {}
}
Loading

0 comments on commit 3a68da3

Please sign in to comment.