enso/eslint.config.mjs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

560 lines
22 KiB
JavaScript
Raw Normal View History

/** @file ESLint configuration file. */
/**
* NOTE: The "Experimental: Use Flat Config" option must be enabled.
* Flat config is still not quite mature, so is disabled by default.
*/
import * as path from 'node:path'
import * as url from 'node:url'
// The preferred syntax is `import * as name`, however these modules do not support it.
// This is specialcased in other files, but these modules shouldn't be used in other files anyway.
import eslintJs from '@eslint/js'
2024-07-24 11:47:05 +03:00
import tsEslint from '@typescript-eslint/eslint-plugin'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import jsdoc from 'eslint-plugin-jsdoc'
import react from 'eslint-plugin-react'
import reactCompiler from 'eslint-plugin-react-compiler'
import reactHooks from 'eslint-plugin-react-hooks'
import pluginVue from 'eslint-plugin-vue'
2024-07-24 11:47:05 +03:00
import globals from 'globals'
// =================
// === Constants ===
// =================
Fix various issues on the Dashboard (#10256) - Fix React DevTools not working in Firefox - Fix selection of asset names when editing them, not working at all in Firefox - Convert tick/cross buttons when editing assets, and the "plus" and "reload" buttons on the "shared with" column, "labels" column, and keyboard shortcuts table, to match more with the rest of the design - Update clip path when the container resizes, so that the icons for hidden columns never overlap the actual table header - Fix #10184 - Fix renames being committed even when cancelling - Fix duplicate name detection - previously, all asset types only checked folders with the same name, not assets with the same name - I'm not 100% sure this is the correct behavior still - Stop using `kbd` (`aria.Keyboard`) to display keyboard shortcuts, since they should not be displayed in a monospace font. - Fix "plus" and "reload" buttons going past the right side of their parent table cell - Limit length of `PermissionDisplay` - if the username of a user with permission is too long, it uses a tooltip instead - Update the username dynamically for all permissions owned by self, when changing username in the settings. - This avoids having to fully invalidate the directory tree every time the username changes, given that nothing changes about the assets' metadata themselves. - Cache children in the Drive tree - This avoids loading spinners when closing a folder and immediately reopening it. - Note that children are still re-fetched on reopen to ensure freshness # Important Notes - This MAY be split into multiple smaller PRs. However, I think it's better to QA as a single PR, to avoid duplicating work checking behavior that may be changed by a sibling PR (assuming the PR was split into multiple).
2024-06-20 21:30:24 +03:00
const DEBUG_STATEMENTS_MESSAGE = 'Avoid leaving debugging statements when committing code'
const DIR_NAME = path.dirname(url.fileURLToPath(import.meta.url))
const NAME = 'enso'
/**
* An explicit whitelist of CommonJS modules, which do not support namespace imports.
* Many of these have incorrect types, so no type error may not mean they support ESM,
* and conversely type errors may not mean they don't support ESM -
* but we add those to the whitelist anyway otherwise we get type errors.
* In particular, `string-length` supports ESM but its type definitions don't.
* `yargs` is a modules we explicitly want the default imports of.
* `node:process` is here because `process.on` does not exist on the namespace import.
*/
const DEFAULT_IMPORT_ONLY_MODULES =
'@vitejs\\u002Fplugin-react|node:process|chalk|string-length|yargs|yargs\\u002Fyargs|sharp|to-ico|connect|morgan|serve-static|tiny-invariant|clsx|create-servers|electron-is-dev|fast-glob|esbuild-plugin-.+|opener|tailwindcss.*|@modyfi\\u002Fvite-plugin-yaml|build-info|is-network-error|validator.+|.*[.]json$'
const RELATIVE_MODULES =
'projectManager|server|configParser|authentication|config|debug|detect|fileAssociations|index|ipc|log|naming|paths|preload|projectManagement|security|urlAssociations|contentConfig|desktopEnvironment|#\\u002F.*'
const ALLOWED_DEFAULT_IMPORT_MODULES = `${DEFAULT_IMPORT_ONLY_MODULES}|postcss|ajv\\u002Fdist\\u002F2020|${RELATIVE_MODULES}`
const STRING_LITERAL = ':matches(Literal[raw=/^["\']/], TemplateLiteral)'
const NOT_CAMEL_CASE = '/^(?!_?[a-z][a-z0-9*]*([A-Z0-9][a-z0-9]*)*$)(?!React$)/'
const WHITELISTED_CONSTANTS = 'logger|.+Context|interpolationFunction.+'
const NOT_CONSTANT_CASE = `/^(?!${WHITELISTED_CONSTANTS}$|_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)/`
// =======================================
// === Restricted syntactic constructs ===
// =======================================
// Extracted to a variable because it needs to be used twice:
// - once as-is for `.d.ts`
// - once explicitly disallowing `declare`s in regular `.ts`.
const RESTRICTED_SYNTAXES = [
{
selector: `ImportDeclaration[source.value=/^(?!(${ALLOWED_DEFAULT_IMPORT_MODULES})$)[^.]/] > ImportDefaultSpecifier`,
message:
'No default imports from modules. Add to `DEFAULT_IMPORT_ONLY_MODULES` in `eslint.config.js` if the module only has a default export.',
},
{
selector: `ImportDeclaration[source.value=/^(?:${DEFAULT_IMPORT_ONLY_MODULES})$/] > ImportNamespaceSpecifier`,
message: 'No namespace imports from modules that only have a default import',
},
{
selector: `ImportDeclaration[source.value=/\\.(?:json|yaml|yml)$/] > ImportDefaultSpecifier[local.name=${NOT_CONSTANT_CASE}]`,
message: 'Use `CONSTANT_CASE` for imports from data files',
},
{
selector: `ImportDeclaration[source.value=/\\.json$/]:not(:has(ImportAttribute[key.name=type][value.value=json]))`,
message: "JSON imports must be { type: 'json' }",
},
{
selector: `ImportDeclaration[source.value=/\\.(?:yaml|yml)$/]:not(:has(ImportAttribute[key.name=type][value.value=yaml]))`,
message: "YAML imports must be { type: 'yaml' }",
},
{
selector: `ImportDeclaration[source.value=/\\.(?:json|yaml|yml)$/] > ImportNamespaceSpecifier`,
message: 'Use default imports for imports from data files',
},
{
selector: `ImportNamespaceSpecifier > Identifier[name=${NOT_CAMEL_CASE}]`,
message: 'Use `camelCase` for imports',
},
{
selector: `:matches(ImportDefaultSpecifier[local.name=/^${NAME}/i], ImportNamespaceSpecifier > Identifier[name=/^${NAME}/i])`,
message: `Don't prefix modules with \`${NAME}\``,
},
{
selector: 'ForOfStatement > .left[kind=let]',
message: 'Use `for (const x of xs)`, not `for (let x of xs)`',
},
{
selector: 'TSTypeAliasDeclaration > :matches(TSLiteralType)',
message: 'No aliases to literal types',
},
{
selector:
'TSTypeAliasDeclaration > :matches(TSBooleanKeyword, TSBigintKeyword, TSNullKeyword, TSNumberKeyword, TSObjectKeyword, TSStringKeyword, TSSymbolKeyword, TSUndefinedKeyword, TSUnknownKeyword, TSVoidKeyword)',
message:
'No aliases to primitives - consider using brands instead: `string & { _brand: "BrandName"; }`',
},
{
// Matches non-functions.
Keyboard navigation between components (#9499) - Close https://github.com/enso-org/cloud-v2/issues/982 - Add keyboard navigation via arrows between different components - This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements. Other changes: - Switch much of the codebase to use `react-aria-components` - This *should* (but does not necessarily) give us improved accessibility for free. - Refactor various common styles into styled components - `FocusArea` to perform automatic registration with `Navigator2D` - `Button` and `UnstyledButton` to let buttons participate in keyboard navigation - `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page - `SettingsPage` in the settings pages - `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section - Add debugging utilities - Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''` - This adds rings around elements (all with different colors): - That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`. - That are `:focus`ed, and that are `:focus-visible` - That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`. - Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''` - This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive. # Important Notes - :warning: Modals and the authentication flow are not yet fully tested. - Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar. - There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult. - Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing - It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard - Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to) - The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation. - This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table - Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above. - Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
selector: `:matches(Program, ExportNamedDeclaration, TSModuleBlock) > VariableDeclaration[kind=const] > VariableDeclarator[id.name=${NOT_CONSTANT_CASE}]:not(:matches([init.callee.object.name=React][init.callee.property.name=forwardRef], :has(ArrowFunctionExpression), :has(CallExpression[callee.object.name=newtype][callee.property.name=newtypeConstructor])))`,
message: 'Use `CONSTANT_CASE` for top-level constants that are not functions',
},
{
selector: `:matches(Program, ExportNamedDeclaration, TSModuleBlock) > VariableDeclaration > VariableDeclarator > ArrowFunctionExpression`,
message: 'Use `function foo() {}` instead of `const foo = () => {}`',
},
{
selector: `ClassBody > PropertyDefinition > ArrowFunctionExpression`,
message: 'Use `foo() {}` instead of `foo = () => {}`',
},
{
// This lint intentionally excludes classes and readonly arrays.
selector: 'TSInterfaceBody:has(TSPropertySignature[readonly=false])',
message: 'Add `readonly` modifier to all interface properties',
},
{
selector: `TSAsExpression:not(:has(TSTypeReference > Identifier[name=const]))`,
message: 'Avoid `as T`. Consider using a type annotation instead.',
},
{
selector: 'ExportNamedDeclaration > VariableDeclaration[kind=let]',
message: 'Use `export const` instead of `export let`',
},
{
selector: `Program > VariableDeclaration[kind=let] > * > ObjectExpression:has(Property > ${STRING_LITERAL}.value):not(:has(Property > .value:not(${STRING_LITERAL})))`,
message:
'Use `const` instead of `let` for top-level object literals only containing string literals',
},
{
selector:
'ImportDeclaration[source.value=/^(?:assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|diagnostics_channel|dns|domain|events|fs|fs\\u002Fpromises|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|timers|tls|trace_events|tty|url|util|v8|vm|wasi|worker_threads|zlib)$/]',
message: 'Use `node:` prefix to import builtin node modules',
},
{
selector: 'TSEnumDeclaration:not(:has(TSEnumMember))',
message: 'Enums must not be empty',
},
{
selector: 'TSAsExpression:has(TSUnknownKeyword, TSNeverKeyword, TSAnyKeyword) > TSAsExpression',
message: 'Use type assertions to specific types instead of `unknown`, `any` or `never`',
},
{
selector: ':matches(MethodDeclaration, FunctionDeclaration) FunctionDeclaration',
message: 'Use arrow functions for nested functions',
},
{
selector: 'IfStatement > ExpressionStatement',
message: 'Wrap `if` branches in `{}`',
},
Split `dashboard.tsx` into smaller components (#6546) * Consistent order for statements in `dashboard.tsx`; change functions back to lambdas * Create convenience aliases for each asset type * Remove obsolete FIXME * Refactor out column renderers into components * Enable `prefer-const` lint * Remove hardcoded product name * Add fixme * Enable `react-hooks` lints (not working for some reason) * Consistent messages for naming-convention lint overrides * Enable `react` lints * Extract out tables for each asset type * Refactor out column display mode switcher to a file * Switch VM check state to use an enum * Fix lint errors * Minor section change * Fix position of create forms * Fix bugs; improve debugging QoL * Add documentation for new components * Refactor out drive bar * Refactor out event handlers to variables * Minor clarifications * Refactor out directory view; some fixes; improve React DX There are still many issues when switching backends * Add `assert` * Use `backend.platform` instead of checking for properties * Fix errors when switching backend * Minor style changes; fix lint errors * Fix assert behavior * Change `Rows` to `Table` * Fixes * Fix lint errors * Fix "show dashboard" button * Implement click to rename * Fix lint errors * Fix lint errors (along with a bug in `devServiceWorker`) * Enable dev-mode on `ide watch` * Fix bug in `useAsyncEffect` introduced during merge * More fixes; new debug hooks; fix infinite loop in `auth.tsx` * Inline Cognito methods * Remove redundant `Promise.resolve`s * Fix column display * Fixes * Simplify modal type * Fix bug when opening IDE * Shift+click to select a range of table items * Implement delete multiple * Fixes * Tick and cross for rename input; fixes * Implement rename and delete directory and multi-delete directory; fixes * Optimize modal re-rendering * Make some internal `Props` private * Remove old asset selection code * Eliminate re-renders when clicking document body * Fix name flickering when renaming * Use static placeholders * Avoid refreshing entire directory on rename * Use asset name instead of ID in error messages * QoL improvements * Enable react lints and `strict-boolean-expressions` * Extract dashboard feature flags to its own module * Feature flag to show more toasts; minimize calls to `listDirectory` * Deselect selection on delete; hide unused features; add exception to PascalCase lint * Fix projects disappearing after being created * Fix name of `projectEvent` module imports * Re-disable delete when project is being closed * Fix assets refreshing when adding new projects * Refactor row state into `Table`; fix delete not being disabled again * Address review * Implement shortcut registry * Fix stop icon spinning when switching backends (ported from #6919) * Give columns names * Immediately show project as opening * Replace `asNewtype` with constructor functions * Address review * Minor bugfixes * Prepare for optimistically updated tables * wip 2 * Fix type errors * Remove indirect usages of `doRefresh` Updating the lists of items will need to be re-added later * Remove `toastPromise` * Fix `New_Directory_-Infinity` bug * wip * WIP: Begin restoring functionality to rows * Fix most issues with DirectoriesTable * Port optimistic UI from `DirectoriesTable` to all other asset tables * Fix bugs in item list events for asset tables * Merge `projectActionButton` into `projectsTable` * Remove `RenameModal`; minor context menu bugfixes * Fix bugs * Remove small default user icon * Fix more bugs * Fix bugs * Fix type error * Address review and QA * Fix optimistic UI for "manage permissions" modal * Fix "share with" modal * Fix template spinner disappearing * Allow multiple projects to be opened on local backend; fix version lifecycle returned by local backend * Fix minor bug when closing local project --------- Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
2023-07-19 12:48:39 +03:00
{
selector: ':matches(ForStatement[test=null], ForStatement[test.value=true])',
message: 'Use `while (true)` instead of `for (;;)`',
},
{
selector: `:matches(\
JSXAttribute[name.name=/^(?:alt|error|label|placeholder|text|title|actionButtonLabel|actionText|aria-label)$/][value.raw=/^'|^"|^\`/], \
JSXText[value=/\\S/], \
JSXAttribute[name.name=/^(?:alt|error|label|placeholder|text|title|actionButtonLabel|actionText|aria-label)$/] ConditionalExpression:matches(\
[consequent.raw=/^'|^"|^\`/], \
[alternate.raw=/^'|^"|^\`/]\
)\
)`,
message: 'Use a `getText()` from `useText` instead of a literal string',
},
{
selector: `JSXAttribute[name.name=/^(?:className)$/] TemplateLiteral`,
message:
Fix various issues on the Dashboard (#10256) - Fix React DevTools not working in Firefox - Fix selection of asset names when editing them, not working at all in Firefox - Convert tick/cross buttons when editing assets, and the "plus" and "reload" buttons on the "shared with" column, "labels" column, and keyboard shortcuts table, to match more with the rest of the design - Update clip path when the container resizes, so that the icons for hidden columns never overlap the actual table header - Fix #10184 - Fix renames being committed even when cancelling - Fix duplicate name detection - previously, all asset types only checked folders with the same name, not assets with the same name - I'm not 100% sure this is the correct behavior still - Stop using `kbd` (`aria.Keyboard`) to display keyboard shortcuts, since they should not be displayed in a monospace font. - Fix "plus" and "reload" buttons going past the right side of their parent table cell - Limit length of `PermissionDisplay` - if the username of a user with permission is too long, it uses a tooltip instead - Update the username dynamically for all permissions owned by self, when changing username in the settings. - This avoids having to fully invalidate the directory tree every time the username changes, given that nothing changes about the assets' metadata themselves. - Cache children in the Drive tree - This avoids loading spinners when closing a folder and immediately reopening it. - Note that children are still re-fetched on reopen to ensure freshness # Important Notes - This MAY be split into multiple smaller PRs. However, I think it's better to QA as a single PR, to avoid duplicating work checking behavior that may be changed by a sibling PR (assuming the PR was split into multiple).
2024-06-20 21:30:24 +03:00
'Use `tv` from `#/utilities/tailwindVariants` or `twMerge` from `tailwind-merge` instead of template strings for classes',
},
Keyboard navigation between components (#9499) - Close https://github.com/enso-org/cloud-v2/issues/982 - Add keyboard navigation via arrows between different components - This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements. Other changes: - Switch much of the codebase to use `react-aria-components` - This *should* (but does not necessarily) give us improved accessibility for free. - Refactor various common styles into styled components - `FocusArea` to perform automatic registration with `Navigator2D` - `Button` and `UnstyledButton` to let buttons participate in keyboard navigation - `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page - `SettingsPage` in the settings pages - `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section - Add debugging utilities - Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''` - This adds rings around elements (all with different colors): - That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`. - That are `:focus`ed, and that are `:focus-visible` - That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`. - Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''` - This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive. # Important Notes - :warning: Modals and the authentication flow are not yet fully tested. - Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar. - There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult. - Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing - It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard - Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to) - The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation. - This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table - Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above. - Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
{
selector: 'JSXOpeningElement[name.name=button] > JSXIdentifier',
message: 'Use `Button` or `UnstyledButton` instead of `button`',
},
{
selector: 'JSXOpeningElement[name.name=/^h[123456]$/] > JSXIdentifier',
message: 'Use `aria.Heading` instead of `h1`-`h6`',
},
]
// ============================
// === ESLint configuration ===
// ============================
export default [
{
// Playwright build cache and Vite build directory.
ignores: [
'**/.cache/**',
'**/playwright-report',
'**/dist',
'**/mockDist',
'**/build.mjs',
'**/*.timestamp-*.mjs',
'**/node_modules',
'**/generated',
'app/rust-ffi/pkg/',
],
},
eslintJs.configs.recommended,
...pluginVue.configs['flat/recommended'],
...vueTsEslintConfig(),
{
// files: ['{**,src}/*.{vue,js,jsx,cjs,mjs,ts,tsx,cts,mts}'],
languageOptions: {
parserOptions: {
tsconfigRootDir: DIR_NAME,
ecmaVersion: 'latest',
extraFileExtensions: ['.vue'],
projectService: {
allowDefaultProject: [
'app/ydoc-server/vitest.config.ts',
'app/ydoc-shared/vitest.config.ts',
],
},
},
},
rules: {
camelcase: ['warn', { ignoreImports: true, ignoreDestructuring: true }],
'no-inner-declarations': 'off',
'vue/attribute-hyphenation': ['error', 'never'],
'vue/v-on-event-hyphenation': ['error', 'never'],
'vue/singleline-html-element-content-newline': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-namespace': 'off',
Move documentation into documentable types (#11441) Move documentation into documentable types (implements #11302). # Important Notes GUI: - Distinguish expression and statement - `Ast.Ast` is still present, as the base class for AST objects. Most references to `Ast.Ast` are now references to `Ast.Expression`. Operations on blocks use `Ast.Statement`. - `Ast.parse` has been replaced with: `Ast.parseExpression`, `Ast.parseStatement`, and `Ast.parseBlock` - `syncToCode` is internally context-aware; it parses the provided code appropriately depending on whether its AST is an expression, a statement, or the top level of a module. - Remove `wrappingExpression` / `innerExpression` APIs: Wrapper types have been eliminated; modifier lines are now fields inside parent types. - Simplify AST printing: - Fully implemented autospacing in `concreteChildren` implementations; the type returned by `concreteChildren` now ensures that spacing has been fully resolved. - Eliminate `printBlock` / `printDocs`: `concreteChildren` is now aware of indentation context, and responsible for indentation of its child lines. - The `Pattern` type is now parameterized to identify the AST type it constructs. The `Pattern.parseExpression` function helps create a `Pattern<Expression>`. - Refactor `performCollape` for testability. - e2e tests: Improve table viz test: It still doesn't pass on my Mac, but these changes are necessary if not sufficient. Compiler (TreeToIr): - An expression in statement context is now found in an `ExpressionStatement` wrapper. - Documentation for a `Function` is now found inside the function node. - Deduplicate some polyglot-function logic.
2024-11-04 18:33:53 +03:00
// Empty interfaces have valid uses; e.g. although an empty interface extending a class is semantically equivalent
// to a type alias, it is not resolved by IDEs to the base type (which may be internal).
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'always' }],
'no-unused-labels': 'off',
// Taken care of by prettier
'vue/max-attributes-per-line': 'off',
'vue/html-indent': 'off',
'vue/html-closing-bracket-newline': 'off',
// TODO[ao]; off temporarily
'@typescript-eslint/no-explicit-any': 'off',
'vue/html-self-closing': 'off',
},
},
{
files: ['app/gui/templates/*.vue'],
rules: {
'vue/multi-word-component-names': 0,
},
},
// JsDoc lints for typescript - the recommended set with some modifications.
{
ignores: ['**/*.js'],
...jsdoc.configs['flat/recommended-typescript'],
rules: {
...jsdoc.configs['flat/recommended-typescript'].rules,
'jsdoc/check-param-names': [
'warn',
{ checkDestructured: false, disableMissingParamChecks: true },
],
'jsdoc/require-jsdoc': [
'warn',
{
publicOnly: true,
require: {
FunctionDeclaration: true,
MethodDefinition: true,
ClassDeclaration: true,
ArrowFunctionExpression: false,
FunctionExpression: true,
},
},
],
'jsdoc/require-param': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-yields': 'off',
},
},
// === Dashboard Rules ===
{
files: [
'app/gui/src/dashboard/**/*.ts',
'app/gui/src/dashboard/**/*.mts',
'app/gui/src/dashboard/**/*.cts',
'app/gui/src/dashboard/**/*.tsx',
'app/gui/src/dashboard/**/*.mtsx',
'app/gui/src/dashboard/**/*.ctsx',
],
settings: {
react: {
version: '18.2',
2024-07-26 09:34:51 +03:00
},
},
plugins: {
jsdoc: jsdoc,
'@typescript-eslint': tsEslint,
react: react,
'react-hooks': reactHooks,
'react-compiler': reactCompiler,
2024-07-26 09:34:51 +03:00
},
languageOptions: {
parserOptions: {
tsconfigRootDir: DIR_NAME,
projectService: true,
2024-07-26 09:34:51 +03:00
},
globals: {
...globals.browser,
...globals.node,
...globals.es2015,
2024-07-26 09:34:51 +03:00
},
},
rules: {
...tsEslint.configs['eslint-recommended']?.rules,
...tsEslint.configs.recommended?.rules,
...tsEslint.configs['recommended-requiring-type-checking']?.rules,
...tsEslint.configs.strict?.rules,
...react.configs['jsx-runtime'].rules,
eqeqeq: ['error', 'always', { null: 'never' }],
Keyboard navigation between components (#9499) - Close https://github.com/enso-org/cloud-v2/issues/982 - Add keyboard navigation via arrows between different components - This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements. Other changes: - Switch much of the codebase to use `react-aria-components` - This *should* (but does not necessarily) give us improved accessibility for free. - Refactor various common styles into styled components - `FocusArea` to perform automatic registration with `Navigator2D` - `Button` and `UnstyledButton` to let buttons participate in keyboard navigation - `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page - `SettingsPage` in the settings pages - `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section - Add debugging utilities - Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''` - This adds rings around elements (all with different colors): - That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`. - That are `:focus`ed, and that are `:focus-visible` - That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`. - Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''` - This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive. # Important Notes - :warning: Modals and the authentication flow are not yet fully tested. - Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar. - There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult. - Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing - It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard - Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to) - The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation. - This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table - Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above. - Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
// Any extra semicolons that exist, are required by Prettier.
'no-extra-semi': 'off',
'jsdoc/require-jsdoc': [
2024-07-26 09:34:51 +03:00
'error',
{
require: {
FunctionDeclaration: true,
MethodDefinition: true,
ClassDeclaration: true,
ArrowFunctionExpression: false,
FunctionExpression: true,
},
// Top-level constants should require JSDoc as well,
// however it does not seem like there is a way to do this.
contexts: [
'TSInterfaceDeclaration',
'TSEnumDeclaration',
'TSTypeAliasDeclaration',
'TSMethodSignature',
2024-07-26 09:34:51 +03:00
],
},
2024-07-26 09:34:51 +03:00
],
'no-constant-condition': ['error', { checkLoops: false }],
'no-restricted-syntax': ['error', ...RESTRICTED_SYNTAXES],
'no-restricted-properties': [
'error',
{ object: 'console', message: DEBUG_STATEMENTS_MESSAGE },
{ property: 'useDebugState', message: DEBUG_STATEMENTS_MESSAGE },
{ property: 'useDebugEffect', message: DEBUG_STATEMENTS_MESSAGE },
{ property: 'useDebugMemo', message: DEBUG_STATEMENTS_MESSAGE },
{ property: 'useDebugCallback', message: DEBUG_STATEMENTS_MESSAGE },
{
object: 'page',
property: 'type',
message: 'Prefer `locator.type` instead',
},
{
object: 'page',
property: 'click',
message: 'Prefer `locator.click` instead',
},
{
object: 'page',
property: 'fill',
message: 'Prefer `locator.fill` instead',
},
{
object: 'page',
property: 'locator',
message: 'Prefer `page.getBy*` instead',
},
],
'prefer-const': 'error',
Fix various issues on the Dashboard (#10256) - Fix React DevTools not working in Firefox - Fix selection of asset names when editing them, not working at all in Firefox - Convert tick/cross buttons when editing assets, and the "plus" and "reload" buttons on the "shared with" column, "labels" column, and keyboard shortcuts table, to match more with the rest of the design - Update clip path when the container resizes, so that the icons for hidden columns never overlap the actual table header - Fix #10184 - Fix renames being committed even when cancelling - Fix duplicate name detection - previously, all asset types only checked folders with the same name, not assets with the same name - I'm not 100% sure this is the correct behavior still - Stop using `kbd` (`aria.Keyboard`) to display keyboard shortcuts, since they should not be displayed in a monospace font. - Fix "plus" and "reload" buttons going past the right side of their parent table cell - Limit length of `PermissionDisplay` - if the username of a user with permission is too long, it uses a tooltip instead - Update the username dynamically for all permissions owned by self, when changing username in the settings. - This avoids having to fully invalidate the directory tree every time the username changes, given that nothing changes about the assets' metadata themselves. - Cache children in the Drive tree - This avoids loading spinners when closing a folder and immediately reopening it. - Note that children are still re-fetched on reopen to ensure freshness # Important Notes - This MAY be split into multiple smaller PRs. However, I think it's better to QA as a single PR, to avoid duplicating work checking behavior that may be changed by a sibling PR (assuming the PR was split into multiple).
2024-06-20 21:30:24 +03:00
'react/forbid-elements': [
2024-07-26 09:34:51 +03:00
'error',
{ forbid: [{ element: 'Debug', message: DEBUG_STATEMENTS_MESSAGE }] },
2024-07-26 09:34:51 +03:00
],
// Not relevant because TypeScript checks types.
'react/prop-types': 'off',
'react/self-closing-comp': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': ['error', { additionalHooks: 'useOnScroll' }],
'react/jsx-pascal-case': ['error', { allowNamespace: true }],
// We use warnings instead of errors because we want to gradually migrate the codebase to the new compiler.
// see: https://github.com/reactwg/react-compiler/discussions/8
'react-compiler/react-compiler': 'warn',
// Prefer `interface` over `type`.
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/member-ordering': 'error',
// Method syntax is not type-safe.
// See: https://typescript-eslint.io/rules/method-signature-style
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/naming-convention': [
2024-07-26 09:34:51 +03:00
'error',
{
selector: ['function'],
// PascalCase for React components, camelCase for all other situations
format: ['camelCase', 'PascalCase'],
},
{
selector: ['variable'],
modifiers: ['const', 'global'],
format: ['UPPER_CASE', 'camelCase', 'PascalCase'],
},
Split `dashboard.tsx` into smaller components (#6546) * Consistent order for statements in `dashboard.tsx`; change functions back to lambdas * Create convenience aliases for each asset type * Remove obsolete FIXME * Refactor out column renderers into components * Enable `prefer-const` lint * Remove hardcoded product name * Add fixme * Enable `react-hooks` lints (not working for some reason) * Consistent messages for naming-convention lint overrides * Enable `react` lints * Extract out tables for each asset type * Refactor out column display mode switcher to a file * Switch VM check state to use an enum * Fix lint errors * Minor section change * Fix position of create forms * Fix bugs; improve debugging QoL * Add documentation for new components * Refactor out drive bar * Refactor out event handlers to variables * Minor clarifications * Refactor out directory view; some fixes; improve React DX There are still many issues when switching backends * Add `assert` * Use `backend.platform` instead of checking for properties * Fix errors when switching backend * Minor style changes; fix lint errors * Fix assert behavior * Change `Rows` to `Table` * Fixes * Fix lint errors * Fix "show dashboard" button * Implement click to rename * Fix lint errors * Fix lint errors (along with a bug in `devServiceWorker`) * Enable dev-mode on `ide watch` * Fix bug in `useAsyncEffect` introduced during merge * More fixes; new debug hooks; fix infinite loop in `auth.tsx` * Inline Cognito methods * Remove redundant `Promise.resolve`s * Fix column display * Fixes * Simplify modal type * Fix bug when opening IDE * Shift+click to select a range of table items * Implement delete multiple * Fixes * Tick and cross for rename input; fixes * Implement rename and delete directory and multi-delete directory; fixes * Optimize modal re-rendering * Make some internal `Props` private * Remove old asset selection code * Eliminate re-renders when clicking document body * Fix name flickering when renaming * Use static placeholders * Avoid refreshing entire directory on rename * Use asset name instead of ID in error messages * QoL improvements * Enable react lints and `strict-boolean-expressions` * Extract dashboard feature flags to its own module * Feature flag to show more toasts; minimize calls to `listDirectory` * Deselect selection on delete; hide unused features; add exception to PascalCase lint * Fix projects disappearing after being created * Fix name of `projectEvent` module imports * Re-disable delete when project is being closed * Fix assets refreshing when adding new projects * Refactor row state into `Table`; fix delete not being disabled again * Address review * Implement shortcut registry * Fix stop icon spinning when switching backends (ported from #6919) * Give columns names * Immediately show project as opening * Replace `asNewtype` with constructor functions * Address review * Minor bugfixes * Prepare for optimistically updated tables * wip 2 * Fix type errors * Remove indirect usages of `doRefresh` Updating the lists of items will need to be re-added later * Remove `toastPromise` * Fix `New_Directory_-Infinity` bug * wip * WIP: Begin restoring functionality to rows * Fix most issues with DirectoriesTable * Port optimistic UI from `DirectoriesTable` to all other asset tables * Fix bugs in item list events for asset tables * Merge `projectActionButton` into `projectsTable` * Remove `RenameModal`; minor context menu bugfixes * Fix bugs * Remove small default user icon * Fix more bugs * Fix bugs * Fix type error * Address review and QA * Fix optimistic UI for "manage permissions" modal * Fix "share with" modal * Fix template spinner disappearing * Allow multiple projects to be opened on local backend; fix version lifecycle returned by local backend * Fix minor bug when closing local project --------- Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
2023-07-19 12:48:39 +03:00
{
selector: ['variable'],
modifiers: ['const', 'exported'],
format: ['UPPER_CASE', 'camelCase', 'PascalCase'],
},
{
selector: ['variable'],
format: ['camelCase', 'PascalCase'],
},
{
selector: ['parameter', 'method'],
format: ['camelCase'],
},
{
selector: ['parameter'],
modifiers: ['unused'],
Fix various issues on the Dashboard (#10256) - Fix React DevTools not working in Firefox - Fix selection of asset names when editing them, not working at all in Firefox - Convert tick/cross buttons when editing assets, and the "plus" and "reload" buttons on the "shared with" column, "labels" column, and keyboard shortcuts table, to match more with the rest of the design - Update clip path when the container resizes, so that the icons for hidden columns never overlap the actual table header - Fix #10184 - Fix renames being committed even when cancelling - Fix duplicate name detection - previously, all asset types only checked folders with the same name, not assets with the same name - I'm not 100% sure this is the correct behavior still - Stop using `kbd` (`aria.Keyboard`) to display keyboard shortcuts, since they should not be displayed in a monospace font. - Fix "plus" and "reload" buttons going past the right side of their parent table cell - Limit length of `PermissionDisplay` - if the username of a user with permission is too long, it uses a tooltip instead - Update the username dynamically for all permissions owned by self, when changing username in the settings. - This avoids having to fully invalidate the directory tree every time the username changes, given that nothing changes about the assets' metadata themselves. - Cache children in the Drive tree - This avoids loading spinners when closing a folder and immediately reopening it. - Note that children are still re-fetched on reopen to ensure freshness # Important Notes - This MAY be split into multiple smaller PRs. However, I think it's better to QA as a single PR, to avoid duplicating work checking behavior that may be changed by a sibling PR (assuming the PR was split into multiple).
2024-06-20 21:30:24 +03:00
format: ['camelCase'],
leadingUnderscore: 'require',
},
{
selector: ['property'],
format: ['camelCase'],
filter: {
regex: '^(?:data-testid)$',
match: false,
},
},
2024-07-26 09:34:51 +03:00
],
'@typescript-eslint/no-confusing-void-expression': 'error',
Dashboard directory interactivity (#6279) * turn object into var * add todo * fix style * fixes * remove forgot password + reset password * remove signout * remove setusername * remove login * remove registration * fix comments * re-enable flag * rename div * add comment * fix lints * remove tailwind conf * Revert "remove registration" This reverts commit 02439c9b709f5f7bdab72171d2706bec45cdfe6e. * Revert "remove login" This reverts commit 8e6f9c11122142c41faddef8a857cd3546d81fab. * Revert "remove setusername" This reverts commit 84721bcccd12b83c05f79505a5e7b444505e7917. * Revert "remove signout" This reverts commit 08a96d3796108f32d3f26317b01248bdfe59c5fa. * Revert "remove forgot password + reset password" This reverts commit e52f51a76253894041c32f9bff4e33690b354176. * remove opener * move opener * tmp * prettier * expand docs * tmp * replace react-scripts with craco * add tailwindcss * switch to brands * tmp * tmp * tmp * fixmes * fixmes * fixmes * fixmes * fixmes * fixes for e-hern's comments * use abortcontroller * add docs * fixes * revert craco, fix windows build * remove from gitignore * remove unnecessary check * tmp * augment window * tmptmp * split errors back up * tmp * tmp * prettier * fix * Fix lints * Prepare for addition for `as T` lint * Add lint for early returns * Address review issues * Fix lints * remove withrouter * fix file length * fixes * fixes * remove dashboard * fix * use switch * prettier * fixes * prettier * fixes * run prettier * run prettier * run prettier * fix main page url * allow node.js debugging * fix lints * change not equal * prettier * Remove references to withRouter; fix lints * Run prettier * Add cloud endpoints * Add JSON-RPC endpoints * Add dashboard skeleton * Add components and edit dashboard * Run prettier * (WIP) Add cloud endpoints * Add rpc endpoints * Address review issues * Formatting and minor fixes for `newtype.ts` * Address review issues * Rename `Brand` to `NewtypeVariant` * Rename `Brand` to `NewtypeVariant` * Fix formatting in `newtype.ts` * Switch dashboard to esbuild * Minor fixes; move Tailwind generation into esbuild-config * Fix watching `content/` and `client/` * Bump esbuild binary versions; minor dependency list fixes * Add dashboard skeleton * Run prettier * Fixes; rename "npm run dev" to "npm run watch-dashboard" * Avoid writing esbuild outputs to disk for `dashboard/` * Convert watch-dashboard to be fully in-memory; rebuild css files on change * Remove obsolete FIXME * Remove unused constants * Run prettier * add missing styles * Fixes * Fix the fixes * Run prettier * Fixes; use nesting plugin to wrap tailwind preflight * Remove testing flag from client/watch * Minor fixes * Run prettier * Export newtypes * Make css rebuild when tailwind config changes * Fix endpoints * Finish copying changes over * Remove duplicate type definitions * Fix bundling for dashboard * Fix dashboard/bundle.ts erroring when build directory does not exist * Move CSS to Tailwind config * Run prettier * Update endpoints * Fix esbuild binary package names * Remove redundant "npx" prefix from build scripts * Remove unused dependency * Begin adding interactivity * workaround for mac freeze * Fix modal bugs * Begin implementing forms, split forms and modals into new files * Get form UI working * add missing sections * Minor fixes, save current directory to localStorage * Fixes for drop-to-upload Note: currently it is opening in a new tab instead of actually uploading * Address review issue * Fix prettier config; run prettier * Fix live-reload of `npm run watch-dashboard` * (WIP) * Fix service worker for client-side routing * Add close button to asset creation forms; fix saving directory to localStorage * Remove workaround for backend bug when listing directories * Fix drop-to-upload * Fix sizing * Fix spacing, add fixed paths * WIP: fix toast notification styles, begin adding context menu * WIP: Add context menu, minor fixes * Fix authentication on desktop IDE * Allow unused locals and parameters in tsconfig.json * Run prettier * Fix TypeScript errors * Fix modals; minor refactor * Implement context menus for labels; fixes * Add modal provider and switch all modals to provider; fixes * Fix modals and user icon size * Fixes * Remove obsolete files from incorrect merge * Address review issues * Fix type error * Stop removing `#root` * Fixes for cloud * Implement search on frontend side * Fix race condition related to `directoryId` * Hide directories, files and secrets tables on desktop IDE * Fix lint errors * Properly update visible projects when a project is created * Pass directory id to create project * Hide column display switcher; remove placeholder column data --------- Co-authored-by: Nikita Pekin <nikita@frecency.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
2023-04-26 12:52:13 +03:00
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-invalid-void-type': ['error', { allowAsThisParameter: true }],
// React 17 and later supports async functions as event handlers, so we need to disable this
// rule to avoid false positives.
2024-07-26 09:34:51 +03:00
//
// See: https://github.com/typescript-eslint/typescript-eslint/pull/4623
'@typescript-eslint/no-misused-promises': [
2024-07-26 09:34:51 +03:00
'error',
{ checksVoidReturn: { attributes: false } },
2024-07-26 09:34:51 +03:00
],
'@typescript-eslint/no-redundant-type-constituents': 'error',
Split `dashboard.tsx` into smaller components (#6546) * Consistent order for statements in `dashboard.tsx`; change functions back to lambdas * Create convenience aliases for each asset type * Remove obsolete FIXME * Refactor out column renderers into components * Enable `prefer-const` lint * Remove hardcoded product name * Add fixme * Enable `react-hooks` lints (not working for some reason) * Consistent messages for naming-convention lint overrides * Enable `react` lints * Extract out tables for each asset type * Refactor out column display mode switcher to a file * Switch VM check state to use an enum * Fix lint errors * Minor section change * Fix position of create forms * Fix bugs; improve debugging QoL * Add documentation for new components * Refactor out drive bar * Refactor out event handlers to variables * Minor clarifications * Refactor out directory view; some fixes; improve React DX There are still many issues when switching backends * Add `assert` * Use `backend.platform` instead of checking for properties * Fix errors when switching backend * Minor style changes; fix lint errors * Fix assert behavior * Change `Rows` to `Table` * Fixes * Fix lint errors * Fix "show dashboard" button * Implement click to rename * Fix lint errors * Fix lint errors (along with a bug in `devServiceWorker`) * Enable dev-mode on `ide watch` * Fix bug in `useAsyncEffect` introduced during merge * More fixes; new debug hooks; fix infinite loop in `auth.tsx` * Inline Cognito methods * Remove redundant `Promise.resolve`s * Fix column display * Fixes * Simplify modal type * Fix bug when opening IDE * Shift+click to select a range of table items * Implement delete multiple * Fixes * Tick and cross for rename input; fixes * Implement rename and delete directory and multi-delete directory; fixes * Optimize modal re-rendering * Make some internal `Props` private * Remove old asset selection code * Eliminate re-renders when clicking document body * Fix name flickering when renaming * Use static placeholders * Avoid refreshing entire directory on rename * Use asset name instead of ID in error messages * QoL improvements * Enable react lints and `strict-boolean-expressions` * Extract dashboard feature flags to its own module * Feature flag to show more toasts; minimize calls to `listDirectory` * Deselect selection on delete; hide unused features; add exception to PascalCase lint * Fix projects disappearing after being created * Fix name of `projectEvent` module imports * Re-disable delete when project is being closed * Fix assets refreshing when adding new projects * Refactor row state into `Table`; fix delete not being disabled again * Address review * Implement shortcut registry * Fix stop icon spinning when switching backends (ported from #6919) * Give columns names * Immediately show project as opening * Replace `asNewtype` with constructor functions * Address review * Minor bugfixes * Prepare for optimistically updated tables * wip 2 * Fix type errors * Remove indirect usages of `doRefresh` Updating the lists of items will need to be re-added later * Remove `toastPromise` * Fix `New_Directory_-Infinity` bug * wip * WIP: Begin restoring functionality to rows * Fix most issues with DirectoriesTable * Port optimistic UI from `DirectoriesTable` to all other asset tables * Fix bugs in item list events for asset tables * Merge `projectActionButton` into `projectsTable` * Remove `RenameModal`; minor context menu bugfixes * Fix bugs * Remove small default user icon * Fix more bugs * Fix bugs * Fix type error * Address review and QA * Fix optimistic UI for "manage permissions" modal * Fix "share with" modal * Fix template spinner disappearing * Allow multiple projects to be opened on local backend; fix version lifecycle returned by local backend * Fix minor bug when closing local project --------- Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
2023-07-19 12:48:39 +03:00
'@typescript-eslint/no-unnecessary-condition': [
2024-07-26 09:34:51 +03:00
'error',
{ allowConstantLoopConditions: true },
2024-07-26 09:34:51 +03:00
],
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/parameter-properties': ['error', { prefer: 'parameter-property' }],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/sort-type-constituents': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': ['error', { capIsConstructor: false }],
'jsdoc/no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': [
2024-07-26 09:34:51 +03:00
'error',
{
ignore: [-1, 0, 1, 2, 3, 4, 5],
ignoreArrayIndexes: true,
ignoreEnums: true,
detectObjects: true,
enforceConst: true,
},
],
'no-redeclare': 'off',
// Important to warn on accidental duplicated `interface`s e.g. when writing API wrappers.
'@typescript-eslint/no-redeclare': ['error', { ignoreDeclarationMerge: false }],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
'jsdoc/require-param-type': 'off',
'jsdoc/check-access': 'error',
'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': 'error',
'jsdoc/check-line-alignment': 'error',
'jsdoc/check-param-names': 'error',
'jsdoc/check-property-names': 'error',
'jsdoc/check-syntax': 'error',
'jsdoc/check-tag-names': 'error',
'jsdoc/check-types': 'error',
'jsdoc/check-values': 'error',
'jsdoc/empty-tags': 'error',
'jsdoc/implements-on-classes': 'error',
'jsdoc/no-bad-blocks': 'error',
'jsdoc/no-defaults': 'error',
'jsdoc/no-multi-asterisks': 'error',
'jsdoc/no-types': 'error',
'jsdoc/no-undefined-types': 'error',
'jsdoc/require-asterisk-prefix': 'error',
'jsdoc/require-description': 'error',
// This rule does not handle `# Heading`s and "etc.", "e.g.", "vs." etc.
// 'jsdoc/require-description-complete-sentence': 'error',
'jsdoc/require-file-overview': 'error',
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/require-param-description': 'error',
'jsdoc/require-param-name': 'error',
'jsdoc/require-property': 'error',
'jsdoc/require-property-description': 'error',
'jsdoc/require-property-name': 'error',
'jsdoc/require-property-type': 'error',
'jsdoc/require-returns-check': 'error',
'jsdoc/require-returns-description': 'error',
'jsdoc/require-throws': 'error',
'jsdoc/require-yields': 'error',
'jsdoc/require-yields-check': 'error',
'jsdoc/tag-lines': 'error',
'jsdoc/valid-types': 'error',
2024-07-26 09:34:51 +03:00
},
},
{
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
ignores: ['**/build.mjs'],
2024-07-26 09:34:51 +03:00
rules: {
'@typescript-eslint/no-var-requires': 'off',
// Parameter types must be specified using JSDoc in JS files.
'jsdoc/no-types': 'off',
2024-07-26 09:34:51 +03:00
},
},
{
files: [
'app/gui/src/dashboard/**/*.ts',
'app/gui/src/dashboard/**/*.mts',
'app/gui/src/dashboard/**/*.cts',
'app/gui/src/dashboard/**/*.tsx',
'app/gui/src/dashboard/**/*.mtsx',
'app/gui/src/dashboard/**/*.ctsx',
],
ignores: ['**/*.d.ts'],
2024-07-26 09:34:51 +03:00
rules: {
'no-restricted-syntax': [
2024-07-26 09:34:51 +03:00
'error',
...RESTRICTED_SYNTAXES,
2024-07-26 09:34:51 +03:00
{
selector: ':not(TSModuleDeclaration)[declare=true]',
message: 'No ambient declarations',
},
2024-07-26 09:34:51 +03:00
],
// This rule does not work with TypeScript, and TypeScript already does this.
'no-undef': 'off',
},
2024-07-26 09:34:51 +03:00
},
]