Skip to content

Commit 16efb94

Browse files
authored
Merge pull request #21 from svelte-plugins/update
✨ refactor(lib): fix exports, add types, and support svelte 4
2 parents 925d916 + 12defda commit 16efb94

38 files changed

+4972
-8033
lines changed

.eslintrc.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
2-
"parser": "@babel/eslint-parser",
3-
"parserOptions": {
4-
"ecmaVersion": 2019,
5-
"sourceType": "module"
6-
},
72
"env": {
8-
"es6": true,
3+
"es2017": true,
94
"commonjs": true,
10-
"browser": true,
11-
"node": true,
12-
"jest/globals": true
5+
"node": true
136
},
14-
"plugins": [
15-
"jest",
16-
"svelte3"
17-
],
18-
"extends": [
19-
"eslint:recommended"
20-
],
21-
"ignorePatterns": [
22-
"dist",
23-
"lib"
24-
],
7+
"parserOptions": {
8+
"ecmaVersion": 2020,
9+
"sourceType": "module"
10+
},
11+
"plugins": ["vitest"],
12+
"extends": ["eslint:recommended", "plugin:vitest/recommended"],
13+
"ignorePatterns": ["**/*.snap.js"],
2514
"overrides": [
2615
{
27-
"files": [
28-
"src/**/*.svelte"
29-
],
30-
"processor": "svelte3/svelte3"
16+
"files": ["*.ts"],
17+
"parser": "@typescript-eslint/parser"
18+
},
19+
{
20+
"files": ["*.svelte"],
21+
"parser": "svelte-eslint-parser"
3122
}
32-
]
23+
],
24+
"rules": {
25+
"eqeqeq": "error",
26+
"no-useless-escape": "off",
27+
"no-unused-expressions": "off",
28+
"no-inner-declarations": "off",
29+
"no-unused-vars": "off",
30+
"no-self-assign": "off",
31+
"no-undef": "off"
32+
}
3333
}

.github/workflows/integration.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,41 @@ on:
33
push:
44
branches:
55
- main
6+
paths:
7+
- src/**
68
pull_request:
79
types: [opened, synchronize, reopened]
810
jobs:
9-
build:
11+
tests:
1012
runs-on: ubuntu-latest
13+
name: Tests
14+
if: |
15+
(
16+
!contains(github.event.head_commit.message, '[skip ci]') &&
17+
!contains(github.event.head_commit.message, 'version bump')
18+
)
1119
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
14-
with:
15-
node-version: '12.x'
16-
registry-url: 'https://registry.npmjs.org'
17-
- run: yarn
18-
- run: yarn install:docs
19-
- run: yarn test:integration
20-
- uses: actions/upload-artifact@v2
21-
if: failure()
22-
with:
23-
name: integration-tests
24-
path: ${{ github.workspace }}/tests/artifacts/
25-
retention-days: 5
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v2
24+
with:
25+
version: 8.11
26+
- name: Install Node
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 20
30+
cache: 'pnpm'
31+
registry-url: 'https://registry.npmjs.org'
32+
- name: Install dependencies
33+
run: pnpm install
34+
- name: Install Playwright Browsers
35+
run: pnpm exec playwright install --with-deps
36+
- name: Run tests
37+
run: pnpm test:integration
38+
- uses: actions/upload-artifact@v3
39+
if: always()
40+
with:
41+
name: playwright-report
42+
path: playwright-report/
43+
retention-days: 5

.github/workflows/unit.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,44 @@ on:
33
push:
44
branches:
55
- main
6+
paths:
7+
- src/**
68
pull_request:
79
types: [opened, synchronize, reopened]
810
jobs:
9-
build:
11+
tests:
1012
runs-on: ubuntu-latest
13+
name: Tests
14+
if: |
15+
(
16+
!contains(github.event.head_commit.message, '[skip ci]') &&
17+
!contains(github.event.head_commit.message, 'version bump')
18+
)
1119
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
14-
with:
15-
node-version: '12.x'
16-
registry-url: 'https://registry.npmjs.org'
17-
- run: yarn
18-
- run: yarn test
19-
- uses: actions/upload-artifact@v2
20-
if: failure()
21-
with:
22-
name: unit-tests
23-
path: ${{ github.workspace }}/coverage/
24-
retention-days: 5
25-
- uses: codecov/[email protected]
26-
with:
27-
token: ${{ secrets.CODECOV_TOKEN }}
28-
directory: ${{ github.workspace }}/coverage/
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v2
24+
with:
25+
version: 8.11
26+
- name: Install Node
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 20
30+
cache: 'pnpm'
31+
registry-url: 'https://registry.npmjs.org'
32+
- name: Install dependencies
33+
run: pnpm install
34+
- name: Run tests
35+
run: pnpm test
36+
- name: Upload artifacts
37+
uses: actions/upload-artifact@v2
38+
if: failure()
39+
with:
40+
name: unit-tests
41+
path: ${{ github.workspace }}/coverage/
42+
retention-days: 5
43+
- uses: codecov/[email protected]
44+
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
directory: ${{ github.workspace }}/coverage/

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
!.lintstagedrc
1717
!.husky
1818
!.storybook
19+
!.vercel
1920

2021
# generated
21-
.vercel
2222
/node_modules
23-
/lib
2423
/dist
2524

2625
# testing
2726
coverage
2827
artifacts
28+
test-results
29+
playwright-report

.lintstagedrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"./src/**/*.{js,svelte,md,mdx,json}": ["eslint --fix", "prettier --write"]
2+
"./src/**/*.{test.js,js,ts,json,svelte}": [
3+
"svelte-check --tsconfig ./tsconfig.json",
4+
"eslint -c ./.eslintrc.json --fix",
5+
"prettier --write"
6+
]
37
}

.prettierrc.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 180,
2+
"printWidth": 120,
33
"trailingComma": "none",
44
"tabWidth": 2,
55
"semi": true,
@@ -9,5 +9,14 @@
99
"svelteSortOrder": "options-scripts-markup-styles",
1010
"svelteStrictMode": false,
1111
"svelteBracketNewLine": true,
12-
"svelteAllowShorthand": true
12+
"svelteAllowShorthand": true,
13+
"plugins": ["prettier-plugin-svelte"],
14+
"overrides": [
15+
{
16+
"files": "*.svelte",
17+
"options": {
18+
"parser": "svelte"
19+
}
20+
}
21+
]
1322
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.0](https://github.com/svelte-plugins/svelte-viewable/releases/tag/v2.0.0) - 2024-02-13
9+
810
## [1.0.0](https://github.com/svelte-plugins/svelte-viewable/releases/tag/v1.0.0) - 2021-04-02
911

1012
- Interface changes that include exposing observer props and events

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
# @svelte-plugins/viewable
66

7-
A simple rule-based approach to tracking element viewability.
7+
A simple rule-based approach to tracking element viewability.
88

9-
This provides the ability to define multiple viewability rules with callbacks for a single element. This comes in handy for instrumentation (specifically dwell time), ad tracking and beaconing, lazy-loading content or images, or doing fancy things at various trigger points.
9+
This provides the ability to define multiple viewability rules with callbacks for a single element. This comes in handy for instrumentation (specifically dwell time), ad tracking and beaconing, lazy-loading content or images, or doing fancy things at various trigger points.
1010

1111
If you're simply looking for a Svelte flavor of IntersectionObserver visit [svelte-intersection-observer](https://github.com/metonym/svelte-intersection-observer).
1212

@@ -15,11 +15,14 @@ Try it in the [Svelte REPL](https://svelte.dev/repl/47fe04909fd14ee5ad5d02390cc1
1515
## Install
1616

1717
```bash
18-
yarn add -D @svelte-plugins/viewable
18+
# npm
19+
> npm install @svelte-plugins/viewable
1920

20-
# or with NPM
21+
# pnpm
22+
> pnpm install @svelte-plugins/viewable
2123

22-
npm i -D @svelte-plugins/viewable
24+
# yarn
25+
> yarn add @svelte-plugins/viewable
2326
```
2427

2528
## Usage

babel.config.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

cypress.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
},
99
"devDependencies": {
1010
"@svelte-plugins/viewable": "../",
11-
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.5",
12-
"autoprefixer": "^10.2.5",
11+
"@sveltejs/vite-plugin-svelte": "^3.0.1",
12+
"autoprefixer": "^10.4.16",
1313
"postcss": "^8.2.8",
14-
"svelte": "^3.35.0",
15-
"vite": "^2.1.3"
14+
"svelte": "^4.2.8",
15+
"vite": "^5.0.12"
1616
}
1717
}

0 commit comments

Comments
 (0)