8000 Better tooling by tajo · Pull Request #194 · tajo/react-range · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Better tooling #194

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

Merged
merged 3 commits into from
Jul 21, 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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "tajo/react-range" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/tidy-plants-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-range": patch
---

Better tooling
22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"react/prop-types": "off",
"react/react-in-jsx-scope": "off"
},
"settings": {
"react": {
"version": "detect"
}
}
}
7 changes: 5 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ on:
jobs:
test:
timeout-minutes: 15
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: pnpm/action-setup@v4
- name: Install dependencies
run: npm install -g pnpm && pnpm install
run: pnpm install
- name: Run Unit tests
run: pnpm test:unit
- name: Run Typecheck
run: pnpm typecheck
- name: Run Lint
run: pnpm lint
- name: Run Build
run: pnpm build
6 changes: 2 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ on:
branches: [main]
jobs:
test:
timeout-minutes: 60
runs-on: macos-latest
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: pnpm/action-setup@v4
with:
version: 9.1.4
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

on:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- uses: pnpm/action-setup@v4
with:
version: 9.1.4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20.14
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
email=vojtech@miksu.cz
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GIT_DEPLOY_KEY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec lint-staged
7 changes: 7 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"*.{js,ts,tsx,css,scss,postcss,md,json}": [
"prettier --write --plugin-search-dir=.",
"prettier --check --plugin-search-dir=."
],
"*.{js,ts,tsx}": "eslint"
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
[![npm version](https://img.shields.io/npm/v/react-range.svg?style=flat-square)](https://www.npmjs.com/package/react-range)
[![npm downloads](https://img.shields.io/npm/dm/react-range.svg?style=flat-square)](https://www.npmjs.com/package/react-range)
[![size](https://img.shields.io/bundlephobia/minzip/react-range.svg?style=flat)](https://bundlephobia.com/result?p=react-range)
<a href="https://stackblitz.com/edit/react-range-edit?file=src%2FApp.tsx"><img src="https://img.shields.io/badge/stackblitz-sandbox-orange" alt="stackblitz"></a>

![Labeled Range](https://raw.githubusercontent.com/tajo/react-range/main/assets/react-range.gif?raw=true)

[![Edit react-range](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/rlp1j1183n)

[See all the other examples](https://react-range.pages.dev) and [their source code](https://github.com/tajo/react-range/tree/main/examples)!
[See all the other examples](https://react-range.pages.dev) and [their source code](https://github.com/tajo/react-range/tree/main/examples)! Try it out in the [Stackblitz sandbox](https://stackblitz.com/edit/react-range-edit?file=src%2FApp.tsx)!

## Installation

Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
8 changes: 1 addition & 7 deletions e2e/marks.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { test, expect } from "@playwright/test";
import {
Examples,
getTestUrl,
trackMouse,
untrackMouse,
addFontStyles,
} from "./utils";
import { Examples, getTestUrl, addFontStyles } from "./utils";

test.beforeEach(async ({ page }) => {
await page.goto(getTestUrl(Examples.MARKS));
Expand Down
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
F438
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
25 changes: 1 addition & 24 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const untrackMouse = async (page: Page) => {
await page.waitForSelector(".mouse-helper", { state: "hidden" });
};

export const addFontStyles = async (page: Page) => {
export const addFontStyles = async () => {
//await page.evaluate(fontStyles);
};

Expand Down Expand Up @@ -152,29 +152,6 @@ const hideCursor = () => {
document.head.appendChild(styleElement);
};

// This injects a box into the page that moves with the mouse;
// Useful for debugging
const fontStyles = () => {
const styleElement = document.createElement("style");
styleElement.innerHTML = `
body {
color: #fff;
font-weight: normal;
font-style: normal;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
margin: 8px;
margin-top: 60px;
margin-left: 30px;
margin-right: 30px;
}
div[role='slider']:focus {
outline: none;
}
`;
document.head.appendChild(styleElement);
};

export const waitDropFinished = async (page: Page) => {
await page.waitForFunction(() => {
const sliders = document.querySelectorAll('[role="slider"]');
Expand Down
2 changes: 1 addition & 1 deletion examples/AllowOverlap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { Range, getTrackBackground } from "../src/index";
import { Range } from "../src/index";

const STEP = 0.1;
const MIN = 0;
Expand Down
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
},
"author": "Vojtech Miksu <vojtech@miksu.cz>",
"license": "MIT",
"packageManager": "pnpm@9.1.4",
"publishConfig": {
"access": "public",
"provenance": true
},
"sideEffects": false,
"scripts": {
"build": "rm -rf lib && tsc --outDir lib && rm -rf lib/examples && mv lib/src/* lib && rm -rf lib/src && rm lib/*.test.* && rm lib/*.stories.*",
"lint": "eslint '{examples,src,e2e,.ladle}/**/*.{js,ts,tsx,mjs}'",
"test": "pnpm test:e2e && pnpm test:unit",
"test:e2e": "pnpm exec playwright test",
"test:unit": "vitest run src",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"prepare": "husky",
"release": "pnpm run build && changeset publish"
},
"tags": [
"react"
Expand All @@ -32,14 +41,27 @@
"interval"
],
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@ladle/react": "^4.1.0",
"@playwright/test": "^1.45.1",
"@types/node": "^20.14.10",
"@types/node": "^20.14.11",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^6.13.0",
"@typescript-eslint/parser": "^6.13.0",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"husky": "^9.0.11",
"lint-staged": "^15.1.0",
"prettier": "^3.3.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.5.3",
"typescript": "5.3.2",
"vitest": "^2.0.3"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export default defineConfig({
/* Configure projects for major browsers */
projects: [
{
name: "firefox",
name: "chrome",
use: {
...devices["Desktop Firefox"],
...devices["Desktop Chrome"],
viewport: { width: 600, height: 460 },
},
},
Expand Down
Loading
0