1
0

eslint.config.mjs 2.9 KB

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