Преглед изворни кода

include code style in linting but exclude pioneer

Mokhtar Naamani пре 4 година
родитељ
комит
f11bd97296
6 измењених фајлова са 46 додато и 22 уклоњено
  1. 0 7
      cli/.eslintrc
  2. 14 0
      cli/.eslintrc.js
  3. 1 1
      cli/package.json
  4. 14 6
      devops/eslint-config/index.js
  5. 7 6
      devops/prettier-config/index.js
  6. 10 2
      pioneer/.eslintrc.js

+ 0 - 7
cli/.eslintrc

@@ -1,7 +0,0 @@
-{
-  "extends": [
-    "@joystream/eslint-config",
-    "oclif",
-    "oclif-typescript"
-  ]
-}

+ 14 - 0
cli/.eslintrc.js

@@ -0,0 +1,14 @@
+module.exports = {
+  "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, to override @joystream/eslint-config
+    // "oclif",
+    // "oclif-typescript",
+
+    // not strictly necessary becase we have this in the root and will be used
+    // through cascading rules
+    "@joystream/eslint-config",
+  ]
+}

+ 1 - 1
cli/package.json

@@ -81,7 +81,7 @@
   },
   "scripts": {
     "postpack": "rm -f oclif.manifest.json",
-    "posttest": "eslint . --ext .ts --config .eslintrc",
+    "posttest": "eslint . --ext .ts",
     "prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
     "test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
     "version": "oclif-dev readme && git add README.md"

+ 14 - 6
devops/eslint-config/index.js

@@ -17,14 +17,22 @@ module.exports = {
   extends: [
     'plugin:react/recommended',
     'standard',
-    'plugin:jsx-a11y/recommended',
-    // Disable formatting related es-linting rules
-    'plugin:prettier/recommended',
-    'prettier/react',
-    'prettier/standard',
+
+    // 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',
+
+    // 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',
   ],
   plugins: [],
   settings: {
     version: 'detect',
   },
-};
+}

+ 7 - 6
devops/prettier-config/index.js

@@ -1,7 +1,8 @@
 module.exports = {
-  "singleQuote": true,
-  "arrowParens": "avoid",
-  "useTabs": false,
-  "tabWidth": 2,
-  "semi": false
-};
+  singleQuote: true,
+  arrowParens: 'avoid',
+  useTabs: false,
+  tabWidth: 2,
+  semi: false,
+  trailingComma: 'es5',
+}

+ 10 - 2
pioneer/.eslintrc.js

@@ -1,5 +1,5 @@
 const base = require('@polkadot/dev-react/config/eslint');
-
+console.log('Using eslintrc from pioneer folder')
 // add override for any (a metric ton of them, initial conversion)
 module.exports = {
   ...base,
@@ -16,5 +16,13 @@ module.exports = {
     'react/prop-types': 'off',
     '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',
+  ])
 };