Skip to content

Commit

Permalink
Use committed ts lib template
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyelliot committed Nov 11, 2020
1 parent a317823 commit 78fec96
Show file tree
Hide file tree
Showing 40 changed files with 6,187 additions and 4,736 deletions.
28 changes: 28 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ steps:
ref:
- refs/tags/v*

- name: code-analysis
image: committed/drone-sonarqube-node
environment:
SONAR_HOST:
from_secret: sonar_host
SONAR_TOKEN:
from_secret: sonar_token
settings:
exclusions: '**/node_modules/**/*,**/dist/**/*.js'
when:
branch:
- master
event:
exclude:
- pull_request

- name: slack
image: plugins/slack
settings:
channel: group-ci
webhook:
from_secret: slack_webhook
template:
from_secret: slack_template
when:
status:
- failure

- name: announce
image: plugins/slack
settings:
Expand Down
118 changes: 118 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
ignorePatterns: ['setupTests.tsx','*.test.ts*', '*.stories.tsx'],
extends: [
// non-ts recommended rules
'eslint:recommended',
// remove non-ts rules covered by typescript-eslint
'plugin:@typescript-eslint/eslint-recommended',
// ts recommended rules
// can be slow
'plugin:@typescript-eslint/recommended',
// ts recommended rules that require tsconfig.json to be specified in parserOptions.project
// can be slow
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier/@typescript-eslint',

'plugin:react/recommended',
'plugin:security/recommended',
// remove rules covered by prettier
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
modules: true,
},
ecmaVersion: 2018,
sourceType: 'module',
project: ['./tsconfig.json'],
},
plugins: ['react', '@typescript-eslint'],
rules: {
"react/prop-types": 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
],
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-implied-eval': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-throw-literal': 'warn',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'warn',
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unused-vars-experimental': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-readonly': 'warn',
// Ideally this would be on, but it has too many false positives. Should apply to arrays but seems to apply to everything, potentially a bug
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'warn',
// require-await is incompatible with promise-function-async
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': [
'warn',
{
allowNumber: true,
allowBoolean: true,
allowNullable: false,
},
],
'@typescript-eslint/strict-boolean-expressions': 'warn',
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
// TODO: We use this in mocks in .spec.ts, perhaps syntax is incorrect?
'@typescript-eslint/unbound-method': 'off',
'react/jsx-pascal-case': [
'warn',
{
ignore: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'd1',
'd2',
'd3',
'd4',
'd5',
'd6',
],
},
],
},
}
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on: [push]
jobs:
build:
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['14.x']
os: [ubuntu-latest]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

- name: Lint
run: yarn lint

- name: Test
run: yarn test --ci --coverage --maxWorkers=2

- name: Build
run: yarn build
12 changes: 12 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: size
on: [pull_request]
jobs:
size:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v1
- uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 28 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
*.log
.DS_Store

# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules
.cache
.rts2_cache_cjs
.rts2_cache_esm
.rts2_cache_umd

# builds
build
dist
storybook-static
.rpt2_cache
lib
lib-esm
_bundles
docs

# misc
.cache
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.docz
.vscode
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.*
**/tsconfig.json
**/webpack.config.js
node_modules
src
stories
example
lib
lib-esm
_bundles
tsdx.config.js
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
dist

.rpt2_cache
lib
lib-esm
_bundles
docs
13 changes: 0 additions & 13 deletions .storybook/WithTheme.js

This file was deleted.

18 changes: 12 additions & 6 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
module.exports = {
stories: ['../src/stories/**/*.stories.(ts|tsx|mdx)'],
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/preset-typescript',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-docs',
'storybook-dark-mode'
]
{
name: '@storybook/addon-essentials',
options: {
backgrounds: false,
},
},
],
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
typescript: {
check: true, // type-check stories during Storybook build
}
}
9 changes: 5 additions & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { addDecorator } from '@storybook/react'
import { withTheme } from './WithTheme'

addDecorator(withTheme)
// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
export const parameters = {
// https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args
actions: { argTypesRegex: '^on.*' },
};
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ class Example extends React.Component {
{
offset: 4,
length: 7,
type: 'NORP'
type: 'NORP',
},
{
offset: 49,
length: 10,
type: 'ORG'
}
type: 'ORG',
},
]}
inlines={[
{
offset: 4,
length: 55,
type: 'Link'
}
type: 'Link',
},
]}
/>
)
Expand Down
10 changes: 5 additions & 5 deletions example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ const App = () => {
{
offset: 4,
length: 7,
type: 'NORP'
type: 'NORP',
},

{
offset: 49,
length: 10,
type: 'ORG'
}
type: 'ORG',
},
]}
inlines={[
{
offset: 4,
length: 55,
type: 'link'
}
type: 'link',
},
]}
/>
</ThemeProvider>
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scheduler/tracing": "../node_modules/scheduler/tracing-profiling"
},
"devDependencies": {
"@types/react": "^16.8.15",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.8.4",
"node-forge": "^0.10.0",
"parcel": "^1.12.4",
Expand Down
1 change: 0 additions & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"preserveConstEnums": true,
"sourceMap": true,
"lib": ["es2015", "es2016", "dom"],
"baseUrl": ".",
"types": ["node"]
}
}
Loading

0 comments on commit 78fec96

Please sign in to comment.