瀏覽代碼

rebased with fixes

Mokhtar Naamani 4 年之前
父節點
當前提交
8fd670de54

+ 3 - 9
cli/.eslintrc.js

@@ -1,16 +1,10 @@
 module.exports = {
-  "extends": [
+  extends: [
     // The oclif rules have some code-style/formatting rules which may conflict with
     // our prettier global settings. Disabling for now
     // I suggest to only add essential rules absolutely required to make the cli work with oclif
-    // at the end of this file,
-    // The rule will be overridden by the rules in the root .eslintrc.js so we may have to
-    // change them there or remove them if necessary.
+    // at the end of this file.
     // "oclif",
     // "oclif-typescript",
-
-    // not strictly necessary becase we have this in the root and will be used
-    // through cascading rules
-    "@joystream/eslint-config",
-  ]
+  ],
 }

+ 5 - 0
devops/.eslintrc.js

@@ -0,0 +1,5 @@
+module.exports = {
+    env: {
+        node: true,
+    }
+}

+ 22 - 17
devops/eslint-config/index.js

@@ -2,39 +2,44 @@
 // as possible with rules that we absolutely require across all projects.
 module.exports = {
   env: {
-    es6: true
-  },
-  globals: {
-    Atomics: 'readonly',
-    SharedArrayBuffer: 'readonly'
+    es6: true,
   },
+  // We are relying on version that comes with @polkadot/dev
+  // Newest version is breaking pioneer!
   parser: '@typescript-eslint/parser',
   parserOptions: {
     ecmaFeatures: {
-      jsx: true
+      jsx: true,
     },
     ecmaVersion: 2019,
-    sourceType: 'module'
+    sourceType: 'module',
   },
   extends: [
+    'eslint:recommended',
     'plugin:react/recommended',
-    'standard'
+    'plugin:@typescript-eslint/eslint-recommended',
+    'plugin:@typescript-eslint/recommended',
 
     // jsx-a11y conflicts with pioneer rules. At time of writing
     // 84 problems -> We want to avoid as much as possible changing code in pioneer at least
     // from polkadot-js code base to make it possible to pull from upstream as easily as possible.
-    // So Leaving out of for now. But it is recommended to add to all joystream react projects
-    // 'plugin:jsx-a11y/recommended',
+    // pioneer has an isolated linting config so its safe to enable here.
+    'plugin:jsx-a11y/recommended',
 
     // Turns off all rules that are unnecessary or might conflict with Prettier.
     // Allows us to do formatting separately from linting.
-    // 'prettier',
-    // 'prettier/@typescript-eslint',
-    // 'prettier/react',
-    // 'prettier/standard',
+    'prettier',
+    'prettier/@typescript-eslint',
+    'prettier/react',
+    'prettier/standard',
+    // To Display prettier errors as ESLint errors, enable the following configuration,
+    // And make sure it is the last configuration in the extends array.
+    'plugin:prettier/recommended',
   ],
-  plugins: [],
   settings: {
-    version: 'detect'
-  }
+    react: {
+      version: 'detect',
+    },
+  },
+  plugins: ['@typescript-eslint'],
 }

+ 1 - 1
devops/eslint-config/package.json

@@ -17,6 +17,6 @@
   },
   "homepage": "https://github.com/joystream/joystream#readme",
   "peerDependencies": {
-    "eslint": ">= 3"
+    "eslint": ">= 5"
   }
 }

+ 45 - 44
package.json

@@ -1,46 +1,47 @@
 {
-	"private": true,
-	"name": "joystream",
-	"license": "GPL-3.0-only",
-	"scripts": {
-		"test": "yarn && yarn workspaces run test",
-		"test-migration": "yarn && yarn workspaces run test-migration",
-		"postinstall": "yarn workspace @joystream/types build",
-		"cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
-		"cargo-build": "scripts/cargo-build.sh"
-	},
-	"workspaces": [
-		"tests/network-tests",
-		"cli",
-		"types",
-		"pioneer",
-		"pioneer/packages/*",
-		"devops/eslint-config",
-		"devops/prettier-config",
-		"devops/tsconfig"
-	],
-	"resolutions": {
-		"@polkadot/api": "^0.96.1",
-		"@polkadot/api-contract": "^0.96.1",
-		"@polkadot/keyring": "^1.7.0-beta.5",
-		"@polkadot/types": "^0.96.1",
-		"@polkadot/util": "^1.7.0-beta.5",
-		"@polkadot/util-crypto": "^1.7.0-beta.5",
-		"babel-core": "^7.0.0-bridge.0",
-		"typescript": "^3.7.2"
-	},
-	"devDependencies": {
-		"eslint-config-prettier": "^6.11.0",
-		"eslint-plugin-jsx-a11y": "^6.2.3",
-		"eslint-plugin-prettier": "^3.1.3",
-		"eslint-plugin-react-hooks": "^4.0.4",
-		"husky": "^4.2.5",
-		"prettier": "2.0.2"
-	},
-	"husky": {
-	  "hooks": {
-		"pre-commit": "devops/git-hooks/pre-commit",
-		"pre-push": "devops/git-hooks/pre-push"
-	  }
-	}
+  "private": true,
+  "name": "joystream",
+  "license": "GPL-3.0-only",
+  "scripts": {
+    "test": "yarn && yarn workspaces run test",
+    "test-migration": "yarn && yarn workspaces run test-migration",
+    "postinstall": "yarn workspace @joystream/types build",
+    "cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
+    "cargo-build": "scripts/cargo-build.sh",
+    "lint": "yarn workspaces run lint"
+  },
+  "workspaces": [
+    "tests/network-tests",
+    "cli",
+    "types",
+    "pioneer",
+    "pioneer/packages/*",
+    "devops/eslint-config",
+    "devops/prettier-config",
+    "devops/tsconfig"
+  ],
+  "resolutions": {
+    "@polkadot/api": "^0.96.1",
+    "@polkadot/api-contract": "^0.96.1",
+    "@polkadot/keyring": "^1.7.0-beta.5",
+    "@polkadot/types": "^0.96.1",
+    "@polkadot/util": "^1.7.0-beta.5",
+    "@polkadot/util-crypto": "^1.7.0-beta.5",
+    "babel-core": "^7.0.0-bridge.0",
+    "typescript": "^3.7.2"
+  },
+  "devDependencies": {
+    "eslint-config-prettier": "^6.11.0",
+    "eslint-plugin-jsx-a11y": "^6.2.3",
+    "eslint-plugin-prettier": "^3.1.3",
+    "eslint-plugin-react-hooks": "^4.0.4",
+    "husky": "^4.2.5",
+    "prettier": "2.0.2"
+  },
+  "husky": {
+    "hooks": {
+      "pre-commit": "devops/git-hooks/pre-commit",
+      "pre-push": "devops/git-hooks/pre-push"
+    }
+  }
 }

+ 2 - 8
pioneer/.eslintrc.js

@@ -17,12 +17,6 @@ module.exports = {
     'new-cap': 'off',
     '@typescript-eslint/interface-name-prefix': 'off'
   },
-  extends: base.extends.concat([
-    // disable formatting rules - incase we decide to apply code style rules
-    // to our linter settings.
-    'prettier',
-    'prettier/@typescript-eslint',
-    'prettier/react',
-    'prettier/standard',
-  ])
+  // isolate pioneer from monorepo eslint rules
+  root: true
 };

+ 5 - 0
tests/network-tests/.eslintrc.js

@@ -0,0 +1,5 @@
+module.exports = {
+    env: {
+        node: true,
+    }
+}

+ 1 - 1
tests/network-tests/package.json

@@ -6,7 +6,7 @@
     "build": "tsc --build tsconfig.json",
     "test": "tap --files ts-node/register src/constantinople/tests/proposals/*Test.ts",
     "test-migration": "tap --files src/rome/tests/romeRuntimeUpgradeTest.ts --files src/constantinople/tests/electingCouncilTest.ts",
-    "lint": "eslint . --ext .ts",
+    "lint": "eslint . --quiet --ext .ts",
     "prettier": "prettier --write ./src"
   },
   "dependencies": {