eslint.config.mjs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import path from "node:path";
  2. import { fileURLToPath } from "node:url";
  3. import typescriptEslint from "@typescript-eslint/eslint-plugin";
  4. import storybookEslint from "eslint-plugin-storybook";
  5. import globals from "globals";
  6. import tsParser from "@typescript-eslint/parser";
  7. import js from "@eslint/js";
  8. import { FlatCompat } from "@eslint/eslintrc";
  9. const __filename = fileURLToPath(import.meta.url);
  10. const __dirname = path.dirname(__filename);
  11. const compat = new FlatCompat({
  12. baseDirectory: __dirname,
  13. recommendedConfig: js.configs.recommended,
  14. allConfig: js.configs.all,
  15. });
  16. /** @type {import("eslint").Linter.Config} */
  17. const config = [
  18. {
  19. ignores: [
  20. "**/*.min.*",
  21. "**/*.user.js",
  22. "**/*.map",
  23. "dist/**/*",
  24. "src/dev/**/*",
  25. "**/test.ts",
  26. ],
  27. }, ...compat.extends(
  28. "eslint:recommended",
  29. "plugin:storybook/recommended",
  30. "plugin:@typescript-eslint/recommended",
  31. ), {
  32. plugins: {
  33. "@typescript-eslint": typescriptEslint,
  34. "storybook": storybookEslint,
  35. },
  36. languageOptions: {
  37. globals: {
  38. ...globals.browser,
  39. ...globals.node,
  40. Atomics: "readonly",
  41. SharedArrayBuffer: "readonly",
  42. GM: "readonly",
  43. unsafeWindow: "writable",
  44. },
  45. parser: tsParser,
  46. ecmaVersion: "latest",
  47. sourceType: "module",
  48. },
  49. rules: {
  50. "no-unreachable": "off",
  51. quotes: ["error", "double"],
  52. semi: ["error", "always"],
  53. "eol-last": ["error", "always"],
  54. "no-async-promise-executor": "off",
  55. "no-cond-assign": "off",
  56. indent: ["error", 2, {
  57. ignoredNodes: ["VariableDeclaration[declarations.length=0]"],
  58. }],
  59. "@typescript-eslint/no-non-null-assertion": "off",
  60. "@typescript-eslint/no-unused-vars": ["warn", {
  61. vars: "local",
  62. ignoreRestSiblings: true,
  63. args: "after-used",
  64. argsIgnorePattern: "^_",
  65. }],
  66. "no-unused-vars": "off",
  67. "@typescript-eslint/ban-ts-comment": "off",
  68. "@typescript-eslint/no-empty-object-type": "off",
  69. "@typescript-eslint/no-explicit-any": "off",
  70. "@typescript-eslint/no-unused-expressions": ["error", {
  71. allowShortCircuit: true,
  72. allowTernary: true,
  73. allowTaggedTemplates: true,
  74. }],
  75. "comma-dangle": ["error", "only-multiline"],
  76. "no-misleading-character-class": "off",
  77. },
  78. }, {
  79. files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
  80. rules: {
  81. "@typescript-eslint/no-var-requires": "off",
  82. quotes: ["error", "double"],
  83. semi: ["error", "always"],
  84. "eol-last": ["error", "always"],
  85. "no-async-promise-executor": "off",
  86. indent: ["error", 2, {
  87. ignoredNodes: ["VariableDeclaration[declarations.length=0]"],
  88. }],
  89. "no-unused-vars": ["warn", {
  90. vars: "local",
  91. ignoreRestSiblings: true,
  92. args: "after-used",
  93. argsIgnorePattern: "^_",
  94. }],
  95. "comma-dangle": ["error", "only-multiline"],
  96. },
  97. },
  98. ];
  99. export default config;