Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup husky for pre-commit linting #889

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# skip in CI
[ -n "$CI" ] && exit 0

# lint commit message
pnpm commitlint --edit "$1"
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# skip in CI
[ -n "$CI" ] && exit 0

# lint commit message
pnpm lint-staged
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@

## Linting

Automatic linting via `husky` _pre-commit_ is setup. For manual linting use:

- `pnpm lint`
- `pnpm lint:fix`

## Formatting

Please stick to [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) messages to make our semantic release versioning work.

## Running tests

- `pnpm test` – Runs the test suite on the current Ember version
Expand Down
29 changes: 14 additions & 15 deletions docs/migration-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
ember-simple-auth-oidc v4 includes an upgrade to Ember v4 and Ember Simple
Auth v4, which entails the removal of the deprecated usage of mixins. This
results in a number of breaking changes, which are described in the following
sections. Refer to the [Ember Simple Auth](https://github.com/simplabs/ember-simple-auth)
and [Ember v4](https://blog.emberjs.com/the-road-to-ember-4-0/) documentation
sections. Refer to the [Ember Simple Auth](https://github.com/simplabs/ember-simple-auth)
and [Ember v4](https://blog.emberjs.com/the-road-to-ember-4-0/) documentation
for more information.

In addition, the access token is no longer refreshed through a timer-based
approach and requires an explicit refresh to ensure that the access token
hasn't expired. Although a refresh is ensured by the addon in certain
scenarios, the consuming application needs to be aware of these behavioral
scenarios, the consuming application needs to be aware of these behavioral
changes, especially when performing authorized requests.

## Mixin removal and replacement
Expand Down Expand Up @@ -84,7 +84,7 @@ requests first trigger an access token refresh, to ensure that the authorization
token is up-to-date. By default, the adapters simply provide the authorization
headers necessary to authorize the Ember Data requests. The headers are also
available through the session service and can be used when overriding the
adapter's headers. The provided adapters contain the necessary logic to handle
adapter's headers. The provided adapters contain the necessary logic to handle
401 responses appropriately.

```diff
Expand Down Expand Up @@ -115,21 +115,20 @@ For more information visit their [upgrade to v4 guide](https://github.com/simpla

## Proxy usage and IE11 support

The new implementation of `OIDCJSONAPIAdapter` and `OIDCRESTAdapter` include
the usage of [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
to ensure that an access token refresh is performed before issuing Ember Data
requests. When using these adapters and requiring IE11 support, a polyfill needs
The new implementation of `OIDCJSONAPIAdapter` and `OIDCRESTAdapter` include
the usage of [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
to ensure that an access token refresh is performed before issuing Ember Data
requests. When using these adapters and requiring IE11 support, a polyfill needs
to be provided.

## Access token refresh

Previous implementations included a timer-based access token refresh mechanism,
which ensured that the access token never expired as long as a valid refresh
token was available. The new implementation automatically refreshes the access
token before transitioning to an authenticated route and before issuing Ember
Data requests. When other kinds of authorized requests are performed, a token
refresh needs to be ensured before making the request, by performing the task
`session.refreshAuthentication` provided through the session service. This will
ensure that the access token is valid and will prevent any unnecessary 401
token was available. The new implementation automatically refreshes the access
token before transitioning to an authenticated route and before issuing Ember
Data requests. When other kinds of authorized requests are performed, a token
refresh needs to be ensured before making the request, by performing the task
`session.refreshAuthentication` provided through the session service. This will
ensure that the access token is valid and will prevent any unnecessary 401
responses.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"start": "ember serve",
"test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\"",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
"test:ember-compatibility": "ember try:each",
"prepare": "husky"
},
"dependencies": {
"@apollo/client": "^3.11.1",
Expand All @@ -46,6 +47,8 @@
"@adfinis/semantic-release-config": "5.0.0",
"@babel/eslint-parser": "7.25.1",
"@babel/plugin-proposal-decorators": "7.24.7",
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@ember/optional-features": "2.1.0",
"@ember/string": "4.0.0",
"@ember/test-helpers": "4.0.4",
Expand Down Expand Up @@ -79,6 +82,8 @@
"eslint-plugin-qunit": "8.1.2",
"graphql": "16.9.0",
"graphql-tag": "2.12.6",
"husky": "9.1.6",
"lint-staged": "15.2.10",
"loader.js": "4.7.0",
"miragejs": "0.1.48",
"prettier": "3.3.3",
Expand Down Expand Up @@ -113,5 +118,11 @@
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"*.js": "eslint --cache --fix",
"*.hbs": "ember-template-lint --fix",
"*.css": "stylelint --fix",
"*.{json,md}": "prettier --write"
}
}
Loading