Explorar el Código

Simplify ESLint config (#3903)

Francisco hace 2 años
padre
commit
2336bd3e8e

+ 12 - 54
.eslintrc

@@ -1,62 +1,20 @@
 {
+  "root": true,
   "extends" : [
-    "standard"
-  ],
-  "plugins": [
-    "mocha"
+    "eslint:recommended",
+    "prettier",
   ],
   "env": {
-    "browser" : true,
-    "node"    : true,
-    "mocha"   : true,
-    "jest"    : true,
+    "es2022": true,
+    "browser": true,
+    "node": true,
+    "mocha": true,
   },
   "globals" : {
-    "artifacts": false,
-    "contract": false,
-    "assert": false,
-    "web3": false,
-    "usePlugin": false,
-    "extendEnvironment": false,
-  },
-  "rules": {
-
-    // Strict mode
-    "strict": ["error", "global"],
-
-    // Code style
-    "array-bracket-spacing": ["off"],
-    "camelcase": ["error", {"properties": "always"}],
-    "comma-dangle": ["error", "always-multiline"],
-    "comma-spacing": ["error", {"before": false, "after": true}],
-    "dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}],
-    "eol-last": ["error", "always"],
-    "eqeqeq": ["error", "smart"],
-    "generator-star-spacing": ["error", "before"],
-    "indent": ["error", 2],
-    "linebreak-style": ["error", "unix"],
-    "max-len": ["error", 120, 2],
-    "no-debugger": "off",
-    "no-dupe-args": "error",
-    "no-dupe-keys": "error",
-    "no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
-    "no-redeclare": ["error", {"builtinGlobals": true}],
-    "no-trailing-spaces": ["error", { "skipBlankLines": false }],
-    "no-undef": "error",
-    "no-use-before-define": "off",
-    "no-var": "error",
-    "object-curly-spacing": ["error", "always"],
-    "prefer-const": "error",
-    "quotes": ["error", "single"],
-    "semi": ["error", "always"],
-    "space-before-function-paren": ["error", "always"],
-
-    "mocha/no-exclusive-tests": ["error"],
-
-    "promise/always-return": "off",
-    "promise/avoid-new": "off",
-  },
-  "parserOptions": {
-    "ecmaVersion": 2020
+    "artifacts": "readonly",
+    "contract": "readonly",
+    "web3": "readonly",
+    "extendEnvironment": "readonly",
+    "expect": "readonly",
   }
 }

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 233 - 505
package-lock.json


+ 2 - 6
package.json

@@ -59,12 +59,8 @@
     "@openzeppelin/docs-utils": "^0.1.3",
     "@openzeppelin/test-helpers": "^0.5.13",
     "chai": "^4.2.0",
-    "eslint": "^7.32.0",
-    "eslint-config-standard": "^16.0.3",
-    "eslint-plugin-import": "^2.25.4",
-    "eslint-plugin-mocha": "^10.0.3",
-    "eslint-plugin-node": "^11.1.0",
-    "eslint-plugin-promise": "^5.2.0",
+    "eslint": "^8.30.0",
+    "eslint-config-prettier": "^8.5.0",
     "eth-sig-util": "^3.0.0",
     "ethereumjs-util": "^7.0.7",
     "ethereumjs-wallet": "^1.0.1",

+ 1 - 1
test/access/AccessControl.behavior.js

@@ -7,7 +7,7 @@ const DEFAULT_ADMIN_ROLE = '0x00000000000000000000000000000000000000000000000000
 const ROLE = web3.utils.soliditySha3('ROLE');
 const OTHER_ROLE = web3.utils.soliditySha3('OTHER_ROLE');
 
-function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, otherAdmin, otherAuthorized) {
+function shouldBehaveLikeAccessControl (errorPrefix, admin, authorized, other, otherAdmin) {
   shouldSupportInterfaces(['AccessControl']);
 
   describe('default admin', function () {

+ 1 - 1
test/proxy/Clones.test.js

@@ -6,7 +6,7 @@ const shouldBehaveLikeClone = require('./Clones.behaviour');
 
 const ClonesMock = artifacts.require('ClonesMock');
 
-contract('Clones', function (accounts) {
+contract('Clones', function () {
   describe('clone', function () {
     shouldBehaveLikeClone(async (implementation, initData, opts = {}) => {
       const factory = await ClonesMock.new();

+ 1 - 1
test/proxy/utils/Initializable.test.js

@@ -10,7 +10,7 @@ const DisableBad1 = artifacts.require('DisableBad1');
 const DisableBad2 = artifacts.require('DisableBad2');
 const DisableOk = artifacts.require('DisableOk');
 
-contract('Initializable', function (accounts) {
+contract('Initializable', function () {
   describe('basic testing without inheritance', function () {
     beforeEach('deploying', async function () {
       this.contract = await InitializableMock.new();

+ 1 - 1
test/proxy/utils/UUPSUpgradeable.test.js

@@ -8,7 +8,7 @@ const UUPSUpgradeableUnsafeMock = artifacts.require('UUPSUpgradeableUnsafeMock')
 const UUPSUpgradeableLegacyMock = artifacts.require('UUPSUpgradeableLegacyMock');
 const CountersImpl = artifacts.require('CountersImpl');
 
-contract('UUPSUpgradeable', function (accounts) {
+contract('UUPSUpgradeable', function () {
   before(async function () {
     this.implInitial = await UUPSUpgradeableMock.new();
     this.implUpgradeOk = await UUPSUpgradeableMock.new();

+ 1 - 1
test/security/ReentrancyGuard.test.js

@@ -5,7 +5,7 @@ const { expect } = require('chai');
 const ReentrancyMock = artifacts.require('ReentrancyMock');
 const ReentrancyAttack = artifacts.require('ReentrancyAttack');
 
-contract('ReentrancyGuard', function (accounts) {
+contract('ReentrancyGuard', function () {
   beforeEach(async function () {
     this.reentrancyMock = await ReentrancyMock.new();
     expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('0');

+ 1 - 1
test/token/ERC721/ERC721.behavior.js

@@ -83,7 +83,7 @@ function shouldBehaveLikeERC721 (errorPrefix, owner, newOwner, approved, another
         await this.token.setApprovalForAll(operator, true, { from: owner });
       });
 
-      const transferWasSuccessful = function ({ owner, tokenId, approved }) {
+      const transferWasSuccessful = function ({ owner, tokenId }) {
         it('transfers the ownership of the given token ID to the given address', async function () {
           expect(await this.token.ownerOf(tokenId)).to.be.equal(this.toWhom);
         });

+ 1 - 1
test/utils/Arrays.test.js

@@ -6,7 +6,7 @@ const AddressArraysMock = artifacts.require('AddressArraysMock');
 const Bytes32ArraysMock = artifacts.require('Bytes32ArraysMock');
 const Uint256ArraysMock = artifacts.require('Uint256ArraysMock');
 
-contract('Arrays', function (accounts) {
+contract('Arrays', function () {
   describe('findUpperBound', function () {
     context('Even number of elements', function () {
       const EVEN_ELEMENTS_ARRAY = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

+ 1 - 1
test/utils/Checkpoints.test.js

@@ -9,7 +9,7 @@ const CheckpointsMock = artifacts.require('CheckpointsMock');
 const first = (array) => array.length ? array[0] : undefined;
 const last = (array) => array.length ? array[array.length - 1] : undefined;
 
-contract('Checkpoints', function (accounts) {
+contract('Checkpoints', function () {
   describe('History checkpoints', function () {
     beforeEach(async function () {
       this.checkpoint = await CheckpointsMock.new();

+ 1 - 1
test/utils/Counters.test.js

@@ -4,7 +4,7 @@ const { expect } = require('chai');
 
 const CountersImpl = artifacts.require('CountersImpl');
 
-contract('Counters', function (accounts) {
+contract('Counters', function () {
   beforeEach(async function () {
     this.counter = await CountersImpl.new();
   });

+ 1 - 1
test/utils/Strings.test.js

@@ -4,7 +4,7 @@ const { expect } = require('chai');
 
 const StringsMock = artifacts.require('StringsMock');
 
-contract('Strings', function (accounts) {
+contract('Strings', function () {
   before(async function () {
     this.strings = await StringsMock.new();
   });

+ 1 - 1
test/utils/TimersBlockNumberImpl.test.js

@@ -3,7 +3,7 @@ const { expect } = require('chai');
 
 const TimersBlockNumberImpl = artifacts.require('TimersBlockNumberImpl');
 
-contract('TimersBlockNumber', function (accounts) {
+contract('TimersBlockNumber', function () {
   beforeEach(async function () {
     this.instance = await TimersBlockNumberImpl.new();
     this.now = await web3.eth.getBlock('latest').then(({ number }) => number);

+ 1 - 1
test/utils/TimersTimestamp.test.js

@@ -3,7 +3,7 @@ const { expect } = require('chai');
 
 const TimersTimestampImpl = artifacts.require('TimersTimestampImpl');
 
-contract('TimersTimestamp', function (accounts) {
+contract('TimersTimestamp', function () {
   beforeEach(async function () {
     this.instance = await TimersTimestampImpl.new();
     this.now = await web3.eth.getBlock('latest').then(({ timestamp }) => timestamp);

+ 1 - 1
test/utils/cryptography/MerkleProof.test.js

@@ -8,7 +8,7 @@ const { expect } = require('chai');
 
 const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
 
-contract('MerkleProof', function (accounts) {
+contract('MerkleProof', function () {
   beforeEach(async function () {
     this.merkleProof = await MerkleProofWrapper.new();
   });

+ 1 - 1
test/utils/introspection/ERC165.test.js

@@ -2,7 +2,7 @@ const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
 
 const ERC165Mock = artifacts.require('ERC165Mock');
 
-contract('ERC165', function (accounts) {
+contract('ERC165', function () {
   beforeEach(async function () {
     this.mock = await ERC165Mock.new();
   });

+ 1 - 1
test/utils/introspection/ERC165Checker.test.js

@@ -16,7 +16,7 @@ const DUMMY_UNSUPPORTED_ID = '0xbaddcafe';
 const DUMMY_UNSUPPORTED_ID_2 = '0xbaadcafe';
 const DUMMY_ACCOUNT = '0x1111111111111111111111111111111111111111';
 
-contract('ERC165Checker', function (accounts) {
+contract('ERC165Checker', function () {
   beforeEach(async function () {
     this.mock = await ERC165CheckerMock.new();
   });

+ 1 - 1
test/utils/introspection/ERC165Storage.test.js

@@ -4,7 +4,7 @@ const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
 
 const ERC165Mock = artifacts.require('ERC165StorageMock');
 
-contract('ERC165Storage', function (accounts) {
+contract('ERC165Storage', function () {
   beforeEach(async function () {
     this.mock = await ERC165Mock.new();
   });

+ 1 - 1
test/utils/math/Math.test.js

@@ -5,7 +5,7 @@ const { Rounding } = require('../../helpers/enums.js');
 
 const MathMock = artifacts.require('MathMock');
 
-contract('Math', function (accounts) {
+contract('Math', function () {
   const min = new BN('1234');
   const max = new BN('5678');
   const MAX_UINT256_SUB1 = MAX_UINT256.sub(new BN('1'));

+ 1 - 1
test/utils/math/SafeCast.test.js

@@ -4,7 +4,7 @@ const { range } = require('../../../scripts/helpers');
 
 const SafeCastMock = artifacts.require('SafeCastMock');
 
-contract('SafeCast', async (accounts) => {
+contract('SafeCast', async function () {
   beforeEach(async function () {
     this.safeCast = await SafeCastMock.new();
   });

+ 1 - 1
test/utils/math/SafeMath.test.js

@@ -15,7 +15,7 @@ function expectStruct (value, expected) {
   }
 }
 
-contract('SafeMath', function (accounts) {
+contract('SafeMath', function () {
   beforeEach(async function () {
     this.safeMath = await SafeMathMock.new();
   });

+ 1 - 1
test/utils/math/SignedMath.test.js

@@ -4,7 +4,7 @@ const { MIN_INT256, MAX_INT256 } = constants;
 
 const SignedMathMock = artifacts.require('SignedMathMock');
 
-contract('SignedMath', function (accounts) {
+contract('SignedMath', function () {
   const min = new BN('-1234');
   const max = new BN('5678');
 

+ 1 - 1
test/utils/math/SignedSafeMath.test.js

@@ -5,7 +5,7 @@ const { expect } = require('chai');
 
 const SignedSafeMathMock = artifacts.require('SignedSafeMathMock');
 
-contract('SignedSafeMath', function (accounts) {
+contract('SignedSafeMath', function () {
   beforeEach(async function () {
     this.safeMath = await SignedSafeMathMock.new();
   });

+ 1 - 1
test/utils/structs/BitMap.test.js

@@ -3,7 +3,7 @@ const { expect } = require('chai');
 
 const BitMap = artifacts.require('BitMapMock');
 
-contract('BitMap', function (accounts) {
+contract('BitMap', function () {
   const keyA = new BN('7891');
   const keyB = new BN('451');
   const keyC = new BN('9592328');

+ 1 - 1
test/utils/structs/DoubleEndedQueue.test.js

@@ -10,7 +10,7 @@ async function getContent (deque) {
   return values;
 }
 
-contract('DoubleEndedQueue', function (accounts) {
+contract('DoubleEndedQueue', function () {
   const bytesA = '0xdeadbeef'.padEnd(66, '0');
   const bytesB = '0x0123456789'.padEnd(66, '0');
   const bytesC = '0x42424242'.padEnd(66, '0');

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio