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

eslint warn floating promises #5495

Merged
merged 5 commits into from
Jun 7, 2022
Merged
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
19 changes: 19 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
/* eslint-env node */
const process = require('process');
const lintTypes = !!process.env.AGORIC_ESLINT_TYPES;

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: lintTypes
? {
sourceType: 'module',
project: [
'./packages/*/jsconfig.json',
'./packages/*/tsconfig.json',
'./packages/wallet/*/jsconfig.json',
'./tsconfig.json',
],
tsconfigRootDir: __dirname,
extraFileExtensions: ['.cjs'],
}
: undefined,
plugins: [
'@jessie.js/eslint-plugin',
'@typescript-eslint',
Expand All @@ -11,6 +27,9 @@ module.exports = {
extends: ['@agoric'],
rules: {
'@typescript-eslint/prefer-ts-expect-error': 'warn',
'@typescript-eslint/no-floating-promises': lintTypes ? 'warn' : 'off',
// so that floating-promises can be explicitly permitted with void operator
'no-void': ['error', { allowAsStatement: true }],
'jsdoc/no-multi-asterisks': 'off',
'jsdoc/multiline-blocks': 'off',
// Use these rules to warn about JSDoc type problems, such as after
Expand Down
29 changes: 25 additions & 4 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,38 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

lint:
##################
# Lint tests
# We run per package bc of https://github.com/typescript-eslint/typescript-eslint/issues/1192
# We split the package tests into two jobs because type linting
# is inefficient and slow https://github.com/typescript-eslint/typescript-eslint/issues/2094
lint-primary:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/restore-node
with:
node-version: '16.x'

# first job also does repo-level linting
- name: lint repo format
run: yarn lint:format
# eslint
- name: yarn lint primary
run: ./scripts/lint-with-types.sh primary

lint-rest:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/restore-node
with:
node-version: '14.x'
node-version: '16.x'

- name: lint check
run: yarn lint
- name: yarn lint rest
run: ./scripts/lint-with-types.sh rest

##################
# Fast-running tests run as a group:
Expand Down
5 changes: 0 additions & 5 deletions packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@
],
"timeout": "10m"
},
"eslintConfig": {
"extends": [
"@agoric"
]
},
"publishConfig": {
"access": "public"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
"import/no-extraneous-dependencies": "off",
"react/display-name": "off"
"react/display-name": "off",
"@typescript-eslint/no-floating-promises": "off"
},
"env": {
"browser": true,
Expand Down
25 changes: 25 additions & 0 deletions scripts/lint-with-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# we don't collect type info by default because it can slow eslint by 8-10x
export AGORIC_ESLINT_TYPES='true'
# CI and some VMs OOM without this
export NODE_OPTIONS='--max-old-space-size=8192'

# argument used by CI to split this across two jobs
SCOPE=$1

# taking roughly half the time to eslint all packages
PRIMARY_PACKAGES="@agoric/{cosmos,ertp,governance,run-protocol,swing-store,swingset-vat,vats,wallet,zoe}"

case $SCOPE in
primary)
yarn lerna run --scope=$PRIMARY_PACKAGES --no-bail lint
;;
rest)
yarn lerna run --ignore=$PRIMARY_PACKAGES --no-bail lint
;;
*)
# all scopes
yarn lint
;;
esac