From 0f000eba1581465e568c2bc96e6dfe7da244ab36 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:24:47 -0700 Subject: [PATCH 1/9] Layout an initial repository for create a typescript server sdk. --- .gitignore | 4 +++ CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++ LICENSE.txt | 13 ++++++++ README.md | 54 +++++++++++++++++++++++++++++++++ common/package.json | 26 ++++++++++++++++ common/src/index.ts | 3 ++ common/tsconfig.json | 18 +++++++++++ common/tsconfig.ref.json | 7 +++++ package.json | 11 +++++++ platform-node/package.json | 27 +++++++++++++++++ platform-node/src/index.ts | 3 ++ platform-node/tsconfig.json | 18 +++++++++++ platform-node/tsconfig.ref.json | 7 +++++ tsconfig.json | 11 +++++++ 14 files changed, 251 insertions(+) create mode 100644 .gitignore create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 common/package.json create mode 100644 common/src/index.ts create mode 100644 common/tsconfig.json create mode 100644 common/tsconfig.ref.json create mode 100644 package.json create mode 100644 platform-node/package.json create mode 100644 platform-node/src/index.ts create mode 100644 platform-node/tsconfig.json create mode 100644 platform-node/tsconfig.ref.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..1ca0d4b299 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +package-lock.json +dist/ +node_modules/ +**/*.tsbuildinfo diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..215e2da5c8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,49 @@ +# Contributing to the LaunchDarkly Server-Side SDK for Node.js + +LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK. + +## Submitting bug reports and feature requests + +The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/node-server-sdk/issues) in the SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days. + +## Submitting pull requests + +We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days. + +## Build instructions + +### Prerequisites + +The project should be built and tested against the lowest compatible version, Node 12. It uses `npm`, which is bundled in all supported versions of Node. + +### Setup + +To install project dependencies, from the project root directory: + +``` +npm install +``` + +### Testing + +To run all unit tests: + +``` +npm test +``` + +To run the SDK contract test suite (see [`contract-tests/README.md`](./contract-tests/README.md)): + +```bash +npm run contract-tests +``` + +### Auditing package dependencies + +The `npm audit` tool compares all dependencies and transitive dependencies to a database of package versions with known vulnerabilities. However, the output of this tool includes both runtime and development dependencies. + +Runtime dependencies can affect applications using the SDK; they can only be fixed by updating one of the explicit dependencies in `package.json`. Development dependencies cannot affect applications, but will still cause `npm audit` to flag the project; they can be fixed by running `npm audit fix` to add overrides for transitive dependencies in `package-lock.json`. + +It is important _not_ to run `npm audit fix` if there are any bad _runtime_ dependencies, because it will hide the problem in our own build, without actually fixing the vulnerability when an application uses the SDK. + +The script `scripts/better-audit.sh`, which is run in the CI build and can also be run manually, processes the output of `npm audit` to eliminate all duplicate entries and then determines whether each entry is coming from a runtime dependency or a development dependency. If there are any runtime ones, it terminates with an error code so the build will fail. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000..d238a2b01d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,13 @@ +Copyright 2022 Catamorphic, Co. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000..ee30e8149c --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# LaunchDarkly Server-Side SDK for JavaScript + + + +The LaunchDarkly Server-Side SDK for Node.js is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications. + +For using LaunchDarkly in *client-side* Node.js applications, refer to our [Client-side Node.js SDK](https://github.com/launchdarkly/node-client-sdk). + +## LaunchDarkly overview + +[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today! + +[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly) + +## Supported Node versions + +This version of the LaunchDarkly SDK is compatible with Node.js versions 12 and above. + +## Getting started + +Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/server-side/node-js) for instructions on getting started with using the SDK. + +## Learn more + +Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/node-js). + +The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-server-sdk/). + +## Testing + +We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly. + +## Contributing + +We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK. + +## 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). 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. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list. +* Explore LaunchDarkly + * [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information + * [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides + * [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation + * [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates diff --git a/common/package.json b/common/package.json new file mode 100644 index 0000000000..82200b5db2 --- /dev/null +++ b/common/package.json @@ -0,0 +1,26 @@ +{ + "name": "@launchdarkly/js-server-sdk-common", + "type": "commonjs", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "description": "LaunchDarkly Server-Side SDK for JavaScript", + "files": [ + "/dist" + ], + "keywords": [ + "launchdarkly", + "analytics", + "client" + ], + "scripts": { + "test": "jest --ci", + "build": "tsc" + }, + "license": "Apache-2.0", + "devDependencies": { + "@types/jest": "^27.4.1", + "jest": "^27.5.1", + "ts-jest": "^27.1.4", + "typescript": "^4.6.3" + } +} diff --git a/common/src/index.ts b/common/src/index.ts new file mode 100644 index 0000000000..4840ec0a19 --- /dev/null +++ b/common/src/index.ts @@ -0,0 +1,3 @@ +export default function doesItWork() { + console.log("yes"); +} \ No newline at end of file diff --git a/common/tsconfig.json b/common/tsconfig.json new file mode 100644 index 0000000000..765f5c0540 --- /dev/null +++ b/common/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "target": "es6", + "lib": [ + "es6", + ], + "module": "commonjs", + "strict": true, + "noImplicitOverride": true, + // Needed for CommonJS modules: markdown-it, fs-extra + "allowSyntheticDefaultImports": true, + "sourceMap": true, + "declaration": true, + "declarationMap": true, // enables importers to jump to source + } +} \ No newline at end of file diff --git a/common/tsconfig.ref.json b/common/tsconfig.ref.json new file mode 100644 index 0000000000..4246a65320 --- /dev/null +++ b/common/tsconfig.ref.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*"], + "compilerOptions": { + "composite": true, + }, +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000000..73b4ac2411 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "js-server-sdk", + "workspaces": [ + "common", + "platform-node" + ], + "scripts": { + "clean": "tsc --build --clean", + "build": "tsc --build" + } +} \ No newline at end of file diff --git a/platform-node/package.json b/platform-node/package.json new file mode 100644 index 0000000000..46df44d19d --- /dev/null +++ b/platform-node/package.json @@ -0,0 +1,27 @@ +{ + "name": "js-server-sdk-platform-node", + "version": "1.0.0", + "description": "Node platform for the JS Server SDK", + "type": "commonjs", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "keywords": [ + "launchdarkly", + "analytics", + "client" + ], + "scripts": { + "test": "jest --ci", + "build": "tsc" + }, + "license": "Apache-2.0", + "dependencies": { + "js-server-sdk-common": "@launchdarkly/js-server-sdk-common" + }, + "devDependencies": { + "@types/jest": "^27.4.1", + "jest": "^27.5.1", + "ts-jest": "^27.1.4", + "typescript": "^4.6.3" + } +} \ No newline at end of file diff --git a/platform-node/src/index.ts b/platform-node/src/index.ts new file mode 100644 index 0000000000..00d7a44609 --- /dev/null +++ b/platform-node/src/index.ts @@ -0,0 +1,3 @@ +import doesItWork from '@launchdarkly/js-server-sdk-common'; + +doesItWork(); \ No newline at end of file diff --git a/platform-node/tsconfig.json b/platform-node/tsconfig.json new file mode 100644 index 0000000000..5057bbfaae --- /dev/null +++ b/platform-node/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "target": "es6", + "lib": [ + "es6" + ], + "module": "commonjs", + "strict": true, + "noImplicitOverride": true, + // Needed for CommonJS modules: markdown-it, fs-extra + "allowSyntheticDefaultImports": true, + "sourceMap": true, + "declaration": true, + "declarationMap": true, // enables importers to jump to source + } +} \ No newline at end of file diff --git a/platform-node/tsconfig.ref.json b/platform-node/tsconfig.ref.json new file mode 100644 index 0000000000..4246a65320 --- /dev/null +++ b/platform-node/tsconfig.ref.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*"], + "compilerOptions": { + "composite": true, + }, +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..9f32c7b465 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { + "path": "./common/tsconfig.ref.json" + }, + { + "path": "./platform-node/tsconfig.ref.json" + }, + ], +} \ No newline at end of file From f7a3c68c8e4ef034f7ff6070edee71e0e057be65 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 5 May 2022 16:13:28 -0700 Subject: [PATCH 2/9] Add more common sdk folder. --- package.json | 3 ++- sdk-common/package.json | 26 ++++++++++++++++++++++ sdk-common/src/index.ts | 0 {common => sdk-common}/tsconfig.json | 0 {common => sdk-common}/tsconfig.ref.json | 0 {common => server-sdk-common}/package.json | 0 {common => server-sdk-common}/src/index.ts | 0 server-sdk-common/tsconfig.json | 18 +++++++++++++++ server-sdk-common/tsconfig.ref.json | 7 ++++++ tsconfig.json | 5 ++++- 10 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 sdk-common/package.json create mode 100644 sdk-common/src/index.ts rename {common => sdk-common}/tsconfig.json (100%) rename {common => sdk-common}/tsconfig.ref.json (100%) rename {common => server-sdk-common}/package.json (100%) rename {common => server-sdk-common}/src/index.ts (100%) create mode 100644 server-sdk-common/tsconfig.json create mode 100644 server-sdk-common/tsconfig.ref.json diff --git a/package.json b/package.json index 73b4ac2411..50ac28f2a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "js-server-sdk", "workspaces": [ - "common", + "sdk-common", + "server-sdk-common", "platform-node" ], "scripts": { diff --git a/sdk-common/package.json b/sdk-common/package.json new file mode 100644 index 0000000000..f3c379640a --- /dev/null +++ b/sdk-common/package.json @@ -0,0 +1,26 @@ +{ + "name": "@launchdarkly/js-sdk-common", + "type": "commonjs", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "description": "LaunchDarkly Server-Side SDK for JavaScript", + "files": [ + "/dist" + ], + "keywords": [ + "launchdarkly", + "analytics", + "client" + ], + "scripts": { + "test": "jest --ci", + "build": "tsc" + }, + "license": "Apache-2.0", + "devDependencies": { + "@types/jest": "^27.4.1", + "jest": "^27.5.1", + "ts-jest": "^27.1.4", + "typescript": "^4.6.3" + } +} diff --git a/sdk-common/src/index.ts b/sdk-common/src/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/common/tsconfig.json b/sdk-common/tsconfig.json similarity index 100% rename from common/tsconfig.json rename to sdk-common/tsconfig.json diff --git a/common/tsconfig.ref.json b/sdk-common/tsconfig.ref.json similarity index 100% rename from common/tsconfig.ref.json rename to sdk-common/tsconfig.ref.json diff --git a/common/package.json b/server-sdk-common/package.json similarity index 100% rename from common/package.json rename to server-sdk-common/package.json diff --git a/common/src/index.ts b/server-sdk-common/src/index.ts similarity index 100% rename from common/src/index.ts rename to server-sdk-common/src/index.ts diff --git a/server-sdk-common/tsconfig.json b/server-sdk-common/tsconfig.json new file mode 100644 index 0000000000..765f5c0540 --- /dev/null +++ b/server-sdk-common/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "target": "es6", + "lib": [ + "es6", + ], + "module": "commonjs", + "strict": true, + "noImplicitOverride": true, + // Needed for CommonJS modules: markdown-it, fs-extra + "allowSyntheticDefaultImports": true, + "sourceMap": true, + "declaration": true, + "declarationMap": true, // enables importers to jump to source + } +} \ No newline at end of file diff --git a/server-sdk-common/tsconfig.ref.json b/server-sdk-common/tsconfig.ref.json new file mode 100644 index 0000000000..4246a65320 --- /dev/null +++ b/server-sdk-common/tsconfig.ref.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*"], + "compilerOptions": { + "composite": true, + }, +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 9f32c7b465..0e93c9a18c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,10 @@ "files": [], "references": [ { - "path": "./common/tsconfig.ref.json" + "path": "./sdk-common/tsconfig.ref.json" + }, + { + "path": "./server-sdk-common/tsconfig.ref.json" }, { "path": "./platform-node/tsconfig.ref.json" From 82758cbaf8b4f922ff1d3d8047e27fde28570b8c Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 5 May 2022 16:20:37 -0700 Subject: [PATCH 3/9] Add extra blank lines. Change module names. --- package.json | 4 ++-- platform-node/package.json | 4 ++-- sdk-common/package.json | 2 +- server-sdk-common/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 50ac28f2a0..616921ef73 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "js-server-sdk", + "name": "@launchdarkly/js-server-sdk", "workspaces": [ "sdk-common", "server-sdk-common", @@ -9,4 +9,4 @@ "clean": "tsc --build --clean", "build": "tsc --build" } -} \ No newline at end of file +} diff --git a/platform-node/package.json b/platform-node/package.json index 46df44d19d..1460f6e942 100644 --- a/platform-node/package.json +++ b/platform-node/package.json @@ -1,5 +1,5 @@ { - "name": "js-server-sdk-platform-node", + "name": "@launchdarkly/js-server-sdk-platform-node", "version": "1.0.0", "description": "Node platform for the JS Server SDK", "type": "commonjs", @@ -24,4 +24,4 @@ "ts-jest": "^27.1.4", "typescript": "^4.6.3" } -} \ No newline at end of file +} diff --git a/sdk-common/package.json b/sdk-common/package.json index f3c379640a..43388206eb 100644 --- a/sdk-common/package.json +++ b/sdk-common/package.json @@ -3,7 +3,7 @@ "type": "commonjs", "main": "./dist/index.js", "types": "./dist/index.d.ts", - "description": "LaunchDarkly Server-Side SDK for JavaScript", + "description": "LaunchDarkly SDK for JavaScript - common code", "files": [ "/dist" ], diff --git a/server-sdk-common/package.json b/server-sdk-common/package.json index 82200b5db2..97edcb76bd 100644 --- a/server-sdk-common/package.json +++ b/server-sdk-common/package.json @@ -3,7 +3,7 @@ "type": "commonjs", "main": "./dist/index.js", "types": "./dist/index.d.ts", - "description": "LaunchDarkly Server-Side SDK for JavaScript", + "description": "LaunchDarkly Server SDK for JavaScript - common code", "files": [ "/dist" ], From 48a6d60048cdde7ee882bc245dd8b81f4c68306f Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 5 May 2022 16:23:46 -0700 Subject: [PATCH 4/9] Blank lines. --- platform-node/src/index.ts | 2 +- server-sdk-common/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform-node/src/index.ts b/platform-node/src/index.ts index 00d7a44609..e9efeb0ad3 100644 --- a/platform-node/src/index.ts +++ b/platform-node/src/index.ts @@ -1,3 +1,3 @@ import doesItWork from '@launchdarkly/js-server-sdk-common'; -doesItWork(); \ No newline at end of file +doesItWork(); diff --git a/server-sdk-common/src/index.ts b/server-sdk-common/src/index.ts index 4840ec0a19..2bc30d5838 100644 --- a/server-sdk-common/src/index.ts +++ b/server-sdk-common/src/index.ts @@ -1,3 +1,3 @@ export default function doesItWork() { console.log("yes"); -} \ No newline at end of file +} From dca048a3f4d241fa2d5daaa1984c6d1e9b9909f8 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 5 May 2022 16:24:44 -0700 Subject: [PATCH 5/9] More blank lines. --- platform-node/tsconfig.json | 2 +- platform-node/tsconfig.ref.json | 2 +- sdk-common/tsconfig.json | 2 +- sdk-common/tsconfig.ref.json | 2 +- server-sdk-common/tsconfig.json | 2 +- server-sdk-common/tsconfig.ref.json | 2 +- tsconfig.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platform-node/tsconfig.json b/platform-node/tsconfig.json index 5057bbfaae..34a316938d 100644 --- a/platform-node/tsconfig.json +++ b/platform-node/tsconfig.json @@ -15,4 +15,4 @@ "declaration": true, "declarationMap": true, // enables importers to jump to source } -} \ No newline at end of file +} diff --git a/platform-node/tsconfig.ref.json b/platform-node/tsconfig.ref.json index 4246a65320..6ac0afa664 100644 --- a/platform-node/tsconfig.ref.json +++ b/platform-node/tsconfig.ref.json @@ -4,4 +4,4 @@ "compilerOptions": { "composite": true, }, -} \ No newline at end of file +} diff --git a/sdk-common/tsconfig.json b/sdk-common/tsconfig.json index 765f5c0540..0c10db0c9d 100644 --- a/sdk-common/tsconfig.json +++ b/sdk-common/tsconfig.json @@ -15,4 +15,4 @@ "declaration": true, "declarationMap": true, // enables importers to jump to source } -} \ No newline at end of file +} diff --git a/sdk-common/tsconfig.ref.json b/sdk-common/tsconfig.ref.json index 4246a65320..6ac0afa664 100644 --- a/sdk-common/tsconfig.ref.json +++ b/sdk-common/tsconfig.ref.json @@ -4,4 +4,4 @@ "compilerOptions": { "composite": true, }, -} \ No newline at end of file +} diff --git a/server-sdk-common/tsconfig.json b/server-sdk-common/tsconfig.json index 765f5c0540..0c10db0c9d 100644 --- a/server-sdk-common/tsconfig.json +++ b/server-sdk-common/tsconfig.json @@ -15,4 +15,4 @@ "declaration": true, "declarationMap": true, // enables importers to jump to source } -} \ No newline at end of file +} diff --git a/server-sdk-common/tsconfig.ref.json b/server-sdk-common/tsconfig.ref.json index 4246a65320..6ac0afa664 100644 --- a/server-sdk-common/tsconfig.ref.json +++ b/server-sdk-common/tsconfig.ref.json @@ -4,4 +4,4 @@ "compilerOptions": { "composite": true, }, -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 0e93c9a18c..d405b65d56 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,4 +11,4 @@ "path": "./platform-node/tsconfig.ref.json" }, ], -} \ No newline at end of file +} From b6f2151245ca90fc00650a4ed3406e55c76ab62b Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Fri, 6 May 2022 14:00:28 -0700 Subject: [PATCH 6/9] Add linting. --- .eslintrc.js | 18 ++++++++++++++++++ package.json | 12 +++++++++++- server-sdk-common/src/index.ts | 2 +- tsconfig.eslint.json | 5 +++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .eslintrc.js create mode 100644 tsconfig.eslint.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..7fead2445a --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,18 @@ +module.exports = { + env: { + node: true, + }, + extends: [ + 'airbnb-base', + 'airbnb-typescript/base' + ], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.eslint.json' + }, + plugins: [ + '@typescript-eslint', + ], + rules: { + }, +}; diff --git a/package.json b/package.json index 616921ef73..d1a31dda1f 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,16 @@ ], "scripts": { "clean": "tsc --build --clean", - "build": "tsc --build" + "build": "tsc --build", + "lint": "eslint . --ext .ts", + "lint:fix": "npm run lint -- --fix" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.22.0", + "@typescript-eslint/parser": "^5.22.0", + "eslint": "^8.14.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-config-airbnb-typescript": "^17.0.0", + "eslint-plugin-import": "^2.26.0" } } diff --git a/server-sdk-common/src/index.ts b/server-sdk-common/src/index.ts index 2bc30d5838..243647d62c 100644 --- a/server-sdk-common/src/index.ts +++ b/server-sdk-common/src/index.ts @@ -1,3 +1,3 @@ export default function doesItWork() { - console.log("yes"); + console.log('yes'); } diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 0000000000..951874af1f --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["/**/*.ts"], + "exclude": ["node_modules"] +} \ No newline at end of file From 851bbba50b7e0b706ad45f0509515317dda506cf Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Fri, 6 May 2022 14:33:56 -0700 Subject: [PATCH 7/9] Update tsconfig.eslint.json --- tsconfig.eslint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 951874af1f..56c9b38305 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -2,4 +2,4 @@ "extends": "./tsconfig.json", "include": ["/**/*.ts"], "exclude": ["node_modules"] -} \ No newline at end of file +} From 7353f7393cf5857651bd991916c96e33af241edd Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Fri, 6 May 2022 15:30:51 -0700 Subject: [PATCH 8/9] Ignore dist directories. --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 7fead2445a..62f203b283 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,7 @@ module.exports = { plugins: [ '@typescript-eslint', ], + ignorePatterns: ["**/dist/**"], rules: { }, }; From c693e206ca30cfdcb82ad2ea67a219d40c3eaff6 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Fri, 6 May 2022 15:31:19 -0700 Subject: [PATCH 9/9] More lint refinement. --- platform-node/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-node/package.json b/platform-node/package.json index 1460f6e942..0ec7bbff11 100644 --- a/platform-node/package.json +++ b/platform-node/package.json @@ -16,7 +16,7 @@ }, "license": "Apache-2.0", "dependencies": { - "js-server-sdk-common": "@launchdarkly/js-server-sdk-common" + "@launchdarkly/js-server-sdk-common": "@launchdarkly/js-server-sdk-common" }, "devDependencies": { "@types/jest": "^27.4.1",