2024-04-26 01:57:26 +02:00
|
|
|
|
"use strict";
|
|
|
|
|
|
2024-06-08 00:34:23 +02:00
|
|
|
|
const confusingBrowserGlobals = require("confusing-browser-globals");
|
|
|
|
|
|
2024-04-26 01:57:26 +02:00
|
|
|
|
module.exports = {
|
|
|
|
|
root: true,
|
|
|
|
|
env: {
|
|
|
|
|
es2020: true,
|
|
|
|
|
node: true,
|
2017-05-25 01:44:58 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
extends: [
|
2020-10-07 12:27:37 +02:00
|
|
|
|
"eslint:recommended",
|
|
|
|
|
"plugin:import/errors",
|
|
|
|
|
"plugin:import/warnings",
|
2022-01-25 11:39:43 +01:00
|
|
|
|
"plugin:no-jquery/recommended",
|
2022-03-16 22:31:50 +01:00
|
|
|
|
"plugin:no-jquery/deprecated",
|
2020-10-07 12:27:37 +02:00
|
|
|
|
"plugin:unicorn/recommended",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"prettier",
|
2020-10-07 12:27:37 +02:00
|
|
|
|
],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
parser: "@babel/eslint-parser",
|
|
|
|
|
parserOptions: {
|
|
|
|
|
requireConfigFile: false,
|
|
|
|
|
warnOnUnsupportedTypeScriptVersion: false,
|
|
|
|
|
sourceType: "unambiguous",
|
2016-11-04 23:15:18 +01:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
plugins: ["formatjs", "no-jquery"],
|
|
|
|
|
settings: {
|
|
|
|
|
formatjs: {
|
|
|
|
|
additionalFunctionNames: ["$t", "$t_html"],
|
2022-09-05 10:06:23 +02:00
|
|
|
|
},
|
2022-01-25 11:39:43 +01:00
|
|
|
|
"no-jquery": {
|
2024-04-26 01:57:26 +02:00
|
|
|
|
collectionReturningPlugins: {
|
|
|
|
|
expectOne: "always",
|
2022-01-25 11:39:43 +01:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
variablePattern: "^\\$(?!t$|t_html$).",
|
|
|
|
|
},
|
2021-06-13 21:53:39 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
reportUnusedDisableDirectives: true,
|
|
|
|
|
rules: {
|
2016-12-05 07:53:36 +01:00
|
|
|
|
"array-callback-return": "error",
|
2020-07-02 01:41:40 +02:00
|
|
|
|
"arrow-body-style": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"block-scoped-var": "error",
|
2020-09-24 07:50:36 +02:00
|
|
|
|
"consistent-return": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
curly: "error",
|
2020-05-27 03:58:32 +02:00
|
|
|
|
"dot-notation": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
eqeqeq: "error",
|
2021-06-13 21:53:39 +02:00
|
|
|
|
"formatjs/enforce-default-message": ["error", "literal"],
|
|
|
|
|
"formatjs/enforce-placeholders": [
|
|
|
|
|
"error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
{ignoreList: ["b", "code", "em", "i", "kbd", "p", "strong"]},
|
2021-06-13 21:53:39 +02:00
|
|
|
|
],
|
|
|
|
|
"formatjs/no-id": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"guard-for-in": "error",
|
2020-08-29 04:31:23 +02:00
|
|
|
|
"import/extensions": "error",
|
2020-07-24 06:02:07 +02:00
|
|
|
|
"import/first": "error",
|
|
|
|
|
"import/newline-after-import": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"import/no-cycle": ["error", {ignoreExternal: true}],
|
2023-07-21 23:18:28 +02:00
|
|
|
|
"import/no-duplicates": "error",
|
2021-11-23 23:29:18 +01:00
|
|
|
|
"import/no-self-import": "error",
|
2023-05-12 01:05:31 +02:00
|
|
|
|
"import/no-unresolved": "off",
|
2020-09-01 22:55:28 +02:00
|
|
|
|
"import/no-useless-path-segments": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"import/order": ["error", {alphabetize: {order: "asc"}, "newlines-between": "always"}],
|
2020-08-01 03:43:15 +02:00
|
|
|
|
"import/unambiguous": "error",
|
2021-02-09 22:46:25 +01:00
|
|
|
|
"lines-around-directive": "error",
|
2020-12-11 04:26:23 +01:00
|
|
|
|
"new-cap": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-alert": "error",
|
2017-06-05 09:01:02 +02:00
|
|
|
|
"no-array-constructor": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-bitwise": "error",
|
|
|
|
|
"no-caller": "error",
|
|
|
|
|
"no-catch-shadow": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"no-constant-condition": ["error", {checkLoops: false}],
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-div-regex": "error",
|
|
|
|
|
"no-else-return": "error",
|
|
|
|
|
"no-eq-null": "error",
|
|
|
|
|
"no-eval": "error",
|
2020-10-07 12:54:16 +02:00
|
|
|
|
"no-implicit-coercion": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-implied-eval": "error",
|
2020-05-27 03:58:32 +02:00
|
|
|
|
"no-inner-declarations": "off",
|
2017-06-05 09:01:02 +02:00
|
|
|
|
"no-iterator": "error",
|
2024-04-03 23:26:17 +02:00
|
|
|
|
"no-jquery/no-append-html": "error",
|
2022-08-16 06:50:20 +02:00
|
|
|
|
"no-jquery/no-constructor-attributes": "error",
|
2022-03-17 00:31:13 +01:00
|
|
|
|
"no-jquery/no-parse-html-literal": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-label-var": "error",
|
|
|
|
|
"no-labels": "error",
|
|
|
|
|
"no-loop-func": "error",
|
|
|
|
|
"no-multi-str": "error",
|
|
|
|
|
"no-native-reassign": "error",
|
2017-06-05 09:01:02 +02:00
|
|
|
|
"no-new-func": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-new-object": "error",
|
|
|
|
|
"no-new-wrappers": "error",
|
|
|
|
|
"no-octal-escape": "error",
|
|
|
|
|
"no-plusplus": "error",
|
|
|
|
|
"no-proto": "error",
|
2024-06-08 00:34:23 +02:00
|
|
|
|
"no-restricted-globals": ["error", ...confusingBrowserGlobals],
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-return-assign": "error",
|
|
|
|
|
"no-script-url": "error",
|
|
|
|
|
"no-self-compare": "error",
|
|
|
|
|
"no-sync": "error",
|
2020-10-07 13:01:09 +02:00
|
|
|
|
"no-throw-literal": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-undef-init": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"no-unneeded-ternary": ["error", {defaultAssignment: false}],
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"no-unused-expressions": "error",
|
2023-06-29 21:59:08 +02:00
|
|
|
|
"no-unused-vars": [
|
|
|
|
|
"error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
{args: "all", argsIgnorePattern: "^_", ignoreRestSiblings: true},
|
2023-06-29 21:59:08 +02:00
|
|
|
|
],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"no-use-before-define": ["error", {functions: false}],
|
2020-10-07 13:17:55 +02:00
|
|
|
|
"no-useless-concat": "error",
|
2017-06-05 09:01:02 +02:00
|
|
|
|
"no-useless-constructor": "error",
|
2019-11-02 00:06:25 +01:00
|
|
|
|
"no-var": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"object-shorthand": ["error", "always", {avoidExplicitReturnArrows: true}],
|
2020-07-24 01:26:12 +02:00
|
|
|
|
"one-var": ["error", "never"],
|
2020-07-02 01:45:54 +02:00
|
|
|
|
"prefer-arrow-callback": "error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"prefer-const": ["error", {ignoreReadBeforeAssign: true}],
|
|
|
|
|
radix: "error",
|
|
|
|
|
"sort-imports": ["error", {ignoreDeclarationSort: true}],
|
|
|
|
|
"spaced-comment": ["error", "always", {markers: ["/"]}],
|
|
|
|
|
strict: "error",
|
2020-10-07 12:27:37 +02:00
|
|
|
|
"unicorn/consistent-function-scoping": "off",
|
|
|
|
|
"unicorn/explicit-length-check": "off",
|
|
|
|
|
"unicorn/filename-case": "off",
|
2021-12-03 21:35:46 +01:00
|
|
|
|
"unicorn/no-await-expression-member": "off",
|
2022-12-07 00:56:16 +01:00
|
|
|
|
"unicorn/no-negated-condition": "off",
|
2020-10-07 12:27:37 +02:00
|
|
|
|
"unicorn/no-null": "off",
|
|
|
|
|
"unicorn/no-process-exit": "off",
|
|
|
|
|
"unicorn/no-useless-undefined": "off",
|
2021-05-09 22:29:53 +02:00
|
|
|
|
"unicorn/numeric-separators-style": "off",
|
|
|
|
|
"unicorn/prefer-module": "off",
|
|
|
|
|
"unicorn/prefer-node-protocol": "off",
|
2024-05-27 04:23:31 +02:00
|
|
|
|
"unicorn/prefer-string-raw": "off",
|
2020-10-24 10:02:35 +02:00
|
|
|
|
"unicorn/prefer-ternary": "off",
|
2022-07-06 06:08:35 +02:00
|
|
|
|
"unicorn/prefer-top-level-await": "off",
|
2020-10-07 12:27:37 +02:00
|
|
|
|
"unicorn/prevent-abbreviations": "off",
|
2022-10-07 00:56:00 +02:00
|
|
|
|
"unicorn/switch-case-braces": "off",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"valid-typeof": ["error", {requireStringLiterals: true}],
|
|
|
|
|
yoda: "error",
|
2019-03-24 11:20:43 +01:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
overrides: [
|
2022-03-16 22:31:50 +01:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/tests/**"],
|
|
|
|
|
rules: {
|
|
|
|
|
"no-jquery/no-selector-prop": "off",
|
|
|
|
|
},
|
2022-03-16 22:31:50 +01:00
|
|
|
|
},
|
2021-03-11 23:33:24 +01:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/e2e-tests/**"],
|
|
|
|
|
globals: {
|
|
|
|
|
zulip_test: false,
|
|
|
|
|
},
|
2021-03-11 23:33:24 +01:00
|
|
|
|
},
|
2021-02-10 04:51:11 +01:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/src/**"],
|
|
|
|
|
globals: {
|
|
|
|
|
StripeCheckout: false,
|
|
|
|
|
},
|
2020-02-18 00:08:43 +01:00
|
|
|
|
},
|
2019-03-24 11:20:43 +01:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["**/*.ts"],
|
|
|
|
|
extends: [
|
2023-12-22 01:08:17 +01:00
|
|
|
|
"plugin:@typescript-eslint/strict-type-checked",
|
2023-12-22 02:05:17 +01:00
|
|
|
|
"plugin:@typescript-eslint/stylistic-type-checked",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"plugin:import/typescript",
|
2021-09-23 00:29:14 +02:00
|
|
|
|
],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
parserOptions: {
|
|
|
|
|
project: "tsconfig.json",
|
2019-03-24 11:20:43 +01:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
settings: {
|
2021-10-16 21:56:00 +02:00
|
|
|
|
"import/resolver": {
|
2024-04-26 01:57:26 +02:00
|
|
|
|
node: {
|
|
|
|
|
extensions: [".ts", ".d.ts", ".js"], // https://github.com/import-js/eslint-plugin-import/issues/2267
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-10-16 21:56:00 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
globals: {
|
|
|
|
|
JQuery: false,
|
2021-05-26 19:59:12 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
rules: {
|
2019-05-31 07:15:00 +02:00
|
|
|
|
// Disable base rule to avoid conflict
|
2021-06-06 22:13:18 +02:00
|
|
|
|
"no-use-before-define": "off",
|
2019-03-25 15:35:44 +01:00
|
|
|
|
|
2023-10-26 04:41:09 +02:00
|
|
|
|
"@typescript-eslint/consistent-type-assertions": [
|
|
|
|
|
"error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
{assertionStyle: "never"},
|
2023-10-26 04:41:09 +02:00
|
|
|
|
],
|
2023-04-19 23:40:04 +02:00
|
|
|
|
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
2021-03-19 00:56:46 +01:00
|
|
|
|
"@typescript-eslint/consistent-type-imports": "error",
|
2020-07-24 01:26:12 +02:00
|
|
|
|
"@typescript-eslint/explicit-function-return-type": [
|
|
|
|
|
"error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
{allowExpressions: true},
|
2020-07-24 01:26:12 +02:00
|
|
|
|
],
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"@typescript-eslint/member-ordering": "error",
|
2023-12-27 01:34:59 +01:00
|
|
|
|
"@typescript-eslint/method-signature-style": "error",
|
2023-03-16 19:19:53 +01:00
|
|
|
|
"@typescript-eslint/no-non-null-assertion": "off",
|
2023-04-20 00:52:01 +02:00
|
|
|
|
"@typescript-eslint/no-unnecessary-condition": "off",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
2023-06-29 21:59:08 +02:00
|
|
|
|
"@typescript-eslint/no-unused-vars": [
|
|
|
|
|
"error",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
{args: "all", argsIgnorePattern: "^_", ignoreRestSiblings: true},
|
2023-06-29 21:59:08 +02:00
|
|
|
|
],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"@typescript-eslint/no-use-before-define": ["error", {functions: false}],
|
2023-07-21 23:20:54 +02:00
|
|
|
|
"@typescript-eslint/parameter-properties": "error",
|
2019-06-22 08:00:15 +02:00
|
|
|
|
"@typescript-eslint/promise-function-async": "error",
|
2024-03-28 23:37:28 +01:00
|
|
|
|
"@typescript-eslint/restrict-plus-operands": ["error", {}],
|
|
|
|
|
"@typescript-eslint/restrict-template-expressions": ["error", {}],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"no-undef": "error",
|
|
|
|
|
},
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
2020-08-01 03:43:15 +02:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["**/*.d.ts"],
|
|
|
|
|
rules: {
|
|
|
|
|
"import/unambiguous": "off",
|
|
|
|
|
},
|
2020-08-01 03:43:15 +02:00
|
|
|
|
},
|
2020-07-24 04:33:22 +02:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/e2e-tests/**", "web/tests/**"],
|
|
|
|
|
globals: {
|
|
|
|
|
CSS: false,
|
|
|
|
|
document: false,
|
|
|
|
|
navigator: false,
|
|
|
|
|
window: false,
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
rules: {
|
2021-06-13 21:53:39 +02:00
|
|
|
|
"formatjs/no-id": "off",
|
2021-05-26 19:51:07 +02:00
|
|
|
|
"new-cap": "off",
|
2021-06-08 04:20:35 +02:00
|
|
|
|
"no-sync": "off",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"unicorn/prefer-prototype-methods": "off",
|
|
|
|
|
},
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/debug-require.js"],
|
|
|
|
|
env: {
|
|
|
|
|
browser: true,
|
|
|
|
|
es2020: false,
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
rules: {
|
2020-07-24 04:33:22 +02:00
|
|
|
|
// Don’t require ES features that PhantomJS doesn’t support
|
2020-08-31 00:14:06 +02:00
|
|
|
|
// TODO: Toggle these settings now that we don't use PhantomJS
|
2020-07-24 04:33:22 +02:00
|
|
|
|
"no-var": "off",
|
|
|
|
|
"object-shorthand": "off",
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"prefer-arrow-callback": "off",
|
|
|
|
|
},
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/shared/**", "web/src/**", "web/third/**"],
|
|
|
|
|
env: {
|
|
|
|
|
browser: true,
|
|
|
|
|
node: false,
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
globals: {
|
2024-06-23 03:30:03 +02:00
|
|
|
|
DEVELOPMENT: false,
|
2024-04-26 01:57:26 +02:00
|
|
|
|
ZULIP_VERSION: false,
|
2023-03-03 22:38:01 +01:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
rules: {
|
|
|
|
|
"no-console": "error",
|
2020-08-29 04:29:19 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
settings: {
|
2023-02-24 02:20:53 +01:00
|
|
|
|
"import/resolver": {
|
2024-04-26 01:57:26 +02:00
|
|
|
|
webpack: {
|
|
|
|
|
config: "./web/webpack.config.ts",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-07-24 04:33:22 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/shared/**"],
|
|
|
|
|
env: {
|
|
|
|
|
browser: false,
|
|
|
|
|
"shared-node-browser": true,
|
2020-07-25 21:22:06 +02:00
|
|
|
|
},
|
2024-04-26 01:57:26 +02:00
|
|
|
|
rules: {
|
2020-07-25 21:22:06 +02:00
|
|
|
|
"import/no-restricted-paths": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
zones: [
|
2020-07-25 21:22:06 +02:00
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
target: "./web/shared",
|
|
|
|
|
from: ".",
|
|
|
|
|
except: ["./node_modules", "./web/shared"],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2023-05-26 07:00:58 +02:00
|
|
|
|
],
|
2024-04-26 01:57:26 +02:00
|
|
|
|
"unicorn/prefer-string-replace-all": "off",
|
|
|
|
|
},
|
2024-03-04 21:00:20 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-26 01:57:26 +02:00
|
|
|
|
files: ["web/server/**"],
|
|
|
|
|
env: {
|
|
|
|
|
node: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|