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

MOT & Support ESM #93

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
003c74b
feat: bring ci in line with our current standard
JoshTheWanderer Jan 29, 2024
097e076
feat: add megalinter
JoshTheWanderer Jan 29, 2024
0d0493b
feat: migrate mergify config to new standards
JoshTheWanderer Jan 29, 2024
e9d317c
feat: update supported node versions
JoshTheWanderer Jan 29, 2024
738faaf
docs: update example to be React 18 compatible
JoshTheWanderer Jan 29, 2024
4c54231
feat: bring into line with current lint setup
JoshTheWanderer Jan 29, 2024
01b53b2
style: linter auto-fixes
JoshTheWanderer Jan 29, 2024
e8a70c3
feat: add license
JoshTheWanderer Jan 29, 2024
99941db
feat: add automated releases
JoshTheWanderer Jan 30, 2024
2bdbee8
feat: update default branch
JoshTheWanderer Jan 30, 2024
9e38c0c
style: yaml lint cleanup
JoshTheWanderer Jan 30, 2024
e36ab28
fix: install dependencies so that megalinter can use our configs
JoshTheWanderer Jan 30, 2024
5a09e71
feat: disable js/ts standard linters
JoshTheWanderer Jan 30, 2024
726ba9a
feat: disable more unwanted linters
JoshTheWanderer Jan 30, 2024
cb8a423
feat: remove linting from test, as we now use megalinter
JoshTheWanderer Jan 30, 2024
59ae5f0
fix: actually disable linters
JoshTheWanderer Jan 30, 2024
c5ebacb
fix: remove build from prepare to speed up CI
JoshTheWanderer Jan 30, 2024
0727070
feat: ignore dist and set next pages folder path
JoshTheWanderer Jan 30, 2024
9c2cbc8
feat: force linter to use our configs
JoshTheWanderer Jan 30, 2024
4d8bf15
style: low-hanging linter fixes
JoshTheWanderer Jan 30, 2024
8787385
feat: add esm build
JoshTheWanderer Jan 30, 2024
86f546e
feat: add vscode settings
JoshTheWanderer Jan 30, 2024
9377b9c
fix: remove unneeded proptypes declaration
JoshTheWanderer Jan 30, 2024
331fb27
feat: remove unneeded react import
JoshTheWanderer Jan 30, 2024
b05b9ee
feat: upgrade caniuse-lite
JoshTheWanderer Jan 30, 2024
7c50f28
feat: remove unused dependencies
JoshTheWanderer Jan 30, 2024
8fb242c
fix: ignore dist
JoshTheWanderer Jan 30, 2024
9758553
feat: use local executable for stylelint
JoshTheWanderer Jan 30, 2024
9b2745f
feat: disable more unneeded linters
JoshTheWanderer Jan 30, 2024
449b102
fix: more fine-grained permissions for releases
JoshTheWanderer Jan 30, 2024
e18cf48
feat: lockdown permissions
JoshTheWanderer Jan 30, 2024
8bd5324
fix: sort out typing issues
JoshTheWanderer Jan 31, 2024
77456e4
feat: esmify configs
JoshTheWanderer Jan 31, 2024
bcfc53b
feat: switch to microbundle pure and upgrade typescript
JoshTheWanderer Jan 31, 2024
ea1f8c4
fix: add all the react bits we need to get microbundle compiling prop…
JoshTheWanderer Jan 31, 2024
7dfae16
feat: clean up example packages
JoshTheWanderer Jan 31, 2024
cf07b07
fix: use cjs files for example
JoshTheWanderer Jan 31, 2024
a521313
feat: consolidate eslint configs
JoshTheWanderer Jan 31, 2024
f0a8604
feat: esm by default
JoshTheWanderer Jan 31, 2024
4eec63f
feat: migrate from react-scripts, drop unneeded packages
JoshTheWanderer Jan 31, 2024
cd821d7
fix: workaround nextjs esm typing being broken
JoshTheWanderer Jan 31, 2024
ccaddf4
Revert "fix: workaround nextjs esm typing being broken"
JoshTheWanderer Feb 1, 2024
ea554b5
Merge branch 'main' into feat/support-esm
JoshTheWanderer Jul 3, 2024
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
6 changes: 1 addition & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
build/
dist/
node_modules/
.snapshots/
*.min.js
dist
28 changes: 0 additions & 28 deletions .eslintrc

This file was deleted.

9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["@etchteam"],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "example/pages/"]
},
"env": {
"jest": true
}
}
26 changes: 26 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
pull_request_rules:
- name: Automerge when checks pass and reviews are approved
conditions:
- and:
- author~=!^dependabot(|-preview)\[bot\]$
- label!=wontfix
- check-success=build
- check-success=test
- check-success=megalinter
- check-success=SonarCloud Code Analysis
- "#approved-reviews-by>=1"
actions:
merge:
method: merge
- name: Automerge security updates when checks pass
conditions:
- author~=^dependabot(|-preview)\[bot\]$
- label!=wontfix
- check-success=build
- check-success=test
- check-success=megalinter
- check-success=SonarCloud Code Analysis
actions:
merge:
method: merge
9 changes: 9 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Always validate the PR title AND all the commits
titleAndCommits: true
# Allows use of Merge commits (eg on github: "Merge branch 'main' into feature/ride-unicorns")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowMergeCommits: true
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowRevertCommits: true
43 changes: 31 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
---
name: CI

on:
push:
pull_request:

branches:
- main
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
strategy:
matrix:
version: [18, 20]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
cache: 'npm'
- run: npm ci
- run: npm test
build:
strategy:
matrix:
version: [18, 20]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.18.1
cache: 'npm'
- run: npm ci --no-audit --prefer-offline
- run: npm run build
- run: npm test
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
cache: 'npm'
- run: npm ci
- run: npm run build
34 changes: 34 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: MegaLinter
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
megalinter:
name: MegaLinter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/[email protected]
id: ml
env:
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: 🚀 Publish
on:
push:
branches:
- main
env:
HUSKY: 0
permissions:
contents: write
issues: write
pull-requests: write
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ yarn-debug.log*
yarn-error.log*

.next

megalinter-reports/
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- lint-staged
46 changes: 46 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configuration file for MegaLinter
#
# See all available variables at https://megalinter.io/latest/config-file/ and in
# linters documentation

# all, none, or list of linter keys
APPLY_FIXES: none

# If you use ENABLE variable, all other languages/formats/tooling-formats will
# be disabled by default
# ENABLE:

# If you use ENABLE_LINTERS variable, all other linters will be disabled by
# default
# ENABLE_LINTERS:

DISABLE:
- COPYPASTE
- SPELL

DISABLE_LINTERS:
# Disable scss-lint in favour of stylelint
- CSS_SCSS_LINT
# Disable standard style linters in favour of eslint
- JAVASCRIPT_STANDARD
- TYPESCRIPT_STANDARD
# Not needed in this repository
- REPOSITORY_TRIVY
# We have secret scanning enabled and set to block pushes with secrets
- REPOSITORY_GITLEAKS
# We use dependabot for vulnerability monitoring and patching
- REPOSITORY_GRYPE

SHOW_ELAPSED_TIME: true

FILEIO_REPORTER: false

# Uncomment if you want MegaLinter to detect errors but not block CI to pass
# DISABLE_ERRORS: true

# Config paths
CSS_STYLELINT_CONFIG_FILE: stylelint.config.js
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.json

# Override linter executables
CSS_STYLELINT_CLI_EXECUTABLE: ['./node_modules/.bin/stylelint']
30 changes: 0 additions & 30 deletions .mergify.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.1
20.11.0
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

5 changes: 5 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
*.*
!*.css
!*.scss
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
},
"sonarlint.connectedMode.project": {
"connectionId": "etchteam",
"projectKey": "etchteam_next-pagination"
}
}
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ISC License

Copyright 2023 Etch Software Limited

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ npm install --save @etchteam/next-pagination
This component is fairly self contained. You will need to pass the **total number of potential results** in order to calculate the number of pages to show.

```jsx
import React, { Component } from 'react'
import { Component } from 'react'

import Pagination from '@etchteam/next-pagination'

Expand Down
5 changes: 5 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
extends: ['@commitlint/config-conventional'],
};

export default config;
11 changes: 4 additions & 7 deletions example/next.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const withSourceMaps = require('@zeit/next-source-maps')()
const isProd = (process.env.NODE_ENV || 'production') === 'production';

const isProd = (process.env.NODE_ENV || 'production') === 'production'

module.exports = withSourceMaps({
module.exports = {
assetPrefix: isProd ? '/next-pagination' : undefined,
basePath: isProd ? '/next-pagination' : undefined
})
basePath: isProd ? '/next-pagination' : undefined,
};
Loading
Loading