浏览代码

Share the eslint config

Manav Rathi 1 年之前
父节点
当前提交
a00f64eaa9

+ 0 - 5
docs/dev.md

@@ -32,8 +32,3 @@ To see what packages depend on each other locally, use
 ```sh
 yarn workspaces info
 ```
-
-## Tips
-
-- Too see what tsc is seeing (say when it is trying to type-check `@/utils`),
-  use `yarn workspace @/utils tsc --showConfig`.

+ 13 - 0
packages/build-config/README.md

@@ -7,3 +7,16 @@ exports various config files that our packages use at build time.
 
 This is _not_ a TypeScript package, nor is it linted. It is not meant to be
 transpiled, it just exports static files that can be included verbatim.
+
+### Debugging
+
+Too see what tsc is seeing (say when it is trying to type-check `@/utils`), use
+`yarn workspace @/utils tsc --showConfig`.
+
+Similarly, to verify what ESLint is trying to do, use `yarn workspace @/utils
+eslint --debug .`
+
+If the issue is in VSCode, open the output window of the corresponding plugin,
+it might be telling us what's going wrong there. In particular, when changing
+the settings here, you might need to "Developer: Reload Window" in VSCode to get
+it to pick up the changes.

+ 13 - 0
packages/build-config/eslintrc-typescript.js

@@ -0,0 +1,13 @@
+module.exports = {
+    extends: [
+        'eslint:recommended',
+        'plugin:@typescript-eslint/recommended-type-checked',
+    ],
+    plugins: ['@typescript-eslint'],
+    parser: '@typescript-eslint/parser',
+    parserOptions: {
+        project: true,
+    },
+    ignorePatterns: ['.eslintrc.js'],
+    root: true,
+};

+ 0 - 15
packages/build-config/eslintrc.typescript.js

@@ -1,15 +0,0 @@
-/* eslint-env node */
-module.exports = {
-    extends: [
-        "eslint:recommended",
-        "plugin:@typescript-eslint/recommended-type-checked",
-    ],
-    plugins: ["@typescript-eslint"],
-    parser: "@typescript-eslint/parser",
-    parserOptions: {
-        project: true,
-        tsconfigRootDir: __dirname,
-    },
-    ignorePatterns: [".eslintrc.js"],
-    root: true,
-};

+ 1 - 10
packages/ui/.eslintrc.js

@@ -1,15 +1,6 @@
-/* eslint-env node */
 module.exports = {
-    extends: [
-        "eslint:recommended",
-        "plugin:@typescript-eslint/recommended-type-checked",
-    ],
-    plugins: ["@typescript-eslint"],
-    parser: "@typescript-eslint/parser",
+    extends: ["@/build-config/eslintrc-typescript"],
     parserOptions: {
-        project: true,
         tsconfigRootDir: __dirname,
     },
-    ignorePatterns: [".eslintrc.js"],
-    root: true,
 };

+ 1 - 1
packages/ui/README.md

@@ -4,5 +4,5 @@ Like [@/utils](../utils/README.md), but for things that require React.
 
 ### Packaging
 
-This (internal) package exports a vanilla TypeScript library. We rely on the
+This (internal) package exports a React TypeScript library. We rely on the
 importing project to transpile and bundle it.

+ 1 - 10
packages/utils/.eslintrc.js

@@ -1,15 +1,6 @@
-/* eslint-env node */
 module.exports = {
-    extends: [
-        "eslint:recommended",
-        "plugin:@typescript-eslint/recommended-type-checked",
-    ],
-    plugins: ["@typescript-eslint"],
-    parser: "@typescript-eslint/parser",
+    extends: ["@/build-config/eslintrc-typescript"],
     parserOptions: {
-        project: true,
         tsconfigRootDir: __dirname,
     },
-    ignorePatterns: [".eslintrc.js"],
-    root: true,
 };