diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..e6c30dc
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+node_modules
+lib
+example
\ No newline at end of file
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..779e89d
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,50 @@
+module.exports = {
+ env: {
+ es6: true,
+ node: true,
+ browser: true,
+ },
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ ecmaVersion: 2022,
+ sourceType: 'module',
+ ecmaFeatures: {
+ jsx: true,
+ },
+ },
+ plugins: ['@typescript-eslint', 'react'],
+ extends: [
+ 'eslint:recommended',
+ 'prettier',
+ 'plugin:@typescript-eslint/eslint-recommended',
+ 'plugin:@typescript-eslint/recommended',
+ 'plugin:react/recommended',
+ ],
+ rules: {
+ 'no-console': ['error', { allow: ['warn', 'error', 'time'] }],
+ 'react/jsx-pascal-case': 2,
+ 'react/no-multi-comp': 2,
+ 'react/prefer-es6-class': 2,
+ 'react/prefer-stateless-function': 2,
+ '@typescript-eslint/no-var-requires': 0,
+ '@typescript-eslint/no-unused-vars': [
+ 'error',
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
+ ],
+ '@typescript-eslint/no-empty-function': 0,
+ '@typescript-eslint/no-explicit-any': 0,
+ '@typescript-eslint/naming-convention': [
+ 'error',
+ {
+ selector: 'variableLike',
+ format: ['camelCase', 'PascalCase'],
+ },
+ {
+ selector: 'variable',
+ modifiers: ['destructured'],
+ format: null,
+ },
+ ],
+ 'no-undef': 'error',
+ },
+};
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..6918ccc
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,26 @@
+---
+name: Bug report
+about: Report a bug or issue to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Some steps involved to reproduce the bug and any code samples you can share.
+```
+// Helps us with reproducing the error :)
+```
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**SDK Version:**
+Providing the SDK version can help with the reproduction of the issue and to know if a change could have broken something.
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..11fc491
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000..f48b259
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,11 @@
+# Description
+
+
+# Usage
+
+```typescript jsx
+// Adding a code snippet also helps if it makes sense to do so :)
+```
+
+# License
+I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.
\ No newline at end of file
diff --git a/.github/workflows/pull-reqeust.yml b/.github/workflows/pull-reqeust.yml
new file mode 100644
index 0000000..1780ff8
--- /dev/null
+++ b/.github/workflows/pull-reqeust.yml
@@ -0,0 +1,30 @@
+name: Pull Request
+on:
+ # Trigger the workflow on push or pull request,
+ # but only for the main branch
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ checks:
+ runs-on: ubuntu-latest
+ name: Lint and check code styling
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup Nodejs ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: 16
+
+ - name: Install dependencies and build
+ run: npm install
+
+ - name: Run lint checks
+ run: npm run lint:ci
+
+ - name: Run prettier checks
+ run: npm run lint:prettier:check
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..e6c30dc
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,3 @@
+node_modules
+lib
+example
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..c7b3df0
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,6 @@
+{
+ "semi": true,
+ "trailingComma": "es5",
+ "singleQuote": true,
+ "printWidth": 80
+}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..02aba0d
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,4 @@
+# Changelog
+
+### 0.1.0 / TBD
+* Initial release of the Nylas React SDK
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..e0e4449
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,36 @@
+# Contribute to Nylas
+ππ First off, thanks for taking the time to contribute! ππ
+
+The following is a set of guidelines for contributing to the Nylas JavaScript SDK; these are guidelines, not rules, so please use your best judgement and feel free to propose changes to this document via pull request.
+
+## How to Ask a Question
+
+If you have a question about how to use the JavaScript SDK, please [create an issue](https://github.com/nylas/nylas-js/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to support@nylas.com to get help.
+
+## How To Contribute
+### Report a Bug or Request a Feature
+
+If you encounter any bugs while using this software, or want to request a new feature or enhancement, please [create an issue](https://github.com/nylas/nylas-js/issues) to report it, and make sure you add a label to indicate what type of issue it is.
+
+### Contribute Code
+
+Pull requests are welcome for bug fixes. If you want to implement something new, [please request a feature](https://github.com/nylas/nylas-js/issues) first so we can discuss it.
+
+While writing your code contribution, make sure you lint your code by running:
+
+`npm run lint`
+
+and apply our code styling standards:
+
+`npm run lint:prettier`
+
+To use the package during local development, symlink the directory:
+
+`npm link` in the `nylas-js` directory
+`npm link @nylas/nylas-js` in the directory with your code that uses the package
+
+### Creating a Pull Request
+
+When your code is ready to be submitted, you can [submit a pull request](https://help.github.com/articles/creating-a-pull-request/) to begin the code review process. Please ensure to title it appropriately with a nice, quick summary of what the PR is achieving. We've also provided a [template for pull requests](pull_request_template.md) as a guide.
+
+All PRs from contributors that aren't employed by Nylas must contain the following text in the PR description: "I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner."
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..4e807c2
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+----
+
+Copyright (c) 2014-2015 InboxApp, Inc. and Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
index a23fd6d..eefc2b2 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,7 @@
+
+
+
+
# Nylas React SDK
![npm](https://img.shields.io/npm/v/@nylas/nylas-react)
@@ -10,7 +14,7 @@ Here are some resources to help you get started:
- [Nylas API Reference](https://developer.nylas.com/docs/api/)
-# Install
+## βοΈ Install
To install the Nylas React SDK, you will first need to have [npm](https://www.npmjs.com/get-npm) installed on your machine.
@@ -27,7 +31,7 @@ cd nylas-react
npm install
```
-# Usage
+## β‘οΈ Usage
The Nylas React SDK provides an easy way to implement authentication in your react application.
@@ -46,11 +50,13 @@ These are the following options that can be passed in to configure an instance o
* authWithRedirect - The function for building, and redirecting to, the authentication URL
* exchangeCodeFromUrlForToken - The function for parsing the code from the authentication URL and exchanging it for an access token
-# Contributing
+## π Contributing
+
+Interested in contributing to the Nylas JavaScript SDK project? Thanks so much for your interest! We are always looking for improvements to the project and contributions from open-source developers are greatly appreciated.
Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.
-# License
+## πLicense
This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.
diff --git a/package.json b/package.json
index e22bcde..0a3604d 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,12 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
- "build": "tsc"
+ "build": "tsc",
+ "lint": "eslint --ext .js,.ts -f visualstudio .",
+ "lint:fix": "npm run lint -- --fix",
+ "lint:ci": "npm run lint:fix -- --quiet",
+ "lint:prettier": "prettier --write '**/*.{ts,js}'",
+ "lint:prettier:check": "prettier --check '**/*.{ts,js}'"
},
"dependencies": {
"@nylas/nylas-js": "^0.1.0"
@@ -13,7 +18,13 @@
"devDependencies": {
"typescript": "^4.7.4",
"react": "^18.2.0",
- "@types/react": "^18.0.12"
+ "@types/react": "^18.0.12",
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
+ "eslint": "^8.20.0",
+ "eslint-config-prettier": "^8.5.0",
+ "eslint-plugin-prettier": "^4.2.1",
+ "eslint-plugin-react": "^7.30.1",
+ "prettier": "^2.7.1"
},
"repository": {
"type": "git",
diff --git a/src/index.ts b/src/index.ts
index 7e0deba..53d61f8 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,14 +1,14 @@
export {
default as NylasContainer,
- NylasContainerOptions
+ NylasContainerOptions,
} from './nylas-container';
export {
default as NylasContext,
NylasContextInterface,
- useNylas
+ useNylas,
} from './nylas-context';
export {
NylasProps,
AuthUrlOptions,
- ExchangeCodeOptions
-} from '@nylas/nylas-js';
\ No newline at end of file
+ ExchangeCodeOptions,
+} from '@nylas/nylas-js';
diff --git a/src/nylas-context.ts b/src/nylas-context.ts
index 9f3f25d..acf7f78 100644
--- a/src/nylas-context.ts
+++ b/src/nylas-context.ts
@@ -1,15 +1,18 @@
import * as React from 'react';
-import Nylas, {AuthUrlOptions, ExchangeCodeOptions} from "@nylas/nylas-js";
+import Nylas, { AuthUrlOptions, ExchangeCodeOptions } from '@nylas/nylas-js';
export interface NylasContextInterface {
client: Nylas;
authState: boolean;
- authWithRedirect(opts: AuthUrlOptions): Promise;
- exchangeCodeFromUrlForToken(opts?: ExchangeCodeOptions): Promise;
+ authWithRedirect(opts: AuthUrlOptions): Promise;
+ exchangeCodeFromUrlForToken(
+ opts?: ExchangeCodeOptions
+ ): Promise;
}
const NylasContext = React.createContext(null);
-export const useNylas = (): NylasContextInterface => React.useContext(NylasContext) as NylasContextInterface;
+export const useNylas = (): NylasContextInterface =>
+ React.useContext(NylasContext) as NylasContextInterface;
-export default NylasContext;
\ No newline at end of file
+export default NylasContext;