Prechádzať zdrojové kódy

Fix streaming eslint configuration (#28055)

Emelia Smith 11 mesiacov pred
rodič
commit
4949b6da58
6 zmenil súbory, kde vykonal 78 pridanie a 13 odobranie
  1. 8 11
      .eslintrc.js
  2. 1 0
      package.json
  3. 32 0
      streaming/.eslintrc.js
  4. 6 2
      streaming/package.json
  5. 11 0
      streaming/tsconfig.json
  6. 20 0
      yarn.lock

+ 8 - 11
.eslintrc.js

@@ -1,4 +1,7 @@
-module.exports = {
+// @ts-check
+const { defineConfig } = require('eslint-define-config');
+
+module.exports = defineConfig({
   root: true,
 
   extends: [
@@ -193,6 +196,7 @@ module.exports = {
       'error',
       {
         devDependencies: [
+          '.eslintrc.js',
           'config/webpack/**',
           'app/javascript/mastodon/performance.js',
           'app/javascript/mastodon/test_setup.js',
@@ -299,6 +303,7 @@ module.exports = {
   overrides: [
     {
       files: [
+        '.eslintrc.js',
         '*.config.js',
         '.*rc.js',
         'ide-helper.js',
@@ -372,14 +377,6 @@ module.exports = {
       env: {
         jest: true,
       },
-    },
-    {
-      files: [
-        'streaming/**/*',
-      ],
-      rules: {
-        'import/no-commonjs': 'off',
-      },
-    },
+    }
   ],
-};
+});

+ 1 - 0
package.json

@@ -184,6 +184,7 @@
     "babel-jest": "^29.5.0",
     "eslint": "^8.41.0",
     "eslint-config-prettier": "^9.0.0",
+    "eslint-define-config": "^2.0.0",
     "eslint-import-resolver-typescript": "^3.5.5",
     "eslint-plugin-formatjs": "^4.10.1",
     "eslint-plugin-import": "~2.29.0",

+ 32 - 0
streaming/.eslintrc.js

@@ -0,0 +1,32 @@
+// @ts-check
+const { defineConfig } = require('eslint-define-config');
+
+module.exports = defineConfig({
+  extends: ['../.eslintrc.js'],
+  env: {
+    browser: false,
+  },
+  parserOptions: {
+    project: true,
+    tsconfigRootDir: __dirname,
+    ecmaFeatures: {
+      jsx: false,
+    },
+    ecmaVersion: 2021,
+  },
+  rules: {
+    'import/no-commonjs': 'off',
+    'import/no-extraneous-dependencies': [
+      'error',
+      {
+        devDependencies: [
+          'streaming/.eslintrc.js',
+        ],
+        optionalDependencies: false,
+        peerDependencies: false,
+        includeTypes: true,
+        packageDir: __dirname,
+      },
+    ],
+  },
+});

+ 6 - 2
streaming/package.json

@@ -12,7 +12,8 @@
     "url": "https://github.com/mastodon/mastodon.git"
   },
   "scripts": {
-    "start": "node ./index.js"
+    "start": "node ./index.js",
+    "check:types": "tsc --noEmit"
   },
   "dependencies": {
     "dotenv": "^16.0.3",
@@ -30,7 +31,10 @@
     "@types/express": "^4.17.17",
     "@types/npmlog": "^7.0.0",
     "@types/pg": "^8.6.6",
-    "@types/uuid": "^9.0.0"
+    "@types/uuid": "^9.0.0",
+    "@types/ws": "^8.5.9",
+    "eslint-define-config": "^2.0.0",
+    "typescript": "^5.0.4"
   },
   "optionalDependencies": {
     "bufferutil": "^4.0.7",

+ 11 - 0
streaming/tsconfig.json

@@ -0,0 +1,11 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "target": "esnext",
+    "module": "CommonJS",
+    "moduleResolution": "node",
+    "noUnusedParameters": false,
+    "paths": {}
+  },
+  "include": ["./*.js", "./.eslintrc.js"]
+}

+ 20 - 0
yarn.lock

@@ -2362,6 +2362,7 @@ __metadata:
     escape-html: "npm:^1.0.3"
     eslint: "npm:^8.41.0"
     eslint-config-prettier: "npm:^9.0.0"
+    eslint-define-config: "npm:^2.0.0"
     eslint-import-resolver-typescript: "npm:^3.5.5"
     eslint-plugin-formatjs: "npm:^4.10.1"
     eslint-plugin-import: "npm:~2.29.0"
@@ -2469,8 +2470,10 @@ __metadata:
     "@types/npmlog": "npm:^7.0.0"
     "@types/pg": "npm:^8.6.6"
     "@types/uuid": "npm:^9.0.0"
+    "@types/ws": "npm:^8.5.9"
     bufferutil: "npm:^4.0.7"
     dotenv: "npm:^16.0.3"
+    eslint-define-config: "npm:^2.0.0"
     express: "npm:^4.18.2"
     ioredis: "npm:^5.3.2"
     jsdom: "npm:^23.0.0"
@@ -2478,6 +2481,7 @@ __metadata:
     pg: "npm:^8.5.0"
     pg-connection-string: "npm:^2.6.0"
     prom-client: "npm:^15.0.0"
+    typescript: "npm:^5.0.4"
     utf-8-validate: "npm:^6.0.3"
     uuid: "npm:^9.0.0"
     ws: "npm:^8.12.1"
@@ -3644,6 +3648,15 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/ws@npm:^8.5.9":
+  version: 8.5.9
+  resolution: "@types/ws@npm:8.5.9"
+  dependencies:
+    "@types/node": "npm:*"
+  checksum: 678bdd6461c4653f2975c537fb673cb1918c331558e2d2422b69761c9ced67200bb07c664e2593f3864077a891cb7c13ef2a40d303b4aacb06173d095d8aa3ce
+  languageName: node
+  linkType: hard
+
 "@types/yargs-parser@npm:*":
   version: 21.0.2
   resolution: "@types/yargs-parser@npm:21.0.2"
@@ -7302,6 +7315,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"eslint-define-config@npm:^2.0.0":
+  version: 2.0.0
+  resolution: "eslint-define-config@npm:2.0.0"
+  checksum: 617c3143bc1ed8df0b20ae632d428d5f241dbb04483631e1410c58fe65ba3e503cf94631c5973115482b58ba464d052422a718c0f4d49182f8d13ffbb36bf1d6
+  languageName: node
+  linkType: hard
+
 "eslint-import-resolver-node@npm:^0.3.9":
   version: 0.3.9
   resolution: "eslint-import-resolver-node@npm:0.3.9"