Files
goose/ui/desktop/eslint.config.js
Bradley Axen 1c9a7c0b05 feat: V1.0 (#734)
Co-authored-by: Michael Neale <michael.neale@gmail.com>
Co-authored-by: Wendy Tang <wendytang@squareup.com>
Co-authored-by: Jarrod Sibbison <72240382+jsibbison-square@users.noreply.github.com>
Co-authored-by: Alex Hancock <alex.hancock@example.com>
Co-authored-by: Alex Hancock <alexhancock@block.xyz>
Co-authored-by: Lifei Zhou <lifei@squareup.com>
Co-authored-by: Wes <141185334+wesrblock@users.noreply.github.com>
Co-authored-by: Max Novich <maksymstepanenko1990@gmail.com>
Co-authored-by: Zaki Ali <zaki@squareup.com>
Co-authored-by: Salman Mohammed <smohammed@squareup.com>
Co-authored-by: Kalvin C <kalvinnchau@users.noreply.github.com>
Co-authored-by: Alec Thomas <alec@swapoff.org>
Co-authored-by: lily-de <119957291+lily-de@users.noreply.github.com>
Co-authored-by: kalvinnchau <kalvin@block.xyz>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rizel Scarlett <rizel@squareup.com>
Co-authored-by: bwrage <bwrage@squareup.com>
Co-authored-by: Kalvin Chau <kalvin@squareup.com>
Co-authored-by: Alice Hau <110418948+ahau-square@users.noreply.github.com>
Co-authored-by: Alistair Gray <ajgray@stripe.com>
Co-authored-by: Nahiyan Khan <nahiyan.khan@gmail.com>
Co-authored-by: Alex Hancock <alexhancock@squareup.com>
Co-authored-by: Nahiyan Khan <nahiyan@squareup.com>
Co-authored-by: marcelle <1852848+laanak08@users.noreply.github.com>
Co-authored-by: Yingjie He <yingjiehe@block.xyz>
Co-authored-by: Yingjie He <yingjiehe@squareup.com>
Co-authored-by: Lily Delalande <ldelalande@block.xyz>
Co-authored-by: Adewale Abati <acekyd01@gmail.com>
Co-authored-by: Ebony Louis <ebony774@gmail.com>
Co-authored-by: Angie Jones <jones.angie@gmail.com>
Co-authored-by: Ebony Louis <55366651+EbonyLouis@users.noreply.github.com>
2025-01-24 13:04:43 -08:00

138 lines
4.2 KiB
JavaScript

const js = require('@eslint/js');
const tsParser = require('@typescript-eslint/parser');
const tsPlugin = require('@typescript-eslint/eslint-plugin');
const reactPlugin = require('eslint-plugin-react');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
// Custom rule to detect window.location.href usage
const noWindowLocationHref = {
meta: {
type: 'problem',
docs: {
description: 'Disallow direct usage of window.location.href in Electron apps',
recommended: true,
},
},
create(context) {
return {
AssignmentExpression(node) {
if (
node.left.type === 'MemberExpression' &&
node.left.object.type === 'MemberExpression' &&
node.left.object.object.type === 'Identifier' &&
node.left.object.object.name === 'window' &&
node.left.object.property.name === 'location' &&
node.left.property.name === 'href'
) {
context.report({
node,
message: 'Do not use window.location.href directly in Electron apps. Use React Router\'s navigate() instead.'
});
}
}
};
}
};
module.exports = [
js.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
// Electron/Node.js globals
process: 'readonly',
__dirname: 'readonly',
require: 'readonly',
module: 'readonly',
// Browser globals
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
localStorage: 'readonly',
fetch: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearInterval: 'readonly',
setInterval: 'readonly',
CustomEvent: 'readonly',
HTMLElement: 'readonly',
HTMLInputElement: 'readonly',
HTMLTextAreaElement: 'readonly',
HTMLButtonElement: 'readonly',
HTMLDivElement: 'readonly',
FileList: 'readonly',
FileReader: 'readonly',
DOMParser: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
Response: 'readonly',
ReadableStream: 'readonly',
AbortController: 'readonly',
RequestCredentials: 'readonly',
HeadersInit: 'readonly',
KeyboardEvent: 'readonly',
MouseEvent: 'readonly', // Add MouseEvent
Node: 'readonly', // Add Node
React: 'readonly',
handleAction: 'readonly',
requestAnimationFrame: 'readonly',
},
},
plugins: {
'@typescript-eslint': tsPlugin,
'react': reactPlugin,
'react-hooks': reactHooksPlugin,
'custom': {
rules: {
'no-window-location-href': noWindowLocationHref
}
}
},
rules: {
...tsPlugin.configs.recommended.rules,
...reactPlugin.configs.recommended.rules,
...reactHooksPlugin.configs.recommended.rules,
// Customize rules
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off', // We use TypeScript for prop validation
'react/no-unknown-property': ['error', {
ignore: ['dark:fill'] // Allow Tailwind dark mode syntax
}],
'react/no-unescaped-entities': 'off', // Allow quotes in JSX
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/ban-types': ['error', {
types: {
Object: {
message: 'Use object instead',
fixWith: 'object',
},
},
}],
'@typescript-eslint/no-var-requires': 'warn', // Downgrade to warning for Electron main process
'no-undef': 'error',
'no-useless-catch': 'warn',
'custom/no-window-location-href': 'error'
},
settings: {
react: {
version: 'detect',
},
},
},
];