eslint.config.mjs 2.8 KB

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