1
0

eslint.config.mjs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. ".storybook/**/*",
  27. "**/*.stories.ts",
  28. ],
  29. }, ...compat.extends(
  30. "eslint:recommended",
  31. "plugin:storybook/recommended",
  32. "plugin:@typescript-eslint/recommended",
  33. ), {
  34. plugins: {
  35. "@typescript-eslint": typescriptEslint,
  36. "storybook": storybookEslint,
  37. },
  38. languageOptions: {
  39. globals: {
  40. ...globals.browser,
  41. ...globals.node,
  42. Atomics: "readonly",
  43. SharedArrayBuffer: "readonly",
  44. GM: "readonly",
  45. unsafeWindow: "writable",
  46. },
  47. parser: tsParser,
  48. ecmaVersion: "latest",
  49. sourceType: "module",
  50. },
  51. rules: {
  52. "no-unreachable": "off",
  53. "quotes": ["error", "double"],
  54. "semi": ["error", "always"],
  55. "eol-last": ["error", "always"],
  56. "no-async-promise-executor": "off",
  57. "no-cond-assign": "off",
  58. "no-empty": ["error", {
  59. allowEmptyCatch: true,
  60. }],
  61. "indent": ["error", 2, {
  62. ignoredNodes: ["VariableDeclaration[declarations.length=0]"],
  63. }],
  64. "@typescript-eslint/no-non-null-assertion": "off",
  65. "@typescript-eslint/no-unused-vars": ["warn", {
  66. vars: "local",
  67. ignoreRestSiblings: true,
  68. args: "after-used",
  69. argsIgnorePattern: "^_",
  70. }],
  71. "no-unused-vars": "off",
  72. "@typescript-eslint/ban-ts-comment": "off",
  73. "@typescript-eslint/no-empty-object-type": "off",
  74. "@typescript-eslint/no-explicit-any": "off",
  75. "@typescript-eslint/no-unused-expressions": ["error", {
  76. allowShortCircuit: true,
  77. allowTernary: true,
  78. allowTaggedTemplates: true,
  79. }],
  80. "comma-dangle": ["error", "only-multiline"],
  81. "no-misleading-character-class": "off",
  82. },
  83. }, {
  84. files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
  85. rules: {
  86. "@typescript-eslint/no-var-requires": "off",
  87. "quotes": ["error", "double"],
  88. "semi": ["error", "always"],
  89. "eol-last": ["error", "always"],
  90. "no-async-promise-executor": "off",
  91. "no-empty": ["error", {
  92. allowEmptyCatch: true,
  93. }],
  94. "indent": ["error", 2, {
  95. ignoredNodes: ["VariableDeclaration[declarations.length=0]"],
  96. }],
  97. "no-unused-vars": ["warn", {
  98. vars: "local",
  99. ignoreRestSiblings: true,
  100. args: "after-used",
  101. argsIgnorePattern: "^_",
  102. }],
  103. "comma-dangle": ["error", "only-multiline"],
  104. },
  105. },
  106. ];
  107. export default config;