Skip to content

Commit

Permalink
Merge pull request #5 from Flagsmith/chore/add-linting
Browse files Browse the repository at this point in the history
chore: add linting
  • Loading branch information
dabeeeenster authored Apr 29, 2024
2 parents 413db03 + 1f93eb5 commit a3dd3c1
Show file tree
Hide file tree
Showing 18 changed files with 10,082 additions and 9,953 deletions.
27 changes: 27 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017,
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["react-hooks"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"react-hooks/rules-of-hooks": "error",
"react/display-name": "off"
},
"settings": {
"react": {
"version": "17"
}
}
}
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint with pre-commit

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
hooks:
- id: prettier

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.55.0
hooks:
- id: eslint
additional_dependencies:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
exclude: |
(?x)^(
package.json|
tests/.*
)$
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package.json
package-lock.json
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 100
}
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ suggesting the next steps.

### A couple things to keep in mind

- Please check your files for styling with pre-commit (`pre-commit install` in the root of the repo).
- If you've changed APIs, update the documentation.
- Keep the code style (indents, wrapping) consistent.
- If your PR involves a lot of commits, squash them using `git rebase -i` as this makes it easier for us to review.
Expand Down
20 changes: 15 additions & 5 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
Copyright 2023 Bullet Train Ltd

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Flagsmith Jira Integration

This repository contains an outer folder to install and configure the Forge CLI with an inner folder containing the Jira app itself.
This repository contains an outer folder to install and configure the Forge CLI with an inner folder containing the Jira
app itself.

See [developer.atlassian.com/platform/forge](https://developer.atlassian.com/platform/forge) for documentation and tutorials explaining Forge.
See [developer.atlassian.com/platform/forge](https://developer.atlassian.com/platform/forge) for documentation and
tutorials explaining Forge.

## Architectural Decisions

See [docs/decisions/README.md](docs/decisions/README.md) for decision records.

## Forge CLI installation

The following steps reflect the usual [Getting started](https://developer.atlassian.com/platform/forge/getting-started/) instructions but diverge for reproducability and portability reasons.
The following steps reflect the usual [Getting started](https://developer.atlassian.com/platform/forge/getting-started/)
instructions but diverge for reproducability and portability reasons.

### Before you begin

Expand All @@ -19,14 +22,17 @@ Forge CLI requires [Docker](https://docs.docker.com/get-docker/) and Node.js 20
- [Apple macOS](https://developer.atlassian.com/platform/forge/installing-forge-on-macos)
- [Linux](https://developer.atlassian.com/platform/forge/installing-forge-on-linux)

Forge recommend installing Node using using [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) but [asdf](https://asdf-vm.com/) also works.
Ensure you are using the correct Node.js version before executing any other commands:
Forge recommend installing Node using using [nvm](https://github.com/nvm-sh/nvm#installing-and-updating) but
[asdf](https://asdf-vm.com/) also works. Ensure you are using the correct Node.js version before executing any other
commands:

nvm use

### Install the Forge CLI

Forge instructions start by [installing the CLI globally](https://developer.atlassian.com/platform/forge/getting-started/#install-the-forge-cli) but instead we will use a local installation with pinned requirements:
Forge instructions start by
[installing the CLI globally](https://developer.atlassian.com/platform/forge/getting-started/#install-the-forge-cli) but
instead we will use a local installation with pinned requirements:

npm ci

Expand All @@ -42,17 +48,20 @@ Create an Atlassian API token to log in to the CLI. The CLI uses your token when
1. Click Create.
1. Click Copy to clipboard and close the dialog.

The `forge login` command attempts to store credentials in your operating system keychain and may not work on all platforms. Instead, we can skip this command and set environment variables instead.
The `forge login` command attempts to store credentials in your operating system keychain and may not work on all
platforms. Instead, we can skip this command and set environment variables instead.

### Using environment variables to login

Copy `.env-example` to `.env` and complete your Atlassian account email address and API token.

If you use [direnv](https://direnv.net/) these values should be picked up automatically. Alternatively use the activate script:
If you use [direnv](https://direnv.net/) these values should be picked up automatically. Alternatively use the activate
script:

source <(./bin/activate)

This reads `.env` values into your shell environment and also sets an alias so you can execute Forge CLI commands by typing `forge` without needing an `npx` prefix or to or mess with your path variable.
This reads `.env` values into your shell environment and also sets an alias so you can execute Forge CLI commands by
typing `forge` without needing an `npx` prefix or to or mess with your path variable.

Check installation and authentication by typing e.g.:

Expand Down
31 changes: 17 additions & 14 deletions docs/decisions/0001-use-atlassian-forge.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# Use Atlassian Forge

* Status: Accepted
- Status: Accepted

## Context and Problem Statement

Need to choose a development platform which allows UI modules to be added to Jira and to be distributed as an app in the Atlassian Marketplace.
Need to choose a development platform which allows UI modules to be added to Jira and to be distributed as an app in the
Atlassian Marketplace.

## Decision Drivers

* Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which can be iterated on later.
- Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which
can be iterated on later.

## Considered Options

* Atlassian Forge (newer mechanism, app hosted by Atlassian)
* Atlassian Connect (older mechanism, iframe only, app hosted by Flagsmith)
- Atlassian Forge (newer mechanism, app hosted by Atlassian)
- Atlassian Connect (older mechanism, iframe only, app hosted by Flagsmith)

## Decision Outcome

Chosen option: "Atlassian Forge", because it allows for faster development of an app that meets requirements with capacity to scale to meet future requirements.
Chosen option: "Atlassian Forge", because it allows for faster development of an app that meets requirements with
capacity to scale to meet future requirements.

### Positive Consequences

* Use of recommended platform with roadmap
* Built-in authentication, sandboxing, and hosting environments
* Built-in console to manage, distribute, and monitor apps
* CLI tooling for testing, deployment and installation
* Allows for Connect-style iframe apps if required
- Use of recommended platform with roadmap
- Built-in authentication, sandboxing, and hosting environments
- Built-in console to manage, distribute, and monitor apps
- CLI tooling for testing, deployment and installation
- Allows for Connect-style iframe apps if required

### Negative Consequences

* Limited to JavaScript/TypeScript but that is the UI stack we use anyway
* Less control over (but less responsibility for) hosting as it is provided by Atlassian
- Limited to JavaScript/TypeScript but that is the UI stack we use anyway
- Less control over (but less responsibility for) hosting as it is provided by Atlassian

## Links

* https://developer.atlassian.com/developer-guide/cloud-development-options/
- https://developer.atlassian.com/developer-guide/cloud-development-options/
32 changes: 18 additions & 14 deletions docs/decisions/0002-use-current-forge-runtime.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# Use Current Forge Runtime

* Status: Accepted
- Status: Accepted

## Context and Problem Statement

Need to choose a JavaScript runtime that executes the app code and provides libraries for Jira and Flagsmith REST API calls, storage, authorisation, etc.
Need to choose a JavaScript runtime that executes the app code and provides libraries for Jira and Flagsmith REST API
calls, storage, authorisation, etc.

## Decision Drivers

* Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which can be iterated on later.
- Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which
can be iterated on later.

## Considered Options

* Current runtime (limited Node.js 14, generally available)
* Native runtime (full Node.js 18, in preview)
- Current runtime (limited Node.js 14, generally available)
- Native runtime (full Node.js 18, in preview)

## Decision Outcome

Chosen option: "Current runtime", while avoiding falling into any of the breaking changes between the runtimes, i.e. use latest Forge libraries, set Content-Type on API calls, don't rely on snapshotting. This allows for faster, more reliable, development without ruling out a future change of runtime.
Chosen option: "Current runtime", while avoiding falling into any of the breaking changes between the runtimes, i.e. use
latest Forge libraries, set Content-Type on API calls, don't rely on snapshotting. This allows for faster, more
reliable, development without ruling out a future change of runtime.

### Positive Consequences

* Stability as preview releases are subject to change
* Reliable tunnelling as local environment is same as deployment environment
* Ability to use runtime features (e.g. debugging) not yet available in new runtime
* Avoids confusion between Forge CLI Node.js (20) and Runtime Node.js (18)
* Minimal obstacles to migrate to the new runtime later
- Stability as preview releases are subject to change
- Reliable tunnelling as local environment is same as deployment environment
- Ability to use runtime features (e.g. debugging) not yet available in new runtime
- Avoids confusion between Forge CLI Node.js (20) and Runtime Node.js (18)
- Minimal obstacles to migrate to the new runtime later

### Negative Consequences

* Potentially slower but should be fast enough, if not we can re-evaluate this decision
* Less Node features in the older runtime but we don't need them now
- Potentially slower but should be fast enough, if not we can re-evaluate this decision
- Less Node features in the older runtime but we don't need them now

## Links

* https://developer.atlassian.com/platform/forge/runtime-reference/native-nodejs-runtime/
- https://developer.atlassian.com/platform/forge/runtime-reference/native-nodejs-runtime/
39 changes: 22 additions & 17 deletions docs/decisions/0003-use-ui-kit.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
# Use UI Kit

* Status: Accepted
- Status: Accepted

## Context and Problem Statement

Need to choose a JavaScript library for UI components (text, tables, inputs, buttons, etc) and Jira UI (app settings, project settings, issue panel, menus, modals, etc).
Need to choose a JavaScript library for UI components (text, tables, inputs, buttons, etc) and Jira UI (app settings,
project settings, issue panel, menus, modals, etc).

## Decision Drivers

* Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which can be iterated on later.
- Overall requirement to quickly tick the box that Flagsmith has a Jira integration and offer MVP functionality which
can be iterated on later.

## Considered Options

* UI Kit (original Jira UI component library)
* UI Kit 2 (updated library, under development, in preview)
* Custom UI (provide own UI components, use bridge to Jira components)
- UI Kit (original Jira UI component library)
- UI Kit 2 (updated library, under development, in preview)
- Custom UI (provide own UI components, use bridge to Jira components)

## Decision Outcome

Chosen option: "UI Kit", because it offers the simplest route to developing an MVP UI without ruling out more complex UI in future. Keep UI and business logic code separate and avoid using withdrawn UI Kit features to minimise barriers to transition.
Chosen option: "UI Kit", because it offers the simplest route to developing an MVP UI without ruling out more complex UI
in future. Keep UI and business logic code separate and avoid using withdrawn UI Kit features to minimise barriers to
transition.

### Positive Consequences

* Stability as preview releases are subject to change
* Reduced complexity as UI Kit 2 requires new native runtime and splits execution between frontend and backend
* Reduced effort as UI Kit provides pre-built UI components styled to fit with Jira
* Greater compatibility as UI Kit is expected to work well with Jira styling features such as dark mode
* Minimal obstacles to migrate to UI Kit 2 later
- Stability as preview releases are subject to change
- Reduced complexity as UI Kit 2 requires new native runtime and splits execution between frontend and backend
- Reduced effort as UI Kit provides pre-built UI components styled to fit with Jira
- Greater compatibility as UI Kit is expected to work well with Jira styling features such as dark mode
- Minimal obstacles to migrate to UI Kit 2 later

### Negative Consequences

* Less control over UI, but assuming it looks no worse than competing integrations, that should meet requirements, if not we can re-evaluate this decision
- Less control over UI, but assuming it looks no worse than competing integrations, that should meet requirements, if
not we can re-evaluate this decision

## Links

* https://developer.atlassian.com/platform/forge/ui-kit-components/
* https://developer.atlassian.com/platform/forge/ui-kit-2/
* https://developer.atlassian.com/platform/forge/custom-ui/iframe/
* https://trello.com/b/z2GIJ3xD/forge-roadmap-for-developers
- https://developer.atlassian.com/platform/forge/ui-kit-components/
- https://developer.atlassian.com/platform/forge/ui-kit-2/
- https://developer.atlassian.com/platform/forge/custom-ui/iframe/
- https://trello.com/b/z2GIJ3xD/forge-roadmap-for-developers
8 changes: 4 additions & 4 deletions docs/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

This directory contains decision records for the Flagsmith for Jira app.

For new ADRs, please use [adr-template.md](adr-template.md) as basis.
More information on MADR is available at <https://adr.github.io/madr/>.
General information about architectural decision records is available at <https://adr.github.io/>.
For new ADRs, please use [adr-template.md](adr-template.md) as basis. More information on MADR is available at
<https://adr.github.io/madr/>. General information about architectural decision records is available at
<https://adr.github.io/>.

Built using <https://marketplace.visualstudio.com/items?itemName=StevenChen.vscode-adr-manager>
Built using <https://marketplace.visualstudio.com/items?itemName=StevenChen.vscode-adr-manager>
Loading

0 comments on commit a3dd3c1

Please sign in to comment.