Skip to content

Migrate project to React 18+ and TypeScript #106

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> 0.1%
not dead
27 changes: 0 additions & 27 deletions .eslintrc.js

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DS_Store
.vscode
.idea
node_modules/
.eslintcache
.cache
.parcel-cache
build
build-website
tmp
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 100,
"arrowParens": "avoid",
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "none"
}
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

32 changes: 32 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @ts-check
import eslintJs from '@eslint/js'
import eslintReact from '@eslint-react/eslint-plugin'
import tseslint from 'typescript-eslint'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import prettierrc from './.prettierrc.json' with { type: 'json' }

export default tseslint.config({
files: ['**/*.ts', '**/*.tsx'],
ignores: ['**/build/**', '**/build-website/**', '**/node_modules/**'],

extends: [
eslintJs.configs.recommended,
tseslint.configs.strictTypeChecked,
eslintReact.configs['recommended-type-checked'],
eslintPluginPrettierRecommended
],

languageOptions: {
parser: tseslint.parser,
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: 'tsconfig.eslint.json'
}
},

rules: {
'@typescript-eslint/no-confusing-void-expression': 'off',
"@typescript-eslint/no-unnecessary-condition": 'off',
'prettier/prettier': ['error', prettierrc]
}
})
117 changes: 0 additions & 117 deletions index.d.ts

This file was deleted.

13 changes: 13 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-check
import { createDefaultPreset } from 'ts-jest'

/** @type {import("jest").Config} **/
const config = {
...createDefaultPreset({
tsconfig: 'tsconfig.test.json'
}),
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/test/jest.setup.js']
}

export default config
120 changes: 71 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
"name": "react-nice-dates",
"version": "3.1.0",
"sideEffects": false,
"main": "build/index.js",
"module": "build/index.esm.js",
"unpkg": "build/index.umd.js",
"types": "build/index.d.ts",
"exports": {
".": {
"global": {
"types": "./build/index.d.ts",
"default": "./build/index.global.js"
},
"import": {
"types": "./build/index.d.mts",
"default": "./build/index.mjs"
},
"require": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
}
},
"./style.css": "./build/style.css",
"./style.scss": "./src/style.scss",
"./build/style.css": "./build/style.css",
"./src/style.scss": "./src/style.scss"
},
"author": "Hernán Sartorio",
"license": "MIT",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/hernansartorio/react-nice-dates.git"
Expand All @@ -17,63 +37,65 @@
"homepage": "https://github.com/hernansartorio/react-nice-dates#readme",
"files": [
"build",
"src/style.scss",
"index.d.ts"
"src/style.scss"
],
"scripts": {
"setup": "yarn && yarn deduplicate && cd website && yarn",
"deduplicate": "yarn-deduplicate yarn.lock",
"start": "parcel website/index.html -d tmp",
"build": "rollup -c && sass src/style.scss build/style.css --no-source-map && postcss build/style.css --use autoprefixer -o build/style.css",
"build:website": "rm -rf build-website/* && parcel build website/index.html -d build-website --experimental-scope-hoisting --no-content-hash && cp website/CNAME build-website/CNAME",
"clean:build": "rm -rf build",
"clean:build-website": "rm -rf build-website website/.parcel-cache",
"prebuild": "npx update-browserslist-db@latest && rm -rf build",
"build": "run-p build:ts build:css",
"build:ts": "tsup",
"build:css": "sass src/style.scss build/style.css --no-source-map && postcss build/style.css --use autoprefixer -o build/style.css",
"prebuild:website": "run-p clean:build-website build",
"build:website": "cd website && yarn && yarn build && cp CNAME favicon.png ../build-website/",
"deploy": "gh-pages -d build-website",
"lint": "eslint --cache --format codeframe src test website",
"dev:package": "tsup src/index.ts --watch",
"lint": "eslint src test --ext .ts,.tsx",
"release": "yarn run build && np",
"test": "jest",
"test:watch": "jest --watch"
},
"dependencies": {
"classnames": "^2.5.1"
},
"peerDependencies": {
"date-fns": "^2.0.0",
"prop-types": "^15",
"react": "^16",
"react-dom": "^16"
"date-fns": "^2 || ^3 || ^4",
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/preset-react": "^7.8.3",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-node-resolve": "^7.0.0",
"@testing-library/dom": "^6.11.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/react-hooks": "^3.2.1",
"@types/date-fns": "^2.6.0",
"autoprefixer": "^9.7.3",
"date-fns": "^2.9.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^2.3.0",
"eslint-plugin-standard": "^4.0.1",
"jest": "^24.9.0",
"parcel-bundler": "^1.12.4",
"parcel-plugin-prerender": "^1.4.1",
"postcss-cli": "^7.1.0",
"prism-react-renderer": "^1.0.2",
"prop-types": "^15",
"react": "^16",
"react-dom": "^16",
"react-test-renderer": "^16.12.0",
"rollup": "^1.29.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-sass": "^1.2.2",
"sass": "^1.25.0"
},
"dependencies": {
"classnames": "^2.2.6"
"@eslint-react/eslint-plugin": "^1.52.2",
"@eslint/js": "^9.30.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@types/jest": "^30.0.0",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.21",
"browserslist": "^4.25.1",
"date-fns": "^2.30.0",
"esbuild-plugin-browserslist": "^1.0.1",
"eslint": "^9.30.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-prettier": "^5.5.1",
"jest": "^30.0.3",
"jest-environment-jsdom": "^30.0.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.5.6",
"postcss-cli": "^11.0.1",
"prettier": "^3.6.2",
"react": "^18",
"react-dom": "^18",
"react-test-renderer": "^18.3.1",
"sass": "^1.89.2",
"ts-jest": "^29.4.0",
"tsup": "^8.5.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.35.0",
"yarn-deduplicate": "^6.0.2"
}
}
Loading