Skip to content

Commit

Permalink
Merge pull request #2233 from exadel-inc/refactor/commit-lint-scope-v…
Browse files Browse the repository at this point in the history
…alidation

refactor(lint): add commit lint scope validation
  • Loading branch information
ala-n authored Feb 23, 2024
2 parents 68c13e8 + 41d311b commit 6788f89
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 27 deletions.
64 changes: 59 additions & 5 deletions .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,62 @@
extends:
- "@commitlint/config-conventional"
rules:
header-max-length: [1, 'always', 120]
body-max-length: [1, 'always', 150]
body-max-line-length: [1, 'always', 150]
footer-max-line-length: [1, 'always', 120]
subject-case: [1, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']]
header-max-length:
- 1
- always
- 120
body-max-length:
- 1
- always
- 150
body-max-line-length:
- 1
- always
- 150
footer-max-line-length:
- 1
- always
- 120
subject-case:
- 1
- never
-
- sentence-case
- start-case
- pascal-case
- upper-case
scope-enum:
- 2
- always
-
- esl-a11y-group
- esl-alert
- esl-animate
- esl-base-element
- esl-carousel
- esl-event-listener
- esl-footnotes
- esl-forms
- esl-image
- esl-media
- esl-media-query
- esl-mixin-element
- esl-open-state
- esl-panel
- esl-panel-group
- esl-popup
- esl-random-text
- esl-related-target
- esl-scrollbar
- esl-share
- esl-tab
- esl-toggleable
- esl-tooltip
- esl-traversing-query
- esl-trigger
- esl-utils
- site
- deps
- deps-dev
- lint
- e2e
18 changes: 13 additions & 5 deletions docs/COMMIT_CONVENTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,25 @@ BREAKING CHANGES:

### \<scope\>

Scope is an optional but "nice to have" part of your commit message.
Scope is highly recommended part of your commit message.

Use a scope to clarify changes area (module, component, feature or epic).
Using a scope enhances clarity and organization in commit messages, allowing for better categorization of changes.

Scope should be placed in parentheses after type but before `:`.
Utilize a scope to clarify the area of changes (module, component, feature, or epic).

The scope should be compatibly short and in lowercase.
The scope should be enclosed in parentheses after the type but before `:`.

The scope should be in lowercase.

```text
fix(esl-component): IE compatibility
fix(esl-utils): fix IE compatibility for scroll type detection
```

**Valid Scope Values**

To ensure consistency and clarity in commit messages, refer to
the [list of permissible scope values](https://github.com/exadel-inc/esl/blob/58095ed129ae6fcc0e1a2e32f099af36c090a176/.commitlintrc.yml).

---

### \<subject\>
Expand Down Expand Up @@ -163,3 +170,4 @@ Update of css rules order.
Close PR #123.
```

34 changes: 17 additions & 17 deletions src/modules/esl-event-listener/test/targets/swipe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ describe('ESLSwipeGestureTarget EventTarget', () => {

test('ESLResizeObserverTarget.for(undefined) returns null without error', () => {
expect(ESLSwipeGestureTarget.for(undefined as any)).toBeNull();
expect(consoleSpy).toBeCalled();
expect(consoleSpy).toHaveBeenCalled();
});

test('ESLResizeObserverTarget.for(null) returns null without error', () => {
expect(ESLSwipeGestureTarget.for(null as any)).toBeNull();
expect(consoleSpy).toBeCalled();
expect(consoleSpy).toHaveBeenCalled();
});

test('ESLResizeObserverTarget.for(123) returns null without error', () => {
expect(ESLSwipeGestureTarget.for(123 as any)).toBeNull();
expect(consoleSpy).toBeCalled();
expect(consoleSpy).toHaveBeenCalled();
});

test('ESLResizeObserverTarget.for({}) returns null without error', () => {
expect(ESLSwipeGestureTarget.for({} as any)).toBeNull();
expect(consoleSpy).toBeCalled();
expect(consoleSpy).toHaveBeenCalled();
});
});

Expand All @@ -38,24 +38,24 @@ describe('ESLSwipeGestureTarget EventTarget', () => {
const listener2 = jest.fn();

test('ESLSwipeGestureTarget does not produce subscription on creation', () => {
expect(addEventListenerSpy).not.toBeCalled();
expect(removeEventListenerSpy).not.toBeCalled();
expect(addEventListenerSpy).not.toHaveBeenCalled();
expect(removeEventListenerSpy).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget doesn`t unsubscribe old listeners upon adding new ones', () => {
target.addEventListener('swipe', listener1);
expect(addEventListenerSpy).toBeCalled();
expect(removeEventListenerSpy).not.toBeCalled();
expect(addEventListenerSpy).toHaveBeenCalled();
expect(removeEventListenerSpy).not.toHaveBeenCalled();
target.addEventListener('swipe', listener2);
expect(addEventListenerSpy).toBeCalled();
expect(removeEventListenerSpy).not.toBeCalled();
expect(addEventListenerSpy).toHaveBeenCalled();
expect(removeEventListenerSpy).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget doesn`t unsubscrie until last subscription is removed from target', () => {
target.removeEventListener('swipe', listener1);
expect(removeEventListenerSpy).not.toBeCalled();
expect(removeEventListenerSpy).not.toHaveBeenCalled();
target.removeEventListener('swipe', listener2);
expect(removeEventListenerSpy).toBeCalled();
expect(removeEventListenerSpy).toHaveBeenCalled();
});
});

Expand All @@ -70,7 +70,7 @@ describe('ESLSwipeGestureTarget EventTarget', () => {
};

const $el = document.createElement('div');
const target = ESLSwipeGestureTarget.for($el, {timeout: 50});
const target = ESLSwipeGestureTarget.for($el, {timeout: 150});
const listener = jest.fn();

beforeAll(() => target.addEventListener('swipe', listener));
Expand Down Expand Up @@ -112,25 +112,25 @@ describe('ESLSwipeGestureTarget EventTarget', () => {
test('ESLSwipeGestureTarget ignores short horizontal swipes', async () => {
$el.dispatchEvent(createEvent(START_EVENT, {pageX: 100, pageY: 100}));
window.dispatchEvent(createEvent(END_EVENT, {pageX: 110, pageY: 105, target: $el}));
expect(listener).not.toBeCalled();
expect(listener).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget ignores short vertical swipes', async () => {
$el.dispatchEvent(createEvent(START_EVENT, {pageX: 100, pageY: 100}));
window.dispatchEvent(createEvent(END_EVENT, {pageX: 105, pageY: 110, target: $el}));
expect(listener).not.toBeCalled();
expect(listener).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget ignores long - lasting swipe', async () => {
$el.dispatchEvent(createEvent(START_EVENT, {pageX: 100, pageY: 100}));
await promisifyTimeout(150);
window.dispatchEvent(createEvent(END_EVENT, {pageX: 210, pageY: 105, target: $el}));
expect(listener).not.toBeCalled();
expect(listener).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget ignores unlinked events', async () => {
window.dispatchEvent(createEvent(END_EVENT, {pageX: 210, pageY: 105, target: $el}));
expect(listener).not.toBeCalled();
expect(listener).not.toHaveBeenCalled();
});

test('ESLSwipeGestureTarget processes diagonal swipes', async () => {
Expand Down

0 comments on commit 6788f89

Please sign in to comment.