Skip to content

Commit

Permalink
Update repo structure
Browse files Browse the repository at this point in the history
* switch from yarn to npm
* add storybook demo folder to test with a built version of the library
* move webpack related code to demo folder
* clean up (dev)dependencies of the main package
* remove cypress
* add github docs & publish workflows
* update eslint to muban config, and fix all issues
* ignore some eslint rules in the examples folder
* remove gsap
* export most used types from the package index
* move cjs build to /dist/cjs
* output declarations in dedicated folder
  • Loading branch information
ThaNarie committed Jan 3, 2022
1 parent 7a93997 commit 3c1d412
Show file tree
Hide file tree
Showing 141 changed files with 102,422 additions and 20,568 deletions.
172 changes: 3 additions & 169 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,178 +1,12 @@
var typeScriptSettings = {
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
'plugin:import/typescript',
'@muban/eslint-config',
],
rules: {
'@typescript-eslint/array-type': ['error', { default: 'generic', readonly: 'generic' }],
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
{
selector: 'parameter',
format: ['camelCase', 'PascalCase'],
},
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true, varsIgnorePattern: "Fragment" },
],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/prefer-readonly': 'error',
camelcase: 'off',
},
};

const reactSettings = {
// parserOptions: {
// ecmaFeatures: {
// jsx: true,
// },
// },
// extends: ['prettier/react'],
// rules: {
// // 'react/jsx-key': 2,
// 'react/jsx-no-comment-textnodes': 2,
// 'react/jsx-no-duplicate-props': 2,
// 'react/jsx-no-target-blank': 2,
// 'react/jsx-no-undef': 2,
// 'react/jsx-uses-react': 2,
// 'react/jsx-uses-vars': 2,
// 'react/jsx-boolean-value': 'error',
// 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
// 'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
// },
};

const mhtmlSettings = {
extends: ['plugin:lit/recommended', 'plugin:lit-a11y/recommended'],
rules: {
"lit/no-legacy-template-syntax": 'off',
"lit/no-private-properties": 'off',
"lit/no-property-change-update": 'off',
"lit/no-template-map": 'off',
"lit/binding-positions": 'off',
"lit/no-invalid-html": 'off',

// "lit/attribute-value-entities": 'off',
// "lit/no-duplicate-template-bindings": 'off',
// "lit/no-invalid-escape-sequences": 'off',
// "lit/no-template-arrow": 'off',
// "lit/no-template-bind": 'off',
// "lit/no-value-attribute": 'off',
}
}

module.exports = {
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.ts", "**/test-utils/**/*.ts"]}]
},
plugins: ['import', 'unicorn', 'babel', 'react', 'lit', 'lit-a11y'],
env: {
browser: true,
es6: true,
},
globals: {
require: true,
process: true,
},
settings: {
react: {
createClass: 'createReactClass', // Regex for Component Factory to use,
// default to "createReactClass"
pragma: 'createElement', // Pragma to use, default to "React"
version: 'detect', // React version. "detect" automatically picks the version you have installed.
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
// default to latest and warns if missing
// It will default to "detect" in the future
flowVersion: '0.53', // Flow version
},
},
rules: {
'no-console': 'warn',
},
overrides: [
{
files: ['*.ts'],
...typeScriptSettings,
...mhtmlSettings,
extends: [...typeScriptSettings.extends, ...mhtmlSettings.extends],
rules: {
...typeScriptSettings.rules,
...mhtmlSettings.rules,
},
},
{
files: ['*.tsx'],
...typeScriptSettings,
parserOptions: {
...typeScriptSettings.parserOptions,
...reactSettings.parserOptions,
},
rules: {
...typeScriptSettings.rules,
...reactSettings.rules,
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'variable',
// Exception for FunctionComponents
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'function',
// Exception for FunctionComponents
format: ['camelCase', 'PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
},
},
],
};
52 changes: 52 additions & 0 deletions .github/workflows/bump-version-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# NOTE: taken from https://github.com/MylesBorins/node-osc/blob/main/.github/workflows/bump-version.yml

name: Bump version, Tag & Publish

on:
workflow_dispatch:
inputs:
version:
description: 'Semver type of new version (major / minor / patch / prerelease)'
required: true
prereleaseid:
description: 'Prerelease id (rc)'
default: ''

jobs:
bump-version:
runs-on: ubuntu-latest

steps:
- name: Check out source
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'

- name: Install npm packages
run: npm ci

- name: Setup Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: bump version
run: |
npm version ${{ github.event.inputs.version }} --no-git-tag-version --preid ${{ github.event.inputs.prereleaseid }}
git add .
git commit -m "v$(npm pkg get version | tr -d '"')"
git tag $(npm pkg get version | tr -d '"') -m "v$(npm pkg get version | tr -d '"')"
- name: publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Push latest version
run: git push origin main --follow-tags
35 changes: 35 additions & 0 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Update Docs

on:
push:
branches: [main]

jobs:
update-docs:
runs-on: ubuntu-latest

steps:
- name: Check out source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'npm'

- name: Install npm packages
run: npm ci

- name: Build Docs
run: npm run docs:build

- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: docs/.vuepress/dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ yarn-error.log*
.eslintcache

# npm publish artifects
/lib
/dist
index.js
index.d.ts
/types
/tmp
/decl

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
16
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
16
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {

Create your story file:
```ts
import type { Story } from '@muban/storybook/dist/client/preview/types-6-0';
import type { Story } from '@muban/storybook/types-6-0';

export default {
title: 'MyComponent',
Expand Down
1 change: 0 additions & 1 deletion cypress.json

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/profile.json

This file was deleted.

Loading

0 comments on commit 3c1d412

Please sign in to comment.