Skip to content

Commit

Permalink
chore: update eslint config (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-abrioux authored Jan 17, 2022
1 parent 5fcf8a5 commit 4004e56
Show file tree
Hide file tree
Showing 37 changed files with 112 additions and 75 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
command: yarn format:check
- run:
name: Verify lint
command: yarn lint
command: yarn lint:check
- run:
name: Build types
command: yarn workspace @requestnetwork/types run build
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
command: 'yarn workspace @requestnetwork/smart-contracts run deploy'
- run:
name: 'Lint smart contracts smart-contracts'
command: 'yarn workspace @requestnetwork/smart-contracts run lint:sol'
command: 'yarn workspace @requestnetwork/smart-contracts run lint:sol:check'
- run:
name: 'Test smart contracts smart-contracts'
command: 'yarn workspace @requestnetwork/smart-contracts run test'
Expand Down
47 changes: 36 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"env": { "browser": true, "node": true },
"parserOptions": {
"project": "tsconfig.json",
"ecmaVersion": 10,
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"prettier"
],
"plugins": [
"eslint-plugin-jsdoc",
"eslint-plugin-import",
"eslint-plugin-prefer-arrow",
"@typescript-eslint"
"jsdoc",
"import",
"prefer-arrow"
],
"rules": {
"arrow-parens": ["off", "always"],
"curly": ["error", "all"],
"complexity": "error",
"eqeqeq": ["error", "smart"],
"import/no-extraneous-dependencies": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unused-vars": "error"
}
"import/no-extraneous-dependencies": "error"
},
"ignorePatterns": [
"/packages/docs/",
"/packages/*/dist/",
// FIXME: tests should be linted
"/packages/*/test/"
],
"overrides": [
{
"files": ["*.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-unused-vars": "error"
}
}
]
}
6 changes: 3 additions & 3 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages/**/src/**/*.ts": [
"eslint --fix",
"*.[jt]s": [
"eslint --fix --quiet",
"prettier --write"
]
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"build": "lerna run build",
"clean": "lerna run clean",
"build:tsc": "tsc -b packages/advanced-logic packages/currency packages/data-access packages/data-format packages/epk-decryption packages/epk-signature packages/ethereum-storage packages/integration-test packages/multi-format packages/payment-detection packages/prototype-estimator packages/request-client.js packages/request-logic packages/request-node packages/smart-contracts packages/toolbox packages/transaction-manager packages/types packages/usage-examples packages/utils packages/web3-signature",
"lint": "eslint packages/**/src/**/*.ts --quiet",
"lint": "eslint . --fix --quiet",
"lint:check": "eslint . --quiet",
"lint-staged": "lint-staged",
"lerna": "lerna",
"packageJsonLint": "npmPkgJsonLint ./packages",
Expand All @@ -40,7 +41,6 @@
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jsdoc": "32.3.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-spellcheck": "0.0.17",
"husky": "4.3.0",
"lerna": "3.22.1",
"lint-staged": "10.5.4",
Expand Down
3 changes: 2 additions & 1 deletion packages/advanced-logic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/currency/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"test": "jest",
"test:watch": "yarn test --watch",
Expand Down
3 changes: 2 additions & 1 deletion packages/data-access/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/data-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/epk-decryption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"build:commonjs": "tsc -b",
"build:umd": "webpack",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
1 change: 0 additions & 1 deletion packages/epk-decryption/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ module.exports = {
new DuplicatePackageCheckerPlugin(),
],
};
/* eslint-enable spellcheck/spell-checker */
3 changes: 2 additions & 1 deletion packages/epk-signature/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"build:commonjs": "tsc -b",
"build:umd": "webpack",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
1 change: 0 additions & 1 deletion packages/epk-signature/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ module.exports = {
new DuplicatePackageCheckerPlugin(),
],
};
/* eslint-enable spellcheck/spell-checker */
3 changes: 2 additions & 1 deletion packages/ethereum-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch",
"init-ipfs": "node scripts/init-ipfs.js"
Expand Down
1 change: 0 additions & 1 deletion packages/ethereum-storage/scripts/init-ipfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function setupSwarmKey(ipfsPath, swarmKeyContent) {
});
} catch (err) {
throw new Error(`Error creating swarm key file: ${err.message}`);
return;
}

shell.echo('Swarm key file created.');
Expand Down
3 changes: 2 additions & 1 deletion packages/multi-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
5 changes: 5 additions & 0 deletions packages/payment-detection/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignorePatterns": [
"/src/thegraph/generated/"
]
}
3 changes: 2 additions & 1 deletion packages/payment-detection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"prebuild": "yarn codegen",
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo **/generated",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"test": "jest --runInBand",
"test:watch": "yarn test --watch",
Expand Down
3 changes: 2 additions & 1 deletion packages/payment-processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"test": "jest --runInBand",
"test:watch": "yarn test --watch"
Expand Down
3 changes: 2 additions & 1 deletion packages/request-client.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"build:umd": "webpack",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"docs": "shx rm -rf ./docs && compodoc -p tsconfig.json --output docs --disablePrivate --gaID UA-105153327-8",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
3 changes: 2 additions & 1 deletion packages/request-logic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"example": "ts-node specs/example/example.ts",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/request-logic/specs/example/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function foo(): Promise<void> {
signatureProvider,
);
// apply creation
let requestState = RequestLogic.applyActionToRequest(null, actionCreation);
let requestState = RequestLogic.applyActionToRequest(null, actionCreation, Date.now());
console.log('###########################################');
console.log('Creation Action ---------------------------');
console.log(JSON.stringify(JSON.stringify(actionCreation)));
Expand All @@ -91,7 +91,7 @@ async function foo(): Promise<void> {
signatureProvider,
);
// apply discount
requestState = RequestLogic.applyActionToRequest(requestState, actionReduceAmount);
requestState = RequestLogic.applyActionToRequest(requestState, actionReduceAmount, Date.now());
console.log('###########################################');
console.log('Reduce Amount Action ----------------------');
console.log(JSON.stringify(actionReduceAmount));
Expand All @@ -108,7 +108,7 @@ async function foo(): Promise<void> {
signatureProvider,
);
// apply accept
requestState = RequestLogic.applyActionToRequest(requestState, actionAccept);
requestState = RequestLogic.applyActionToRequest(requestState, actionAccept, Date.now());
console.log('###########################################');
console.log('Accept Action -----------------------------');
console.log(JSON.stringify(JSON.stringify(actionAccept)));
Expand All @@ -117,4 +117,4 @@ async function foo(): Promise<void> {
console.log('###########################################');
}

foo();
void foo();
3 changes: 2 additions & 1 deletion packages/request-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"start": "ts-node src/server.ts",
"start:watch": "ts-node-dev src/server.ts",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"init-ipfs": "node init-ipfs.js"
},
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/smart-contracts/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ignorePatterns": [
"/cache/",
"/types/",
// FIXME: artifacts index.ts should be linted
"/src/lib/artifacts/**/index.ts"
]
}
8 changes: 0 additions & 8 deletions packages/smart-contracts/.eslintrc.js

This file was deleted.

8 changes: 6 additions & 2 deletions packages/smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
"clean:lib": "shx rm -rf dist",
"clean:hardhat": "shx rm -rf cache && shx rm -rf build",
"clean": "yarn clean:lib && yarn clean:types && yarn clean:hardhat",
"lint:lib": "eslint \"src/lib/**/*.ts\"",
"lint:sol": "solhint \"src/contracts/**/*.sol\"",
"lint:lib": "eslint . --fix",
"lint:lib:check": "eslint .",
"lint:sol": "solhint \"src/contracts/**/*.sol\" --fix",
"lint:sol:check": "solhint \"src/contracts/**/*.sol\"",
"lint": "yarn run lint:lib && yarn run lint:sol",
"lint:check": "yarn run lint:lib:check && yarn run lint:sol:check",
"ganache": "ganache-cli -l 90000000 -p 8545 -m \"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat\"",
"deploy": "yarn hardhat deploy-local-env --network private",
"test": "yarn hardhat test --network private",
Expand All @@ -58,6 +61,7 @@
"@openzeppelin/contracts": "4.4.1",
"@openzeppelin/test-helpers": "0.5.6",
"@requestnetwork/currency": "0.8.0",
"@requestnetwork/types": "0.35.0",
"@typechain/ethers-v5": "7.0.1",
"@typechain/hardhat": "2.1.2",
"@types/chai": "4.2.21",
Expand Down
4 changes: 3 additions & 1 deletion packages/smart-contracts/scripts/deploy-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export async function deployOne<TContract extends Contract>(
type: 'attached',
};
}
} catch (e) {}
} catch (e) {
// ignore error
}
}

if (options?.nonceCondition) {
Expand Down
4 changes: 2 additions & 2 deletions packages/smart-contracts/scripts/deploy-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ export async function deployAllPaymentContracts(
hre: HardhatRuntimeEnvironment,
): Promise<void> {
const deploymentResults: (DeploymentResult | undefined)[] = [];
let simulationSuccess: boolean | undefined = args.simulate ? true : undefined;
let simulationSuccess: boolean | undefined;

try {
simulationSuccess = args.simulate ? true : undefined;
const [deployer] = await hre.ethers.getSigners();

console.log(
Expand Down Expand Up @@ -293,7 +294,6 @@ export async function deployAllPaymentContracts(
} else {
console.log(`--- No deployment was made. ---`);
}
// @ts-ignore
if (simulationSuccess === false) {
console.log('--- DO NOT PROCEED ---');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-contracts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"rootDir": ".",
"resolveJsonModule": true
},
"include": ["./src/**/*", "./src/**/*.json"],
"include": ["src", "src/**/*.json", "scripts", "hardhat.config.ts"],
"references": [{ "path": "../currency" }, { "path": "../utils" }]
}
3 changes: 2 additions & 1 deletion packages/toolbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"prepare": "yarn run build",
"cli": "cross-env NODE_ENV=development ts-node src/cli.ts",
"chainlinkPath": "yarn -s cli listAggregators",
Expand Down
3 changes: 2 additions & 1 deletion packages/transaction-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"scripts": {
"build": "tsc -b",
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
"lint": "eslint \"src/**/*.ts\"",
"lint": "eslint . --fix",
"lint:check": "eslint .",
"test": "jest",
"test:watch": "yarn test --watch"
},
Expand Down
Loading

0 comments on commit 4004e56

Please sign in to comment.