Skip to content

Commit

Permalink
chore: update linter, prettier configs (storacha#380)
Browse files Browse the repository at this point in the history
Per storacha#296, update linter configs to match https://github.com/web3-storage/w3protocol, minus prettier because it wouldn't stop having bare knuckle boxing matches with eslint that I got sick of mediating.

Use @hugomrdias's `hd-scripts` configs, but turn off a few eslint rules
that either a) I didn't like (no-negated-conditions, no-null) or b) feel
duplicative in TypeScript (all of the jsdoc rules). Also turn off
`import/extensions` because as far as I can tell it recommends the wrong
thing. Without disabling these rules I got errors like this:

<img width="971" alt="Screenshot 2023-02-07 at 4 32 03 PM"
src="https://user-images.githubusercontent.com/1113/217206052-f8c9422a-8a86-45bc-8902-b255515f63e3.png">

I'm definitely open to leaving some of these on if anyone likes them.
  • Loading branch information
travis authored Feb 16, 2023
1 parent 0bd21fb commit 116a6d8
Show file tree
Hide file tree
Showing 106 changed files with 2,286 additions and 1,123 deletions.
3 changes: 1 addition & 2 deletions .github/actions/pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: pnpm
description: 'Setup node & pnpm'

runs:
using: "composite"
using: 'composite'
steps:
- uses: pnpm/action-setup@v2
with:
Expand All @@ -15,4 +15,3 @@ runs:
node-version: 18
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'

5 changes: 2 additions & 3 deletions .github/actions/preview/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ outputs:
value: ${{ steps.set_summary.outputs.summary }}

runs:
using: "composite"
using: 'composite'
steps:
- name: Add to web3.storage
uses: web3-storage/add-to-web3@v2
id: ipfs
with:
path_to_add: ${{ inputs.path_to_add }}
web3_token: ${{ inputs.web3_token }}

- name: Update IPFS DNSLink
if: inputs.dnslink_domain != '' && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npx dnslink-cloudflare --record ${{ inputs.dnslink_record }} --domain ${{ inputs.dnslink_domain }} --link /ipfs/${{ steps.ipfs.outputs.cid }}
Expand Down Expand Up @@ -78,4 +78,3 @@ runs:
core.setOutput('summary', `### Website preview 🔗✨
- 🙂 https://w3s.link/ipfs/${{ steps.ipfs.outputs.cid }}
- ⛅️ ${{ steps.cloudflare_url.outputs.stdout }}`)
19 changes: 11 additions & 8 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ module.exports = {
modules: false,
exclude: [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-parameters'
]
}
'@babel/plugin-transform-parameters',
],
},
],
'@babel/preset-typescript',
'@babel/preset-react'
'@babel/preset-react',
],
env: {
test: {
plugins: [
// everything needs to be cjs for jest
['@babel/plugin-transform-modules-commonjs', { loose: true, importInterop: 'node' }]
]
}
}
[
'@babel/plugin-transform-modules-commonjs',
{ loose: true, importInterop: 'node' },
],
],
},
},
}
23 changes: 23 additions & 0 deletions eslint.packages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
extends: ['./node_modules/hd-scripts/eslint/ts.js'],
parserOptions: {
project: './tsconfig.json',
ecmaFeatures: {
jsx: true,
},
},
env: {},
globals: {},
rules: {
'unicorn/prefer-number-properties': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/no-null': 'off',
'unicorn/prefer-export-from': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-useless-undefined': 'off',
'jsdoc/require-param': 'off',
'jsdoc/newline-after-description': 'off',
'jsdoc/require-param-type': 'off',
'import/extensions': 'off'
},
}
2 changes: 1 addition & 1 deletion examples/react/file-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"@vitejs/plugin-react": "^3.0.0",
"vite": "^4.0.0"
}
}
}
4 changes: 2 additions & 2 deletions examples/react/file-upload/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
base: '',
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
4 changes: 2 additions & 2 deletions examples/react/multi-file-upload/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
base: '',
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
8 changes: 4 additions & 4 deletions examples/react/playground/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
backgrounds: {
default: 'dark'
}
}
default: 'dark',
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export default {
title: 'w3ui/Authenticator',
component: AuthenticationSubmitted,
tags: ['autodocs'],
argTypes: {
}
argTypes: {},
}

export const Submitted = {
args: {
}
args: {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export default {
title: 'w3ui/Authenticator',
component: Authenticator,
tags: ['autodocs'],
argTypes: {
}
argTypes: {},
}

export const Primary = {
args: {
}
args: {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export default {
title: 'w3ui/SpaceCreator',
component: SpaceCreator,
tags: ['autodocs'],
argTypes: {
}
argTypes: {},
}

export const Primary = {
args: {
}
args: {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ export default {
title: 'w3ui/SpaceCreator',
component: SpaceCreatorCreating,
tags: ['autodocs'],
argTypes: {
}
argTypes: {},
}

export const Creating = {
args: {
}
args: {},
}
18 changes: 10 additions & 8 deletions examples/react/playground/src/stories/SpaceFinder.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ export default {
component: SpaceFinder,
tags: ['autodocs'],
argTypes: {
setSelected: { action: 'set space' }
}
setSelected: { action: 'set space' },
},
}

const spaces = ['did:example:abc123', 'did:example:xyz789', 'did:example:lmn456'].map(
(did: string, i) => new Space(did as DID, { name: `Space ${i}` })
)
const spaces = [
'did:example:abc123',
'did:example:xyz789',
'did:example:lmn456',
].map((did: string, i) => new Space(did as DID, { name: `Space ${i}` }))

export const Primary = {
args: {
spaces,
selected: spaces[0]
selected: spaces[0],
},
decorators: [
(Story) => (
<div style={{ margin: '3em' }}>
<Story />
</div>
)
]
),
],
}
10 changes: 3 additions & 7 deletions examples/react/playground/src/stories/Uploader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ export default {
title: 'w3ui/Uploader',
component: Uploader,
tags: ['autodocs'],
argTypes: {
},
parameters: {

}
argTypes: {},
parameters: {},
}

export const Primary = {
args: {
}
args: {},
}
38 changes: 24 additions & 14 deletions examples/react/playground/src/stories/UploadsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,63 @@ import '@w3ui/react/src/styles/uploads-list.css'
export default {
title: 'w3ui/UploadsList',
component: UploadsList,
tags: ['autodocs']
tags: ['autodocs'],
}

// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
export const Empty = {
render: () => {
const state = { data: [], loading: false }
const actions = {
next: async (): Promise<void> => { },
reload: async (): Promise<void> => { }
next: async (): Promise<void> => {},
reload: async (): Promise<void> => {},
}
return (
<UploadsListContext.Provider value={[state, actions]}>
<UploadsList />
</UploadsListContext.Provider>
)
}
},
}

export const OneItem = {
render: () => {
const state = { data: [{ root: Link.parse('QmPr755CxWUwt39C2Yiw4UGKrv16uZhSgeZJmoHUUS9TSJ') }], loading: false }
const state = {
data: [
{ root: Link.parse('QmPr755CxWUwt39C2Yiw4UGKrv16uZhSgeZJmoHUUS9TSJ') },
],
loading: false,
}
const actions = {
next: async (): Promise<void> => { console.log('NEXT') },
reload: async (): Promise<void> => { }
next: async (): Promise<void> => {
console.log('NEXT')
},
reload: async (): Promise<void> => {},
}
return (
<UploadsListContext.Provider value={[state, actions]}>
<UploadsList />
</UploadsListContext.Provider>
)
}
},
}

export const OneHundredItems = {
render: () => {
const state = { data: oneHundredCids.map(root => ({ root })), loading: false }
const state = {
data: oneHundredCids.map((root) => ({ root })),
loading: false,
}
const actions = {
next: async (): Promise<void> => { },
reload: async (): Promise<void> => { }
next: async (): Promise<void> => {},
reload: async (): Promise<void> => {},
}
return (
<UploadsListContext.Provider value={[state, actions]}>
<UploadsList />
</UploadsListContext.Provider>
)
}
},
}

/* commenting because currently unused but potentially useful soon
Expand Down Expand Up @@ -175,5 +185,5 @@ const oneHundredCids = [
'bafkreiaivicxyj4zanjcvtkn2csw2eyr2zhdu3pk7r7xsdrmgv2yjzfwp4',
'bafkreidvyaevch6silpmqqd5gmacqdpy3ujwxcsjnbukhitpn6eclfpfse',
'bafkreicebeagd3i4yxxsoxpfmibq3t6ebx2evab2xlitsqabdzptae6o4m',
'bafkreids7gwr2igplug6lluxzjmj7l7cy63ckmabhfaciy62zqtw4telyy'
].map(cid => Link.parse(cid))
'bafkreids7gwr2igplug6lluxzjmj7l7cy63ckmabhfaciy62zqtw4telyy',
].map((cid) => Link.parse(cid))
4 changes: 2 additions & 2 deletions examples/react/playground/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
4 changes: 2 additions & 2 deletions examples/react/sign-up-in/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
base: '',
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
4 changes: 2 additions & 2 deletions examples/react/template/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
base: '',
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
1 change: 0 additions & 1 deletion examples/react/uploads-list/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@w3ui/example-react-uploads-list",

"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/uploads-list/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
base: '',
plugins: [react()],
server: {
port: 3000
}
port: 3000,
},
})
2 changes: 1 addition & 1 deletion examples/react/w3console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"typescript": "^4.9.3",
"vite": "^4.0.0"
}
}
}
Loading

0 comments on commit 116a6d8

Please sign in to comment.