fix(ags nvim): get eslint to work again and update deps
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-08-01 12:54:32 -04:00
parent a79cb29aaf
commit 28615e8152
31 changed files with 773 additions and 734 deletions

View file

@ -27,18 +27,18 @@ in
# lua
''
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'javascript', 'typescript', 'css', 'scss' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
pattern = { 'javascript', 'typescript', 'css', 'scss' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
vim.api.nvim_create_autocmd('FileType', {
pattern = 'html',
command = 'setlocal ts=2 sw=2 expandtab',
pattern = 'html',
command = 'setlocal ts=2 sw=2 expandtab',
});
vim.api.nvim_create_autocmd('FileType', {
pattern = 'scss',
command = 'setlocal iskeyword+=@-@',
pattern = 'scss',
command = 'setlocal iskeyword+=@-@',
});
local lsp = require('lspconfig');
@ -66,6 +66,41 @@ in
command = 'EslintFixAll',
});
end,
settings = {
validate = 'on',
packageManager = 'npm',
useESLintClass = true,
useFlatConfig = true,
experimental = {
useFlatConfig = true,
},
codeAction = {
disableRuleComment = {
enable = true,
location = 'separateLine'
},
showDocumentation = {
enable = true,
},
},
codeActionOnSave = {
mode = 'all',
rules = {},
},
format = true,
quiet = false,
onIgnoredFiles = 'off',
rulesCustomizations = {},
run = 'onType',
problems = {
shortenToSingleLine = false,
},
nodePath = "",
workingDirectory = {
mode = 'location',
},
},
});
lsp.cssls.setup({

View file

@ -1,461 +1,454 @@
// TODO: switch to typescript https://github.com/eslint/eslint/pull/18134
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import stylistic from '@stylistic/eslint-plugin';
// import stylisticRules from '@stylistic/eslint-plugin/rule-options';
import jsdoc from 'eslint-plugin-jsdoc';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';
export default tseslint.config(
// @ts-expect-error this works
eslint.configs.recommended,
jsdoc.configs['flat/recommended-typescript'],
export default tseslint.config({
// @ts-expect-error this should work
files: ['**/*.js', '**/*.ts'],
ignores: ['node_modules/**', 'types/**'],
{ ignores: ['js'] },
extends: [
eslint.configs.recommended,
jsdoc.configs['flat/recommended-typescript'],
stylistic.configs['recommended-flat'],
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
],
{
plugins: {
jsdoc,
'@stylistic': stylistic, // as typeof stylisticRules,
'@typescript-eslint': tsPlugin,
},
rules: {
// JSDoc settings
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
'jsdoc/check-line-alignment': ['warn', 'always', {
tags: ['param', 'arg', 'argument', 'property', 'prop'],
}],
'jsdoc/no-types': 'off',
rules: {
// JSDoc settings
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
'jsdoc/check-line-alignment': ['warn', 'always', {
tags: ['param', 'arg', 'argument', 'property', 'prop'],
}],
// Newer settings
'@typescript-eslint/no-extraneous-class': ['off'],
'@typescript-eslint/no-implied-eval': ['off'],
'class-methods-use-this': 'off',
'@stylistic/no-multiple-empty-lines': 'off',
// Newer settings
'@typescript-eslint/no-extraneous-class': ['off'],
'@typescript-eslint/no-implied-eval': ['off'],
// Pre-flat config
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
// Pre-flat config
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'array-callback-return': [
'error',
{
allowImplicit: true,
checkForEach: true,
},
],
'no-constructor-return': [
'error',
],
'no-unreachable-loop': [
'error',
{
ignore: [
'ForInStatement',
'ForOfStatement',
],
},
],
'no-use-before-define': [
'error',
{
functions: false,
},
],
'block-scoped-var': [
'error',
],
'class-methods-use-this': [
'error',
],
'curly': [
'warn',
],
'default-case-last': [
'warn',
],
'default-param-last': [
'error',
],
'eqeqeq': [
'error',
'smart',
],
'func-names': [
'warn',
'never',
],
'func-style': [
'warn',
'expression',
],
'logical-assignment-operators': [
'warn',
'always',
],
'no-array-constructor': [
'error',
],
'no-empty-function': [
'warn',
],
'no-empty-static-block': [
'warn',
],
'no-extend-native': [
'error',
],
'no-extra-bind': [
'warn',
],
'no-implicit-coercion': [
'warn',
],
'no-iterator': [
'error',
],
'no-labels': [
'error',
],
'no-lone-blocks': [
'error',
],
'no-lonely-if': [
'error',
],
'no-loop-func': [
'error',
],
'no-magic-numbers': [
'error',
{
ignore: [
-1,
0.1,
0,
1,
2,
3,
4,
5,
10,
12,
33,
66,
100,
255,
360,
450,
500,
1000,
],
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
},
],
'no-multi-assign': [
'error',
],
'no-new-wrappers': [
'error',
],
'no-object-constructor': [
'error',
],
'no-proto': [
'error',
],
'no-return-assign': [
'error',
],
'no-sequences': [
'error',
],
'no-shadow': [
'error',
{
builtinGlobals: true,
allow: [
'Window',
],
},
],
'no-undef-init': [
'warn',
],
'no-undefined': [
'error',
],
'no-useless-constructor': [
'warn',
],
'no-useless-escape': [
'off',
],
'no-useless-return': [
'error',
],
'no-var': [
'error',
],
'no-void': [
'off',
],
'no-with': [
'error',
],
'object-shorthand': [
'error',
'always',
],
'one-var': [
'error',
'never',
],
'operator-assignment': [
'warn',
'always',
],
'prefer-arrow-callback': [
'error',
],
'prefer-const': [
'error',
],
'prefer-object-has-own': [
'error',
],
'prefer-regex-literals': [
'error',
],
'prefer-template': [
'warn',
],
'no-prototype-builtins': 'off',
'@typescript-eslint/no-var-requires': [
'off',
],
'@stylistic/array-bracket-newline': [
'warn',
'consistent',
],
'@stylistic/array-bracket-spacing': [
'warn',
'never',
],
'@stylistic/arrow-parens': [
'warn',
'always',
],
'@stylistic/brace-style': [
'warn',
'stroustrup',
],
'@stylistic/comma-dangle': [
'warn',
'always-multiline',
],
'@stylistic/comma-spacing': [
'warn',
{
before: false,
after: true,
},
],
'@stylistic/comma-style': [
'error',
'last',
],
'@stylistic/dot-location': [
'error',
'property',
],
'@stylistic/function-call-argument-newline': [
'warn',
'consistent',
],
'@stylistic/function-paren-newline': [
'warn',
'consistent',
],
'@stylistic/indent': [
'warn',
4,
{
SwitchCase: 1,
ignoreComments: true,
ignoredNodes: ['TemplateLiteral > *'],
},
],
'@stylistic/key-spacing': [
'warn',
{
beforeColon: false,
afterColon: true,
},
],
'@stylistic/keyword-spacing': [
'warn',
{
before: true,
},
],
'@stylistic/linebreak-style': [
'error',
'unix',
],
'@stylistic/lines-between-class-members': [
'warn',
'always',
{
exceptAfterSingleLine: true,
},
],
'@stylistic/max-len': [
'warn',
{
code: 105,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
},
],
'@stylistic/multiline-ternary': [
'warn',
'always-multiline',
],
'@stylistic/new-parens': [
'error',
],
'@stylistic/no-mixed-operators': [
'warn',
],
'@stylistic/no-mixed-spaces-and-tabs': [
'error',
],
'@stylistic/no-multi-spaces': [
'error',
],
'@stylistic/no-tabs': [
'error',
],
'@stylistic/no-trailing-spaces': [
'error',
],
'@stylistic/no-whitespace-before-property': [
'warn',
],
'@stylistic/nonblock-statement-body-position': [
'error',
'below',
],
'@stylistic/object-curly-newline': [
'warn',
{
consistent: true,
},
],
'@stylistic/object-curly-spacing': [
'warn',
'always',
],
'@stylistic/operator-linebreak': [
'warn',
'after',
],
'@stylistic/padded-blocks': [
'error',
'never',
],
'@stylistic/padding-line-between-statements': [
'warn',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
{
blankLine: 'always',
prev: [
'const',
'let',
'var',
],
next: '*',
},
{
blankLine: 'any',
prev: [
'const',
'let',
'var',
],
next: [
'const',
'let',
'var',
],
},
{
blankLine: 'always',
prev: [
'case',
'default',
],
next: '*',
},
],
'@stylistic/quote-props': [
'error',
'consistent-as-needed',
],
'@stylistic/quotes': [
'error',
'single',
{
avoidEscape: true,
},
],
'@stylistic/semi': [
'error',
'always',
],
'@stylistic/semi-spacing': [
'warn',
],
'@stylistic/space-before-blocks': [
'warn',
],
'@stylistic/space-before-function-paren': [
'warn',
'never',
],
'@stylistic/space-infix-ops': [
'warn',
],
'@stylistic/spaced-comment': [
'warn',
'always',
],
'@stylistic/switch-colon-spacing': [
'warn',
],
'@stylistic/wrap-regex': [
'warn',
],
},
'array-callback-return': [
'error',
{
allowImplicit: true,
checkForEach: true,
},
],
'no-constructor-return': [
'error',
],
'no-unreachable-loop': [
'error',
{
ignore: [
'ForInStatement',
'ForOfStatement',
],
},
],
'no-use-before-define': [
'error',
{
functions: false,
},
],
'block-scoped-var': [
'error',
],
'curly': [
'warn',
],
'default-case-last': [
'warn',
],
'default-param-last': [
'error',
],
'eqeqeq': [
'error',
'smart',
],
'func-names': [
'warn',
'never',
],
'func-style': [
'warn',
'expression',
],
'logical-assignment-operators': [
'warn',
'always',
],
'no-array-constructor': [
'error',
],
'no-empty-function': [
'warn',
],
'no-empty-static-block': [
'warn',
],
'no-extend-native': [
'error',
],
'no-extra-bind': [
'warn',
],
'no-implicit-coercion': [
'warn',
],
'no-iterator': [
'error',
],
'no-labels': [
'error',
],
'no-lone-blocks': [
'error',
],
'no-lonely-if': [
'error',
],
'no-loop-func': [
'error',
],
'no-magic-numbers': [
'error',
{
ignore: [
-1,
0.1,
0,
1,
2,
3,
4,
5,
10,
12,
33,
66,
100,
255,
360,
450,
500,
1000,
],
ignoreDefaultValues: true,
ignoreClassFieldInitialValues: true,
},
],
'no-multi-assign': [
'error',
],
'no-new-wrappers': [
'error',
],
'no-object-constructor': [
'error',
],
'no-proto': [
'error',
],
'no-return-assign': [
'error',
],
'no-sequences': [
'error',
],
'no-shadow': [
'error',
{
builtinGlobals: true,
allow: [
'Window',
],
},
],
'no-undef-init': [
'warn',
],
'no-undefined': [
'error',
],
'no-useless-constructor': [
'warn',
],
'no-useless-escape': [
'off',
],
'no-useless-return': [
'error',
],
'no-var': [
'error',
],
'no-void': [
'off',
],
'no-with': [
'error',
],
'object-shorthand': [
'error',
'always',
],
'one-var': [
'error',
'never',
],
'operator-assignment': [
'warn',
'always',
],
'prefer-arrow-callback': [
'error',
],
'prefer-const': [
'error',
],
'prefer-object-has-own': [
'error',
],
'prefer-regex-literals': [
'error',
],
'prefer-template': [
'warn',
],
'no-prototype-builtins': 'off',
'@typescript-eslint/no-var-requires': [
'off',
],
'@stylistic/array-bracket-newline': [
'warn',
'consistent',
],
'@stylistic/array-bracket-spacing': [
'warn',
'never',
],
'@stylistic/arrow-parens': [
'warn',
'always',
],
'@stylistic/brace-style': [
'warn',
'stroustrup',
],
'@stylistic/comma-dangle': [
'warn',
'always-multiline',
],
'@stylistic/comma-spacing': [
'warn',
{
before: false,
after: true,
},
],
'@stylistic/comma-style': [
'error',
'last',
],
'@stylistic/dot-location': [
'error',
'property',
],
'@stylistic/function-call-argument-newline': [
'warn',
'consistent',
],
'@stylistic/function-paren-newline': [
'warn',
'consistent',
],
'@stylistic/indent': [
'warn',
4,
{
SwitchCase: 1,
ignoreComments: true,
ignoredNodes: ['TemplateLiteral > *'],
},
],
'@stylistic/key-spacing': [
'warn',
{
beforeColon: false,
afterColon: true,
},
],
'@stylistic/keyword-spacing': [
'warn',
{
before: true,
},
],
'@stylistic/linebreak-style': [
'error',
'unix',
],
'@stylistic/lines-between-class-members': [
'warn',
'always',
{
exceptAfterSingleLine: true,
},
],
'@stylistic/max-len': [
'warn',
{
code: 105,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
},
],
'@stylistic/multiline-ternary': [
'warn',
'always-multiline',
],
'@stylistic/new-parens': [
'error',
],
'@stylistic/no-mixed-operators': [
'warn',
],
'@stylistic/no-mixed-spaces-and-tabs': [
'error',
],
'@stylistic/no-multi-spaces': [
'error',
],
'@stylistic/no-tabs': [
'error',
],
'@stylistic/no-trailing-spaces': [
'error',
],
'@stylistic/no-whitespace-before-property': [
'warn',
],
'@stylistic/nonblock-statement-body-position': [
'error',
'below',
],
'@stylistic/object-curly-newline': [
'warn',
{
consistent: true,
},
],
'@stylistic/object-curly-spacing': [
'warn',
'always',
],
'@stylistic/operator-linebreak': [
'warn',
'after',
],
'@stylistic/padded-blocks': [
'error',
'never',
],
'@stylistic/padding-line-between-statements': [
'warn',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
{
blankLine: 'always',
prev: [
'const',
'let',
'var',
],
next: '*',
},
{
blankLine: 'any',
prev: [
'const',
'let',
'var',
],
next: [
'const',
'let',
'var',
],
},
{
blankLine: 'always',
prev: [
'case',
'default',
],
next: '*',
},
],
'@stylistic/quote-props': [
'error',
'consistent-as-needed',
],
'@stylistic/quotes': [
'error',
'single',
{
avoidEscape: true,
},
],
'@stylistic/semi': [
'error',
'always',
],
'@stylistic/semi-spacing': [
'warn',
],
'@stylistic/space-before-blocks': [
'warn',
],
'@stylistic/space-before-function-paren': [
'warn',
'never',
],
'@stylistic/space-infix-ops': [
'warn',
],
'@stylistic/spaced-comment': [
'warn',
'always',
],
'@stylistic/switch-colon-spacing': [
'warn',
],
'@stylistic/wrap-regex': [
'warn',
],
},
);
});

View file

@ -5,137 +5,6 @@ import { Variable as Var } from 'types/variable';
import { Widget as agsWidget } from 'types/widgets/widget';
export type AgsWidget = agsWidget<unknown> & Widget;
// For ./ts/applauncher/main.ts
import { Application } from 'types/service/applications.ts';
import { CursorBoxProps } from 'ts/misc/cursorbox';
export type AgsAppItem = AgsEventBox<Widget, { app: Application }
& CursorBoxProps<Widget, unknown>>;
// For ./ts/bar/hovers/keyboard.ts
export type Keyboard = {
address: string;
name: string;
rules: string;
model: string;
layout: string;
variant: string;
options: string;
active_keymap: string;
main: boolean;
};
// For ./ts/bar/items/workspaces.ts
// TODO: improve type
export type Workspace = AgsRevealer<unknown & Widget, unknown & { id: number }>;
// For ./ts/bar/fullscreen.ts
export type DefaultProps = RevealerProps<CenterBoxGeneric>;
// For ./ts/media-player/gesture.ts
export type Gesture = {
attribute?: object
setup?(self: OverlayGeneric): void
props?: OverlayProps<unknown & Widget, unknown>
};
// For ./ts/media-player/mpris.ts
type PlayerDragProps = unknown & { dragging: boolean };
export type PlayerDrag = AgsCenterBox<
unknown & Widget, unknown & Widget, unknown & Widget, unknown & PlayerDragProps
>;
type Colors = {
imageAccent: string;
buttonAccent: string;
buttonText: string;
hoverAccent: string;
};
// For ./ts/media-player
export type PlayerBoxProps = {
bgStyle: string,
player: MprisPlayer,
};
export type PlayerBox = AgsCenterBox<
unknown & Widget, unknown & Widget, unknown & Widget, PlayerBoxProps
>;
export type PlayerOverlay = AgsOverlay<AgsWidget, {
players: Map;
setup: boolean;
dragging: boolean;
includesWidget(playerW: PlayerBox): PlayerBox;
showTopOnly(): void;
moveToTop(player: PlayerBox): void;
}>;
export type PlayerButtonType = {
player: MprisPlayer
colors: Var<Colors>
children: StackProps['children']
onClick: string
prop: string
};
// For ./ts/notifications/gesture.js
type NotifGestureProps = {
dragging: boolean;
hovered: boolean
ready: boolean
id: number;
slideAway(side: 'Left' | 'Right'): void;
};
export type NotifGesture = AgsEventBox<BoxGeneric, NotifGestureProps>;
// For ./ts/osd/ctor.ts
export type OSDStack = AgsStack<unknown & Widget, {
popup(osd: string): void,
}>;
export type ConnectFunc = (self?: ProgressBarGeneric) => void;
export type OSD = {
name: string;
icon: IconPropsGeneric['icon'];
info: {
mod: GObject.Object;
signal?: string | string[];
logic?(self: ProgressBarGeneric): void;
widget?: AgsWidget;
}
};
// For ./ts/on-screen-keyboard
export type OskWindow = Window<BoxGeneric, {
startY: null | number;
setVisible: (state: boolean) => void;
killGestureSigs: () => void;
setSlideUp: () => void;
setSlideDown: () => void;
}>;
// For CursorBox
import { CursorBox, CursorBoxProps } from 'ts/misc/cursorbox';
export type CursorBox = CursorBox;
export type CursorBoxProps = CursorBoxProps;
// For PopupWindow
export type HyprTransition = 'slide' | 'slide top' | 'slide bottom' | 'slide left' |
'slide right' | 'popin' | 'fade';
export type CloseType = 'none' | 'stay' | 'released' | 'clicked';
import { PopupWindow } from 'ts/misc/popup';
export type PopupWindow = PopupWindow;
// For ./ts/quick-settings
import { BluetoothDevice as BTDev } from 'types/service/bluetooth.ts';
export type APType = {
bssid: string
address: string
lastSeen: number
ssid: string
active: boolean
strength: number
iconName: string
};
export type APBox = AgsBox<unknown & Widget, { ap: Var<APType> }>;
export type DeviceBox = AgsBox<unknown & Widget, { dev: BTDev }>;
// Generic widgets
import AgsBox from 'types/widgets/box.ts';
export type BoxGeneric = AgsBox<unknown & Widget, unknown>;
@ -168,10 +37,141 @@ import AgsRevealer, { RevealerProps } from 'types/widgets/revealer';
export type RevealerGeneric = AgsRevealer<unknown & Widget, unknown>;
import AgsStack, { StackProps } from 'types/widgets/stack';
export type StackGeneric = AgsStack<{ [name: string]: Widget; }, unknown>;
export type StackGeneric = AgsStack<Record<string, Widget>, unknown>;
import AgsScrollable from 'types/widgets/scrollable';
export type ScrollableGeneric = AgsScrollable<unkown & Widget, unknown>;
import AgsWindow from 'types/widgets/window';
export type WindowGeneric = AgsWindow<unknown & Widget, unknown>;
// For ./ts/applauncher/main.ts
import { Application } from 'types/service/applications.ts';
import { CursorBoxProps } from 'ts/misc/cursorbox';
export type AgsAppItem = AgsEventBox<Widget, { app: Application }
& CursorBoxProps<Widget, unknown>>;
// For ./ts/bar/hovers/keyboard.ts
export interface Keyboard {
address: string
name: string
rules: string
model: string
layout: string
variant: string
options: string
active_keymap: string
main: boolean
}
// For ./ts/bar/items/workspaces.ts
// TODO: improve type
export type Workspace = AgsRevealer<unknown & Widget, unknown & { id: number }>;
// For ./ts/bar/fullscreen.ts
export type DefaultProps = RevealerProps<CenterBoxGeneric>;
// For ./ts/media-player/gesture.ts
export interface Gesture {
attribute?: object
setup?(self: OverlayGeneric): void
props?: OverlayProps<unknown & Widget, unknown>
}
// For ./ts/media-player/mpris.ts
type PlayerDragProps = unknown & { dragging: boolean };
export type PlayerDrag = AgsCenterBox<
unknown & Widget, unknown & Widget, unknown & Widget, unknown & PlayerDragProps
>;
interface Colors {
imageAccent: string
buttonAccent: string
buttonText: string
hoverAccent: string
}
// For ./ts/media-player
export interface PlayerBoxProps {
bgStyle: string
player: MprisPlayer
}
export type PlayerBox = AgsCenterBox<
unknown & Widget, unknown & Widget, unknown & Widget, PlayerBoxProps
>;
export type PlayerOverlay = AgsOverlay<AgsWidget, {
players: Map
setup: boolean
dragging: boolean
includesWidget(playerW: PlayerBox): PlayerBox
showTopOnly(): void
moveToTop(player: PlayerBox): void
}>;
export interface PlayerButtonType {
player: MprisPlayer
colors: Var<Colors>
children: StackProps['children']
onClick: string
prop: string
}
// For ./ts/notifications/gesture.js
interface NotifGestureProps {
dragging: boolean
hovered: boolean
ready: boolean
id: number
slideAway(side: 'Left' | 'Right'): void
}
export type NotifGesture = AgsEventBox<BoxGeneric, NotifGestureProps>;
// For ./ts/osd/ctor.ts
export type OSDStack = AgsStack<unknown & Widget, {
popup(osd: string): void
}>;
export type ConnectFunc = (self?: ProgressBarGeneric) => void;
export interface OSD {
name: string
icon: IconPropsGeneric['icon']
info: {
mod: GObject.Object
signal?: string | string[]
logic?(self: ProgressBarGeneric): void
widget?: AgsWidget
}
}
// For ./ts/on-screen-keyboard
export type OskWindow = Window<BoxGeneric, {
startY: null | number
setVisible: (state: boolean) => void
killGestureSigs: () => void
setSlideUp: () => void
setSlideDown: () => void
}>;
// For CursorBox
import { CursorBox, CursorBoxProps } from 'ts/misc/cursorbox';
export type CursorBox = CursorBox;
export type CursorBoxProps = CursorBoxProps;
// For PopupWindow
export type HyprTransition = 'slide' | 'slide top' | 'slide bottom' | 'slide left' |
'slide right' | 'popin' | 'fade';
export type CloseType = 'none' | 'stay' | 'released' | 'clicked';
import { PopupWindow } from 'ts/misc/popup';
export type PopupWindow = PopupWindow;
// For ./ts/quick-settings
import { BluetoothDevice as BTDev } from 'types/service/bluetooth.ts';
export interface APType {
bssid: string
address: string
lastSeen: number
ssid: string
active: boolean
strength: number
iconName: string
}
export type APBox = AgsBox<unknown & Widget, { ap: Var<APType> }>;
export type DeviceBox = AgsBox<unknown & Widget, { dev: BTDev }>;

View file

@ -1,7 +1,9 @@
const { execAsync, monitorFile } = Utils;
/** @param {string} host */
/**
* @param {string} host the name of the machine/user who's running ags
*/
const watchAndCompileSass = (host) => {
const reloadCss = () => {
const scss = `${App.configDir}/scss/${host}.scss`;
@ -20,7 +22,10 @@ const watchAndCompileSass = (host) => {
reloadCss();
};
/** @param {string} host */
/**
* @param {string} host the name of the machine/user who's running ags
* @returns the config
*/
export const transpileTypeScript = async(host) => {
const outPath = `/tmp/ags-${host}/index.js`;

Binary file not shown.

View file

@ -5,16 +5,13 @@
"fzf": "0.5.2"
},
"devDependencies": {
"@eslint/js": "9.7.0",
"@stylistic/eslint-plugin": "2.3.0",
"@eslint/js": "9.8.0",
"@stylistic/eslint-plugin": "2.6.1",
"@types/eslint__js": "8.42.3",
"@types/node": "20.14.11",
"eslint": "9.7.0",
"eslint-plugin-jsdoc": "48.7.0",
"typescript": "5.5.3",
"typescript-eslint": "7.16.1"
},
"overrides": {
"eslint": "$eslint"
"@types/node": "22.0.2",
"eslint": "9.8.0",
"eslint-plugin-jsdoc": "48.10.2",
"typescript": "5.5.4",
"typescript-eslint": "8.0.0"
}
}

View file

@ -41,22 +41,6 @@ class Brightness extends Service {
return this.#kbd;
}
get screen() {
return this.#screen;
}
get screenIcon() {
return this.#screenIcon;
}
get caps() {
return this.#caps;
}
get capsIcon() {
return this.#capsIcon;
}
set kbd(value) {
if (value < 0 || value > this.#kbdMax) {
return;
@ -70,6 +54,10 @@ class Brightness extends Service {
.catch(console.error);
}
get screen() {
return this.#screen;
}
set screen(percent) {
if (percent < 0) {
percent = 0;
@ -88,16 +76,27 @@ class Brightness extends Service {
.catch(console.error);
}
get screenIcon() {
return this.#screenIcon;
}
get caps() {
return this.#caps;
}
get capsIcon() {
return this.#capsIcon;
}
constructor() {
super();
try {
this.#monitorKbdState();
this.#kbdMax = Number(exec(`brightnessctl -d ${KBD} m`));
this.#caps = Number(exec(`bash -c brightnessctl -d ${this.#capsName} g`));
this.#screen = Number(exec('brightnessctl g')) /
Number(exec('brightnessctl m'));
this.#screen = Number(exec('brightnessctl g')) / Number(exec('brightnessctl m'));
}
catch (error) {
catch (_e) {
console.error('missing dependancy: brightnessctl');
}
}
@ -140,6 +139,7 @@ class Brightness extends Service {
}
},
).catch(() => {
// @ts-expect-error this works in ags
interval.destroy();
});
}, INTERVAL);

View file

@ -16,7 +16,7 @@ class Clipboard extends Service {
// Class Attributes
private _clips_left = 0;
private _clips: Map<number, { clip: string; isImage: boolean }> = new Map();
private _clips = new Map<number, { clip: string, isImage: boolean }>();
get clips() {
return this._clips;
@ -75,7 +75,7 @@ class Clipboard extends Service {
this._clips_left = Math.min(rawClips.length - 1, n);
rawClips.forEach(async (clip, i) => {
rawClips.forEach(async(clip, i) => {
if (i > n) {
return;
}
@ -83,7 +83,7 @@ class Clipboard extends Service {
if (clip.includes('img')) {
this._decrementClipsLeft();
const newClip: [number, {clip: string; isImage: boolean;}] = [
const newClip: [number, { clip: string, isImage: boolean }] = [
parseInt((clip.match('[0-9]+') ?? [''])[0]),
{
clip,
@ -98,7 +98,7 @@ class Clipboard extends Service {
const decodedClip = await this._decodeItem(clip);
if (decodedClip) {
const newClip: [number, {clip: string; isImage: boolean;}] = [
const newClip: [number, { clip: string, isImage: boolean }] = [
parseInt(clip),
{
clip: decodedClip,
@ -120,7 +120,7 @@ class Clipboard extends Service {
() => {
this._getHistory(1);
},
() => {/**/},
() => { /**/ },
);
}
}

View file

@ -57,7 +57,7 @@ class GSR extends Service {
},
);
},
() => {/**/},
() => { /**/ },
);
}

View file

@ -14,27 +14,27 @@ const ON_CLICK_TRIGGERS = [
// Types
import { PopupWindow } from 'global-types';
import { Subprocess } from 'types/@girs/gio-2.0/gio-2.0.cjs';
type Layer = {
address: string;
x: number;
y: number;
w: number;
h: number;
namespace: string;
};
type Levels = {
0?: Array<Layer> | null;
1?: Array<Layer> | null;
2?: Array<Layer> | null;
3?: Array<Layer> | null;
};
type Layers = {
levels: Levels;
};
type CursorPos = {
x: number;
y: number;
};
interface Layer {
address: string
x: number
y: number
w: number
h: number
namespace: string
}
interface Levels {
0?: Layer[] | null
1?: Layer[] | null
2?: Layer[] | null
3?: Layer[] | null
}
interface Layers {
levels: Levels
}
interface CursorPos {
x: number
y: number
}
class Pointers extends Service {
@ -51,7 +51,7 @@ class Pointers extends Service {
#process = null as Subprocess | null;
#lastLine = '';
#pointers = [] as Array<string>;
#pointers = [] as string[];
get process() {
return this.#process;
@ -111,12 +111,12 @@ class Pointers extends Service {
#initAppConnection() {
App.connect('window-toggled', () => {
const anyVisibleAndClosable =
(App.windows as Array<PopupWindow>).some((w) => {
(App.windows as PopupWindow[]).some((w) => {
const closable = w.close_on_unfocus &&
!(
w.close_on_unfocus === 'none' ||
w.close_on_unfocus === 'stay'
);
!(
w.close_on_unfocus === 'none' ||
w.close_on_unfocus === 'stay'
);
return w.visible && closable;
});
@ -132,7 +132,7 @@ class Pointers extends Service {
}
static detectClickedOutside(clickStage: string) {
const toClose = ((App.windows as Array<PopupWindow>)).some((w) => {
const toClose = ((App.windows as PopupWindow[])).some((w) => {
const closable = (
w.close_on_unfocus &&
w.close_on_unfocus === clickStage
@ -160,8 +160,8 @@ class Pointers extends Service {
'osk',
];
const getNoCloseWidgets = (names: Array<string>) => {
const arr = [] as Array<Layer>;
const getNoCloseWidgets = (names: string[]) => {
const arr = [] as Layer[];
names.forEach((name) => {
arr.push(
@ -184,7 +184,7 @@ class Pointers extends Service {
};
const clickIsOnWidget = (w: Layer) => {
return pos.x > w.x && pos.x < w.x + w.w &&
pos.y > w.y && pos.y < w.y + w.h;
pos.y > w.y && pos.y < w.y + w.h;
};
const noCloseWidgets =
@ -200,9 +200,9 @@ class Pointers extends Service {
}
return window &&
window.close_on_unfocus &&
window.close_on_unfocus ===
clickStage;
window.close_on_unfocus &&
window.close_on_unfocus ===
clickStage;
});
if (noCloseWidgets.some(clickIsOnWidget)) {
@ -212,7 +212,7 @@ class Pointers extends Service {
widgets.forEach(
(w) => {
if (!(pos.x > w.x && pos.x < w.x + w.w &&
pos.y > w.y && pos.y < w.y + w.h)) {
pos.y > w.y && pos.y < w.y + w.h)) {
App.closeWindow(w.namespace);
}
},

View file

@ -5,7 +5,7 @@ import { Application } from 'types/service/applications.ts';
const bash = async(strings: TemplateStringsArray | string, ...values: unknown[]) => {
const cmd = typeof strings === 'string' ?
strings :
strings.flatMap((str, i) => `${str }${values[i] ?? ''}`)
strings.flatMap((str, i) => `${str}${values[i] ?? ''}`)
.join('');
return Utils.execAsync(['bash', '-c', cmd]).catch((err) => {

View file

@ -69,7 +69,7 @@ export default () => {
rows.forEach((row) => {
row.changed();
const item = (row.get_children()[0] as AgsAppItem);
const item = row.get_children()[0] as AgsAppItem;
if (item.attribute.app) {
const isMatching = fzfResults.some((r) => {

View file

@ -27,7 +27,7 @@ Hyprland.connect('event', (hyprObj) => {
const mon = Hyprland.getMonitor(c.monitor);
return c.fullscreen &&
c.workspace.id === mon?.activeWorkspace.id;
c.workspace.id === mon?.activeWorkspace.id;
});
const monitors = fsClients.map((c) =>

View file

@ -9,11 +9,11 @@ export default () => HoverRevealer({
icon: Icon().hook(Network, (self) => {
if (Network.wifi.internet === 'connected' ||
Network.wifi.internet === 'connecting') {
Network.wifi.internet === 'connecting') {
self.icon = Network.wifi.icon_name;
}
else if (Network.wired.internet === 'connected' ||
Network.wired.internet === 'connecting') {
Network.wired.internet === 'connecting') {
self.icon = Network.wired.icon_name;
}
else {
@ -23,11 +23,11 @@ export default () => HoverRevealer({
label: Label().hook(Network, (self) => {
if (Network.wifi.internet === 'connected' ||
Network.wifi.internet === 'connecting') {
Network.wifi.internet === 'connecting') {
self.label = Network.wifi.ssid || 'Unknown';
}
else if (Network.wired.internet === 'connected' ||
Network.wired.internet === 'connecting') {
Network.wired.internet === 'connecting') {
self.label = 'Connected';
}
else {

View file

@ -50,7 +50,7 @@ const Workspace = ({ id }: { id: number }) => {
// Deal with urgent windows
const client = Hyprland.getClient(addr);
const isThisUrgent = client &&
client.workspace.id === id;
client.workspace.id === id;
if (isThisUrgent) {
self.toggleClassName('urgent', true);

View file

@ -3,10 +3,12 @@ import CalendarWidget from './main.ts';
import { get_gdkmonitor_from_desc } from '../lib.ts';
const RIGHT_MARGIN = 20;
export default () => PopupWindow({
name: 'calendar',
anchor: ['bottom', 'right'],
margins: [0, 20, 0, 0],
margins: [0, RIGHT_MARGIN, 0, 0],
transition: 'slide bottom',
gdkmonitor: get_gdkmonitor_from_desc('desc:Acer Technologies Acer K212HQL T3EAA0014201'),

View file

@ -15,8 +15,8 @@ import { Box as AgsBox } from 'types/widgets/box';
const lock = Lock.prepare_lock();
const windows: Map<Gdk.Monitor, Gtk.Window> = new Map();
const blurBGs: AgsBox<Gtk.Widget, { geometry: { w: number, h: number }; }>[] = [];
const windows = new Map<Gdk.Monitor, Gtk.Window>();
const blurBGs: AgsBox<Gtk.Widget, { geometry: { w: number, h: number } }>[] = [];
const transition_duration = 1000;
const WINDOW_MARGINS = -2;

View file

@ -19,7 +19,7 @@ import {
export default ({
setup = () => {/**/},
setup = () => { /**/ },
...props
}: Gesture) => {
const widget = EventBox();

View file

@ -3,10 +3,10 @@ import { PopupWindow } from 'global-types';
export default () => {
(App.windows as Array<PopupWindow>)
(App.windows as PopupWindow[])
.filter((w) => w &&
w.close_on_unfocus &&
w.close_on_unfocus !== 'stay')
w.close_on_unfocus &&
w.close_on_unfocus !== 'stay')
.forEach((w) => {
App.closeWindow(w.name);
});

View file

@ -5,6 +5,9 @@ import Gdk from 'gi://Gdk?version=3.0';
import { BaseProps, Widget as AgsWidget } from 'types/widgets/widget';
type EventHandler<Self> = (self: Self, event: Gdk.Event) => boolean | unknown;
// eslint-disable-next-line
export interface CursorBox<Child, Attr> extends AgsWidget<Attr> { }
export type CursorBoxProps<
Child extends Gtk.Widget,
Attr = unknown,
@ -26,10 +29,8 @@ export type CursorBoxProps<
on_secondary_click_release?: EventHandler<Self>
}, Attr>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface CursorBox<Child, Attr> extends AgsWidget<Attr> { }
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class CursorBox<Child extends Gtk.Widget, Attr> extends Gtk.EventBox {
static {
Widget.register(this, {

View file

@ -3,7 +3,7 @@ const { get_home_dir } = imports.gi.GLib;
import GObject from 'types/@girs/gobject-2.0/gobject-2.0';
type Persist = {
interface Persist {
name: string
gobject: GObject.Object
prop: string
@ -11,7 +11,7 @@ type Persist = {
whenTrue?: boolean | string
whenFalse?: boolean | string
signal?: string
};
}
export default ({

View file

@ -8,6 +8,9 @@ import { Window } from 'resource:///com/github/Aylur/ags/widgets/window.js';
import type { WindowProps } from 'types/widgets/window';
import type { Widget as AgsWidget } from 'types/widgets/widget';
// eslint-disable-next-line
export interface PopupWindow<Child, Attr> extends AgsWidget<Attr> { }
import {
CloseType,
HyprTransition,
@ -18,17 +21,15 @@ export type PopupWindowProps<
Attr = unknown,
Self = PopupWindow<Child, Attr>,
> = WindowProps<Child, Attr, Self> & {
transition?: HyprTransition;
on_open?(self: PopupWindow<Child, Attr>): void;
on_close?(self: PopupWindow<Child, Attr>): void;
close_on_unfocus?: CloseType;
anchor?: Array<'top' | 'bottom' | 'right' | 'left'>;
transition?: HyprTransition
on_open?(self: PopupWindow<Child, Attr>): void
on_close?(self: PopupWindow<Child, Attr>): void
close_on_unfocus?: CloseType
anchor?: ('top' | 'bottom' | 'right' | 'left')[]
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface PopupWindow<Child, Attr> extends AgsWidget<Attr> { }
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class PopupWindow<
Child extends Gtk.Widget,
Attr,
@ -68,6 +69,7 @@ export class PopupWindow<
}
// eslint-disable-next-line no-use-before-define
protected _on_open: (self: PopupWindow<Child, Attr>) => void;
get on_open() {
@ -79,6 +81,7 @@ export class PopupWindow<
}
// eslint-disable-next-line no-use-before-define
private _on_close: (self: PopupWindow<Child, Attr>) => void;
get on_close() {
@ -92,8 +95,8 @@ export class PopupWindow<
constructor({
transition = 'slide top',
on_open = () => {/**/ },
on_close = () => {/**/ },
on_open = () => { /**/ },
on_close = () => { /**/ },
// Window props
name,

View file

@ -9,22 +9,24 @@ import { ListBoxRow } from 'types/@girs/gtk-3.0/gtk-3.0.cjs';
import { Monitor } from 'types/service/hyprland';
import { Binding } from 'types/service';
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface SortedList<Attr> extends AgsWidget<Attr> { }
// eslint-disable-next-line no-use-before-define
type MakeChild = ReturnType<typeof makeChild>;
type SortedListProps<Attr = unknown, Self = SortedList<Attr>> =
PopupWindowProps<MakeChild['child'], Attr, Self> & {
on_select: (row: ListBoxRow) => void;
init_rows?: (list: MakeChild['list']) => void;
set_sort: (
text: string,
list: MakeChild['list'],
placeholder: MakeChild['placeholder'],
) => void;
setup_list?: (list: MakeChild['list']) => void;
};
PopupWindowProps<MakeChild['child'], Attr, Self> & {
on_select: (row: ListBoxRow) => void
init_rows?: (list: MakeChild['list']) => void
set_sort: (
text: string,
list: MakeChild['list'],
placeholder: MakeChild['placeholder'],
) => void
setup_list?: (list: MakeChild['list']) => void
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface SortedList<Attr> extends AgsWidget<Attr> { }
const centerCursor = async(): Promise<void> => {
@ -108,6 +110,7 @@ const makeChild = (class_name: string | Binding<any, any, string>) => {
};
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class SortedList<
Attr,
> extends PopupWindow<MakeChild['child'], Attr> {

View file

@ -14,11 +14,11 @@ import { launchApp } from '../applauncher/launch.ts';
// Types
import { Notification as NotifObj } from 'types/service/notifications.ts';
import { Client } from 'types/service/hyprland.ts';
type NotificationWidget = {
interface NotificationWidget {
notif: NotifObj
slideIn?: 'Left' | 'Right'
command?(): void
};
}
import {
CursorBox as CBox,
EventBoxGeneric,
@ -46,7 +46,7 @@ const getDragState = (box: EventBoxGeneric) => (box
const NotificationIcon = (notif: NotifObj) => {
let iconCmd = (box: CBox):void => {
let iconCmd = (box: CBox): void => {
if (!box) {
console.log();
}
@ -66,16 +66,16 @@ const NotificationIcon = (notif: NotifObj) => {
if (!getDragState(box)) {
if (wmClass === 'Proton Mail') {
Hyprland.messageAsync('dispatch ' +
'togglespecialworkspace thunder');
'togglespecialworkspace thunder');
}
else if (wmClass === 'Spotify') {
Hyprland.messageAsync('dispatch ' +
'togglespecialworkspace spot');
'togglespecialworkspace spot');
}
else {
Hyprland.messageAsync('j/clients').then((msg) => {
const clients = JSON.parse(msg) as Array<Client>;
const classes = [] as Array<string>;
const clients = JSON.parse(msg) as Client[];
const classes = [] as string[];
for (const key of clients) {
if (key.class) {
@ -85,7 +85,7 @@ const NotificationIcon = (notif: NotifObj) => {
if (wmClass && classes.includes(wmClass)) {
Hyprland.messageAsync('dispatch ' +
`focuswindow ^(${wmClass})`);
`focuswindow ^(${wmClass})`);
}
else {
Hyprland.messageAsync('dispatch workspace empty')
@ -168,7 +168,7 @@ export const HasNotifs = Variable(false);
export const Notification = ({
notif,
slideIn = 'Left',
command = () => {/**/},
command = () => { /**/ },
}: NotificationWidget) => {
if (!notif) {
return;
@ -248,7 +248,7 @@ export const Notification = ({
notif.close(),
child: Icon('window-close' +
'-symbolic'),
'-symbolic'),
}),
}),
],

View file

@ -44,7 +44,7 @@ const defaultStyle = `${TRANSITION} margin: unset; opacity: 1;`;
export default ({
id,
slideIn = 'Left',
command = () => {/**/},
command = () => { /**/ },
...props
}) => {
const widget = EventBox({

View file

@ -28,7 +28,7 @@ export default (window: OskWindow) => {
window.child.setCss(`margin-bottom: -${HIDDEN_MARGIN}px;`);
let signals = [] as Array<number>;
let signals = [] as number[];
window.attribute = {
startY: null,

View file

@ -45,14 +45,14 @@ const LCTRL_CODE = 29;
// Types
import { Variable as Var } from 'types/variable.ts';
type Key = {
keytype: string,
label: string,
labelShift?: string,
labelAltGr?: string,
shape: string,
interface Key {
keytype: string
label: string
labelShift?: string
labelAltGr?: string
shape: string
keycode: number
};
}
const ModKey = (key: Key) => {

View file

@ -7,7 +7,7 @@ import PopupWindow from '../misc/popup.ts';
import { BoxGeneric } from 'global-types';
// Import all the OSDs as an array
const OSDList = [] as Array<() => BoxGeneric>;
const OSDList = [] as (() => BoxGeneric)[];
import * as Modules from './osds.ts';
for (const osd in Modules) {

View file

@ -187,7 +187,7 @@ export const BluetoothMenu = () => {
// Make bottom scroll indicator appear only
// when first getting overflowing children
if (!(bottomArrow.reveal_child === true ||
topArrow.reveal_child === true)) {
topArrow.reveal_child === true)) {
bottomArrow.reveal_child = true;
}
}
@ -200,7 +200,7 @@ export const BluetoothMenu = () => {
}
// Trigger sort_func
(self.get_children() as Array<ListBoxRow>)
(self.get_children() as ListBoxRow[])
.forEach((ch) => {
ch.changed();
});

View file

@ -36,7 +36,7 @@ type IndicatorTuple = [
signal?: string,
];
type GridButtonType = {
interface GridButtonType {
command?(): void
secondary_command?(): void
on_open?(menu: RevealerGeneric): void
@ -44,17 +44,17 @@ type GridButtonType = {
indicator?: IndicatorTuple
// @ts-expect-error me is lazy
menu?: Widget
};
}
// TODO: do vpn button
const SPACING = 28;
const ButtonStates = [] as Array<Var<boolean>>;
const ButtonStates = [] as Var<boolean>[];
const GridButton = ({
command = () => {/**/},
secondary_command = () => {/**/},
on_open = () => {/**/},
command = () => { /**/ },
secondary_command = () => { /**/ },
on_open = () => { /**/ },
icon,
indicator,
menu,
@ -158,7 +158,7 @@ const GridButton = ({
?.children[1] as BoxGeneric;
const isSetup = (rowMenu
.get_children() as Array<BoxGeneric>)
.get_children() as BoxGeneric[])
.find((ch) => ch === menu);
if (!isSetup) {

View file

@ -43,7 +43,7 @@ const AccessPoint = (ap: APType) => {
self.setCss(
`opacity: ${
widget.attribute.ap.value.ssid ===
Network.wifi.ssid ?
Network.wifi.ssid ?
'1' :
'0'
};
@ -150,7 +150,7 @@ export const NetworkMenu = () => {
self.hook(Network, () => {
// Add missing APs
const currentAPs = Network.wifi
?.access_points as Array<APType>;
?.access_points as APType[];
currentAPs.forEach((ap) => {
if (ap.ssid !== 'Unknown') {
@ -214,7 +214,7 @@ export const NetworkMenu = () => {
// Make bottom scroll indicator appear only
// when first getting overflowing children
if (!(bottomArrow.reveal_child === true ||
topArrow.reveal_child === true)) {
topArrow.reveal_child === true)) {
bottomArrow.reveal_child = true;
}
}
@ -227,7 +227,7 @@ export const NetworkMenu = () => {
}
// Trigger sort_func
(self.get_children() as Array<ListBoxRow>)
(self.get_children() as ListBoxRow[])
.forEach((ch) => {
ch.changed();
});