@comet/eslint-plugin 8.0.0-canary-20250129120834 → 8.0.0-canary-20250130093900

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @comet/eslint-plugin
2
2
 
3
- ## 8.0.0-canary-20250129120834
3
+ ## 8.0.0-canary-20250130093900
4
4
 
5
5
  ## 7.11.0
6
6
 
@@ -0,0 +1,77 @@
1
+ import eslint from "@eslint/js";
2
+ import globals from "globals";
3
+ import tseslint from "typescript-eslint";
4
+ import prettierConfig from "eslint-config-prettier";
5
+ import prettierPlugin from "eslint-plugin-prettier/recommended";
6
+ import unusedImports from "eslint-plugin-unused-imports";
7
+ import simpleImportSort from "eslint-plugin-simple-import-sort";
8
+ import { configs as eslintPluginJsonc } from "eslint-plugin-jsonc";
9
+ import importPlugin from "eslint-plugin-import";
10
+ import packageJson from "eslint-plugin-package-json/configs/recommended";
11
+
12
+ /** @type {import('eslint')} */
13
+ const config = [
14
+ {
15
+ ignores: ["lib/**/*", "bin/**/*"],
16
+ },
17
+ eslint.configs.recommended,
18
+ ...tseslint.configs.recommended,
19
+ prettierConfig,
20
+ prettierPlugin,
21
+ {
22
+ plugins: {
23
+ "unused-imports": unusedImports,
24
+ },
25
+ rules: {
26
+ "unused-imports/no-unused-imports": "error",
27
+ },
28
+ },
29
+ {
30
+ plugins: {
31
+ "simple-import-sort": simpleImportSort,
32
+ },
33
+ rules: {
34
+ "simple-import-sort/imports": "error",
35
+ "simple-import-sort/exports": "error",
36
+ },
37
+ },
38
+ {
39
+ ...importPlugin.flatConfigs.recommended,
40
+ rules: {
41
+ "import/no-duplicates": "error",
42
+ "import/newline-after-import": "error",
43
+ "import/no-extraneous-dependencies": "error",
44
+ },
45
+ },
46
+ {
47
+ languageOptions: {
48
+ globals: {
49
+ ...globals.node,
50
+ ...globals.jest,
51
+ },
52
+
53
+ parser: tseslint.parser,
54
+ parserOptions: {
55
+ projectService: true,
56
+ tsconfigRootDir: import.meta.dirname,
57
+ },
58
+ },
59
+ // Rules
60
+ rules: {
61
+ "prefer-template": "error",
62
+ "no-console": ["error", { allow: ["warn", "error"] }],
63
+ "no-return-await": "error",
64
+ },
65
+ },
66
+ /* order matters -> json rules must be after typescript rules */
67
+ ...eslintPluginJsonc["flat/recommended-with-json"],
68
+ {
69
+ ignores: ["package.json"],
70
+ rules: {
71
+ "jsonc/sort-keys": "error",
72
+ },
73
+ },
74
+ packageJson,
75
+ ];
76
+
77
+ export default config;
package/lib/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var no_other_module_relative_import_1 = __importDefault(require("./rules/no-other-module-relative-import"));
7
7
  var no_private_sibling_import_1 = __importDefault(require("./rules/no-private-sibling-import"));
8
8
  var plugin = {
9
9
  rules: {
10
- "no-private-sibling-import": no_private_sibling_import_1["default"],
11
- "no-other-module-relative-import": no_other_module_relative_import_1["default"]
12
- }
10
+ "no-private-sibling-import": no_private_sibling_import_1.default,
11
+ "no-other-module-relative-import": no_other_module_relative_import_1.default,
12
+ },
13
13
  };
14
14
  module.exports = plugin;
@@ -2,13 +2,13 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var path_1 = __importDefault(require("path"));
7
7
  function parentDirCount(dir) {
8
8
  var match = dir.match(/^(\.\.\/)*/);
9
9
  return match[0].length / 3;
10
10
  }
11
- exports["default"] = {
11
+ exports.default = {
12
12
  meta: {
13
13
  type: "suggestion",
14
14
  fixable: "code",
@@ -17,15 +17,15 @@ exports["default"] = {
17
17
  type: "object",
18
18
  properties: {
19
19
  sourceRoot: {
20
- type: "string"
20
+ type: "string",
21
21
  },
22
22
  sourceRootAlias: {
23
- type: "string"
24
- }
23
+ type: "string",
24
+ },
25
25
  },
26
- additionalProperties: false
26
+ additionalProperties: false,
27
27
  },
28
- ]
28
+ ],
29
29
  },
30
30
  create: function (context) {
31
31
  return {
@@ -41,13 +41,13 @@ exports["default"] = {
41
41
  if (filePath == "<text>")
42
42
  return; // If the input is from stdin, this test can't fail
43
43
  var sourceDir = "".concat(context.getCwd(), "/").concat(options.sourceRoot);
44
- var fileDir = path_1["default"].dirname(filePath);
45
- var relativeFileToSourceDir = path_1["default"].relative(sourceDir, fileDir);
44
+ var fileDir = path_1.default.dirname(filePath);
45
+ var relativeFileToSourceDir = path_1.default.relative(sourceDir, fileDir);
46
46
  if (!relativeFileToSourceDir || relativeFileToSourceDir.startsWith("..")) {
47
47
  // file is not in source directory
48
48
  return;
49
49
  }
50
- var fileSubdirectoriesCount = relativeFileToSourceDir.split(path_1["default"].sep).length;
50
+ var fileSubdirectoriesCount = relativeFileToSourceDir.split(path_1.default.sep).length;
51
51
  // importParentDirCount is the number of ../ parts in the import path
52
52
  // fileSubdirectoriesCount is the number of subdirectories in the file path relative to the source directory
53
53
  if (importParentDirCount >= fileSubdirectoriesCount) {
@@ -55,12 +55,12 @@ exports["default"] = {
55
55
  node: node,
56
56
  message: "Avoid relative import from other module",
57
57
  fix: function (fixer) {
58
- var importPathRelativeToSourceDir = path_1["default"].relative(sourceDir, "".concat(fileDir, "/").concat(node.source.value.toString()));
58
+ var importPathRelativeToSourceDir = path_1.default.relative(sourceDir, "".concat(fileDir, "/").concat(node.source.value.toString()));
59
59
  return fixer.replaceText(node.source, "\"".concat(options.sourceRootAlias, "/").concat(importPathRelativeToSourceDir, "\""));
60
- }
60
+ },
61
61
  });
62
62
  }
63
- }
63
+ },
64
64
  };
65
- }
65
+ },
66
66
  };
@@ -2,20 +2,18 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var eslint_1 = require("eslint");
7
7
  var no_other_module_relative_import_1 = __importDefault(require("./no-other-module-relative-import"));
8
- var ruleTester = new eslint_1.RuleTester({
9
- parser: require.resolve("@typescript-eslint/parser")
10
- });
8
+ var ruleTester = new eslint_1.RuleTester();
11
9
  var errors = [{ message: "Avoid relative import from other module" }];
12
10
  var options = [{ sourceRoot: "./src", sourceRootAlias: "@src" }];
13
- ruleTester.run("no-other-module-relative-import", no_other_module_relative_import_1["default"], {
11
+ ruleTester.run("no-other-module-relative-import", no_other_module_relative_import_1.default, {
14
12
  valid: [
15
13
  {
16
14
  code: "import Bar from \"@src/moduleb/Bar\";",
17
15
  filename: "".concat(process.cwd(), "/src/modulea/Foo.ts"),
18
- options: options
16
+ options: options,
19
17
  },
20
18
  { code: "import Bar from \"../Bar\";", filename: "".concat(process.cwd(), "/src/modulea/sub/Foo.ts"), options: options },
21
19
  { code: "import Bar from \"xx/bar\";", filename: "".concat(process.cwd(), "/src/modulea/Foo.ts"), options: options },
@@ -26,14 +24,14 @@ ruleTester.run("no-other-module-relative-import", no_other_module_relative_impor
26
24
  filename: "".concat(process.cwd(), "/src/modulea/Foo.ts"),
27
25
  options: options,
28
26
  errors: errors,
29
- output: "import Bar from \"@src/moduleb/Bar\";"
27
+ output: "import Bar from \"@src/moduleb/Bar\";",
30
28
  },
31
29
  {
32
30
  code: "import Bar from \"../../Bar\";",
33
31
  filename: "".concat(process.cwd(), "/src/modulea/sub/Foo.ts"),
34
32
  options: options,
35
33
  errors: errors,
36
- output: "import Bar from \"@src/Bar\";"
34
+ output: "import Bar from \"@src/Bar\";",
37
35
  },
38
- ]
36
+ ],
39
37
  });
@@ -2,9 +2,9 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var path_1 = __importDefault(require("path"));
7
- exports["default"] = {
7
+ exports.default = {
8
8
  meta: {
9
9
  type: "suggestion",
10
10
  schema: [
@@ -12,10 +12,10 @@ exports["default"] = {
12
12
  type: "array",
13
13
  description: "List of private sibling file extensions, defaults to gql, sc",
14
14
  items: {
15
- type: "string"
16
- }
15
+ type: "string",
16
+ },
17
17
  },
18
- ]
18
+ ],
19
19
  },
20
20
  create: function (context) {
21
21
  return {
@@ -30,19 +30,19 @@ exports["default"] = {
30
30
  if (!isPrivateFileMatch[1].startsWith("./")) {
31
31
  context.report({
32
32
  node: node,
33
- message: "Import private siblings always with relative imports"
33
+ message: "Import private siblings always with relative imports",
34
34
  });
35
35
  }
36
36
  else {
37
- if (isPrivateFileMatch[1] != "./".concat(path_1["default"].basename(filePath).replace(/\.(.*)$/, ""))) {
37
+ if (isPrivateFileMatch[1] != "./".concat(path_1.default.basename(filePath).replace(/\.(.*)$/, ""))) {
38
38
  context.report({
39
39
  node: node,
40
- message: "Avoid private sibling import from other files"
40
+ message: "Avoid private sibling import from other files",
41
41
  });
42
42
  }
43
43
  }
44
44
  }
45
- }
45
+ },
46
46
  };
47
- }
47
+ },
48
48
  };
@@ -2,19 +2,17 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var eslint_1 = require("eslint");
7
7
  var no_private_sibling_import_1 = __importDefault(require("./no-private-sibling-import"));
8
- var ruleTester = new eslint_1.RuleTester({
9
- parser: require.resolve("@typescript-eslint/parser")
10
- });
8
+ var ruleTester = new eslint_1.RuleTester();
11
9
  var errors = [{ message: "Avoid private sibling import from other files" }];
12
10
  var options = [["gql", "sc", "gql.generated"]];
13
- ruleTester.run("no-private-sibling-import", no_private_sibling_import_1["default"], {
11
+ ruleTester.run("no-private-sibling-import", no_private_sibling_import_1.default, {
14
12
  valid: [{ code: "import FooGql from \"./Foo.gql\";", filename: "/path/to/Foo.ts", options: options }],
15
- invalid: [{ code: "import BarGql from \"./Bar.gql\";", filename: "/path/to/Foo.ts", options: options, errors: errors }]
13
+ invalid: [{ code: "import BarGql from \"./Bar.gql\";", filename: "/path/to/Foo.ts", options: options, errors: errors }],
16
14
  });
17
- ruleTester.run("no-private-sibling-import", no_private_sibling_import_1["default"], {
15
+ ruleTester.run("no-private-sibling-import", no_private_sibling_import_1.default, {
18
16
  valid: [{ code: "import FooGql from \"./Foo.gql.generated\";", filename: "/path/to/Foo.ts", options: options }],
19
- invalid: [{ code: "import BarGql from \"./Bar.gql.generated\";", filename: "/path/to/Foo.ts", options: options, errors: errors }]
17
+ invalid: [{ code: "import BarGql from \"./Bar.gql.generated\";", filename: "/path/to/Foo.ts", options: options, errors: errors }],
20
18
  });
package/package.json CHANGED
@@ -1,25 +1,29 @@
1
1
  {
2
2
  "name": "@comet/eslint-plugin",
3
- "version": "8.0.0-canary-20250129120834",
3
+ "version": "8.0.0-canary-20250130093900",
4
4
  "main": "lib/index.js",
5
5
  "devDependencies": {
6
- "@typescript-eslint/parser": "^5.0.0",
7
- "eslint-config-prettier": "^8.6.0",
8
- "eslint-plugin-prettier": "^5.2.3",
9
- "eslint-plugin-simple-import-sort": "^9.0.0",
10
- "eslint-plugin-unused-imports": "^2.0.0",
11
- "@typescript-eslint/eslint-plugin": "^5.48.2",
12
- "@types/eslint": "^8.56.12",
6
+ "@eslint/js": "^9.14.0",
13
7
  "@types/jest": "^27.5.2",
14
- "eslint": "^8.36.0",
8
+ "eslint": "^9.18.0",
9
+ "eslint-config-prettier": "^9.1.0",
10
+ "eslint-plugin-import": "^2.31.0",
11
+ "eslint-plugin-jsonc": "^2.18.2",
12
+ "eslint-plugin-package-json": "^0.21.1",
13
+ "eslint-plugin-prettier": "^5.2.1",
14
+ "eslint-plugin-simple-import-sort": "^12.1.1",
15
+ "eslint-plugin-unused-imports": "^4.1.4",
16
+ "globals": "^15.12.0",
15
17
  "jest": "^29.7.0",
16
18
  "npm-run-all2": "^5.0.2",
17
19
  "prettier": "^3.4.2",
18
20
  "ts-jest": "^29.2.5",
19
- "typescript": "^4.0.0"
21
+ "typescript": "^5.7.3",
22
+ "typescript-eslint": "^8.13.0"
20
23
  },
21
24
  "peerDependencies": {
22
- "eslint": "8"
25
+ "eslint": ">=9",
26
+ "prettier": ">=3"
23
27
  },
24
28
  "publishConfig": {
25
29
  "access": "public",
@@ -30,7 +34,7 @@
30
34
  "clean": "rimraf lib",
31
35
  "dev": "tsc --watch",
32
36
  "lint": "run-p lint:prettier lint:eslint lint:tsc",
33
- "lint:eslint": "eslint --max-warnings 0 src/ package.json",
37
+ "lint:eslint": "eslint --max-warnings 0 src/ **/*.json --no-warn-ignored",
34
38
  "lint:prettier": "npx prettier --check './**/*.{js,json,md,yml,yaml}'",
35
39
  "lint:tsc": "tsc",
36
40
  "test": "jest",
@@ -2,9 +2,7 @@ import { RuleTester } from "eslint";
2
2
 
3
3
  import noOtherModuleRelativeImport from "./no-other-module-relative-import";
4
4
 
5
- const ruleTester = new RuleTester({
6
- parser: require.resolve("@typescript-eslint/parser"),
7
- });
5
+ const ruleTester = new RuleTester();
8
6
 
9
7
  const errors = [{ message: "Avoid relative import from other module" }];
10
8
 
@@ -2,9 +2,7 @@ import { RuleTester } from "eslint";
2
2
 
3
3
  import noPrivateSiblingImport from "./no-private-sibling-import";
4
4
 
5
- const ruleTester = new RuleTester({
6
- parser: require.resolve("@typescript-eslint/parser"),
7
- });
5
+ const ruleTester = new RuleTester();
8
6
 
9
7
  const errors = [{ message: "Avoid private sibling import from other files" }];
10
8
 
package/tsconfig.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "extends": "../../tsconfig.core.json",
3
2
  "compilerOptions": {
4
3
  "outDir": "lib",
5
4
  "rootDir": "src"
6
5
  },
7
- "include": ["./src"],
8
- "exclude": ["node_modules", "lib"]
6
+ "exclude": ["node_modules", "lib"],
7
+ "extends": "../../tsconfig.core.json",
8
+ "include": ["./src"]
9
9
  }
package/.eslintrc.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
3
- "parser": "@typescript-eslint/parser",
4
- "plugins": ["@typescript-eslint", "simple-import-sort", "unused-imports"],
5
- "rules": {
6
- "no-unused-vars": "off",
7
- "@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }],
8
- "prefer-template": "error",
9
- "simple-import-sort/exports": "error",
10
- "simple-import-sort/imports": "error",
11
- "unused-imports/no-unused-imports": "error",
12
- "no-console": ["error", { "allow": ["warn", "error"] }],
13
- "no-return-await": "error"
14
- },
15
- "overrides": [
16
- {
17
- "files": ["*.ts", "*.tsx"],
18
- "rules": {
19
- "@typescript-eslint/no-unused-vars": ["error", { "args": "none", "ignoreRestSiblings": true }]
20
- }
21
- }
22
- ],
23
- "ignorePatterns": ["bin/", "lib/**"]
24
- }