1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Apply @typescript-eslint/ban-ts-comment rule

This commit is contained in:
Laurent Cozic 2023-06-30 10:22:47 +01:00
parent 7591a1182e
commit 48ef6db4a5
22 changed files with 47 additions and 78 deletions

View File

@ -183,7 +183,7 @@ module.exports = {
'project': './tsconfig.eslint.json',
},
'rules': {
'@typescript-eslint/ban-ts-comment': ['error'],
'@typescript-eslint/explicit-member-accessibility': ['error'],
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
'@typescript-eslint/array-type': 'error',

View File

@ -846,9 +846,7 @@ class MainScreenComponent extends React.Component<Props, State> {
{this.renderPluginDialogs()}
{noteContentPropertiesDialogOptions.visible && <NoteContentPropertiesDialog markupLanguage={noteContentPropertiesDialogOptions.markupLanguage} themeId={this.props.themeId} onClose={this.noteContentPropertiesDialog_close} text={noteContentPropertiesDialogOptions.text}/>}
{notePropertiesDialogOptions.visible && <NotePropertiesDialog themeId={this.props.themeId} noteId={notePropertiesDialogOptions.noteId} onClose={this.notePropertiesDialog_close} onRevisionLinkClick={notePropertiesDialogOptions.onRevisionLinkClick} />}
{/* @ts-ignore */}
{shareNoteDialogOptions.visible && <ShareNoteDialog themeId={this.props.themeId} noteIds={shareNoteDialogOptions.noteIds} onClose={this.shareNoteDialog_close} />}
{/* @ts-ignore */}
{shareFolderDialogOptions.visible && <ShareFolderDialog themeId={this.props.themeId} folderId={shareFolderDialogOptions.folderId} onClose={this.shareFolderDialog_close} />}
<PromptDialog autocomplete={promptOptions && 'autocomplete' in promptOptions ? promptOptions.autocomplete : null} defaultValue={promptOptions && promptOptions.value ? promptOptions.value : ''} themeId={this.props.themeId} style={styles.prompt} onClose={this.promptOnClose_} label={promptOptions ? promptOptions.label : ''} description={promptOptions ? promptOptions.description : null} visible={!!this.state.promptOptions} buttons={promptOptions && 'buttons' in promptOptions ? promptOptions.buttons : null} inputType={promptOptions && 'inputType' in promptOptions ? promptOptions.inputType : null} />

View File

@ -366,4 +366,4 @@ const mapStateToProps = (state: State) => {
};
};
export default connect(mapStateToProps)(ShareFolderDialog as any);
export default connect(mapStateToProps)(ShareFolderDialog);

View File

@ -234,4 +234,4 @@ const mapStateToProps = (state: AppState) => {
};
};
export default connect(mapStateToProps)(ShareNoteDialog as any);
export default connect(mapStateToProps)(ShareNoteDialog);

View File

@ -320,8 +320,7 @@ class Dialog extends React.PureComponent<Props, State> {
const searchKeywords = await this.keywords(searchQuery);
const notes = await Note.byIds(results.map((result: any) => result.id).slice(0, limit), { fields: ['id', 'body', 'markup_language', 'is_todo', 'todo_completed'] });
// Can't make any sense of this code so...
// @ts-ignore
const notesById = notes.reduce((obj, { id, body, markup_language }) => ((obj[[id]] = { id, body, markup_language }), obj), {});
const notesById = notes.reduce((obj, { id, body, markup_language }) => ((obj[[id] as any] = { id, body, markup_language }), obj), {});
// Filter out search results that are associated with non-existing notes.
// https://github.com/laurent22/joplin/issues/5417

View File

@ -7,7 +7,7 @@ import Setting from '@joplin/lib/models/Setting';
import { EventHandlers } from '@joplin/lib/services/plugins/utils/mapEventHandlersToIds';
import shim from '@joplin/lib/shim';
import Logger from '@joplin/lib/Logger';
import BackOffHandler from './BackOffHandler';
// import BackOffHandler from './BackOffHandler';
const ipcRenderer = require('electron').ipcRenderer;
const logger = Logger.create('PluginRunner');
@ -84,7 +84,7 @@ function mapEventIdsToHandlers(pluginId: string, arg: any) {
export default class PluginRunner extends BasePluginRunner {
protected eventHandlers_: EventHandlers = {};
private backOffHandlers_: Record<string, BackOffHandler> = {};
// private backOffHandlers_: Record<string, BackOffHandler> = {};
public constructor() {
super();
@ -97,13 +97,12 @@ export default class PluginRunner extends BasePluginRunner {
return cb(...args);
}
// @ts-ignore
private backOffHandler(pluginId: string): BackOffHandler {
if (!this.backOffHandlers_[pluginId]) {
this.backOffHandlers_[pluginId] = new BackOffHandler(pluginId);
}
return this.backOffHandlers_[pluginId];
}
// private backOffHandler(pluginId: string): BackOffHandler {
// if (!this.backOffHandlers_[pluginId]) {
// this.backOffHandlers_[pluginId] = new BackOffHandler(pluginId);
// }
// return this.backOffHandlers_[pluginId];
// }
public async run(plugin: Plugin, pluginApi: Global) {
const scriptPath = `${Setting.value('tempDir')}/plugin_${plugin.id}.js`;

View File

@ -230,27 +230,23 @@ const appReducer = (state = appDefaultState, action: any) => {
try {
switch (action.type) {
// @ts-ignore
case 'NAV_BACK':
{
if (!navHistory.length) break;
let newAction = null;
while (navHistory.length) {
newAction = navHistory.pop();
if (newAction.routeName !== state.route.routeName) break;
}
action = newAction ? newAction : navHistory.pop();
historyGoingBack = true;
}
// Fall throught
case 'NAV_GO':
if (action.type === 'NAV_BACK') {
if (!navHistory.length) break;
let newAction = null;
while (navHistory.length) {
newAction = navHistory.pop();
if (newAction.routeName !== state.route.routeName) break;
}
action = newAction ? newAction : navHistory.pop();
historyGoingBack = true;
}
{
const currentRoute = state.route;
@ -426,7 +422,6 @@ async function initialize(dispatch: Function) {
value: profileConfig,
});
// @ts-ignore
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
Setting.setConstant('appId', 'net.cozic.joplin-mobile');
Setting.setConstant('appType', 'mobile');

View File

@ -2,9 +2,7 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
"plugin:@typescript-eslint/recommended"
],
"env": {
"node": true,

View File

@ -51,7 +51,6 @@
"@typescript-eslint/parser": "5.59.0",
"coveralls": "3.1.1",
"eslint": "8.39.0",
"eslint-config-prettier": "8.8.0",
"jest": "29.5.0",
"prettier": "2.8.8",
"ts-jest": "29.1.0",

View File

@ -8,8 +8,7 @@ export class CollectingHandler extends MultiplexHandler {
constructor(cbs: Partial<Handler> = {}) {
super((name, ...args) => {
this.events.push([name, ...args]);
// @ts-ignore
if (this._cbs[name]) this._cbs[name](...args);
if (this._cbs[name]) (this._cbs as any)[name](...args);
});
this._cbs = cbs;
@ -31,8 +30,7 @@ export class CollectingHandler extends MultiplexHandler {
continue;
}
// @ts-ignore
this._cbs[name](...args);
(this._cbs as any)[name](...args);
}
}
}

View File

@ -179,8 +179,7 @@ function addConditionally<T>(
recurse = false
) {
const tmp = fetch(what, where, recurse);
// @ts-ignore
if (tmp) obj[prop] = tmp;
if (tmp) (obj as any)[prop] = tmp;
}
function isValidFeed(value: string) {

View File

@ -225,8 +225,7 @@ export class Parser extends EventEmitter {
//Tokenizer event handlers
ontext(data: string) {
this._updatePosition(1);
// @ts-ignore
this.endIndex--;
this.endIndex = this.endIndex === null ? 0 : this.endIndex + 1;
if (this._cbs.ontext) this._cbs.ontext(data);
}
@ -241,8 +240,7 @@ export class Parser extends EventEmitter {
) {
for (
let el;
// @ts-ignore
openImpliesClose[name].has(
(openImpliesClose as any)[name].has(
(el = this._stack[this._stack.length - 1])
);
this.onclosetag(el)
@ -305,8 +303,7 @@ export class Parser extends EventEmitter {
if (pos !== -1) {
if (this._cbs.onclosetag) {
pos = this._stack.length - pos;
// @ts-ignore
while (pos--) this._cbs.onclosetag(this._stack.pop());
while (pos--) this._cbs.onclosetag((this._stack as any).pop());
} else this._stack.length = pos;
} else if (name === "p" && !this._options.xmlMode) {
this.onopentagname(name);

View File

@ -563,8 +563,7 @@ export default class Tokenizer {
),
map = this._xmlMode ? xmlMap : entityMap;
if (Object.prototype.hasOwnProperty.call(map, entity)) {
// @ts-ignore
this._emitPartial(map[entity]);
this._emitPartial((map as any)[entity]);
this._sectionStart = this._index + 1;
}
}
@ -578,8 +577,7 @@ export default class Tokenizer {
// The min length of legacy entities is 2
const entity = this._buffer.substr(start, limit);
if (Object.prototype.hasOwnProperty.call(legacyMap, entity)) {
// @ts-ignore
this._emitPartial(legacyMap[entity]);
this._emitPartial((legacyMap as any)[entity]);
this._sectionStart += limit + 1;
return;
} else {

View File

@ -51,8 +51,7 @@ function eventReducer(events: Event[], arr: [string, ...unknown[]]): Event[] {
events[events.length - 1].event === "text"
) {
// Combine text nodes
// @ts-ignore
events[events.length - 1].data[0] += arr[1];
(events as any)[events.length - 1].data[0] += arr[1];
} else {
events.push({
event: arr[0].substr(2),

View File

@ -7,7 +7,7 @@ function useEventListener(
element?: any
) {
// Create a ref that stores handler
const savedHandler = useRef();
const savedHandler = useRef<any>();
useEffect(() => {
// Define the listening target
@ -25,7 +25,6 @@ function useEventListener(
const eventListener = (event: Event) => {
// eslint-disable-next-line no-extra-boolean-cast
if (!!savedHandler?.current) {
// @ts-ignore
savedHandler.current(event);
}
};

View File

@ -192,8 +192,7 @@ export default class ResourceEditWatcher {
// that event is not event triggered.
// https://github.com/laurent22/joplin/issues/3407
//
// @ts-ignore Leave unused path variable
this.watcher_.on('raw', (event: string, path: string, options: any) => {
this.watcher_.on('raw', (event: string, _path: string, options: any) => {
const watchedPath = options.watchedPath ? toSystemSlashes(options.watchedPath, 'linux') : '';
this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${watchedPath}`);

View File

@ -6,14 +6,10 @@ export default class InteropService_Exporter_Base {
private context_: any = {};
private metadata_: any = {};
// @ts-ignore
public async init(destDir: string, options: any = {}) {}
// @ts-ignore
public async prepareForProcessingItemType(itemType: number, itemsToExport: any[]) {}
// @ts-ignore
public async processItem(itemType: number, item: any) {}
// @ts-ignore
public async processResource(resource: any, filePath: string) {}
public async init(_destDir: string, _options: any = {}) {}
public async prepareForProcessingItemType(_itemType: number, _itemsToExport: any[]) {}
public async processItem(_itemType: number, _item: any) {}
public async processResource(_resource: any, _filePath: string) {}
public async close() {}
public setMetadata(md: any) {

View File

@ -23,8 +23,7 @@ export default class InteropService_Importer_Base {
this.options_ = options;
}
// @ts-ignore
public async exec(result: ImportExportResult): Promise<ImportExportResult> {}
public async exec(_result: ImportExportResult): Promise<ImportExportResult> { return null; }
protected async temporaryDirectory_(createIt: boolean) {
const md5 = require('md5');

View File

@ -39,7 +39,7 @@ export interface ShareInvitation {
export interface State {
shares: StateShare[];
shareUsers: Record<string, StateShareUser>;
shareUsers: Record<string, StateShareUser[]>;
shareInvitations: ShareInvitation[];
processingShareInvitationResponse: boolean;
}

View File

@ -22,8 +22,7 @@ if (Platform.OS === 'android') {
)
) as SafxInterface;
} else {
// @ts-ignore
SafX = {};
SafX = {} as any;
}
export type Encoding = 'utf8' | 'base64' | 'ascii';

View File

@ -9,8 +9,7 @@
// the code.
function plugin(markdownIt: any) {
// @ts-ignore: Keep the function signature as-is despite unusued arguments
markdownIt.renderer.rules.fence = function(tokens: any[], idx: number, options: any, env: any, slf: any) {
markdownIt.renderer.rules.fence = function(tokens: any[], idx: number, options: any, _env: any, slf: any) {
let token = tokens[idx],
info = token.info ? markdownIt.utils.unescapeAll(token.info).trim() : '',
langName = '',

View File

@ -4488,7 +4488,6 @@ __metadata:
domutils: 3.1.0
entities: 2.2.0
eslint: 8.39.0
eslint-config-prettier: 8.8.0
jest: 29.5.0
prettier: 2.8.8
ts-jest: 29.1.0
@ -15365,7 +15364,7 @@ __metadata:
languageName: node
linkType: hard
"eslint-config-prettier@npm:8.8.0, eslint-config-prettier@npm:>=8.0.0":
"eslint-config-prettier@npm:>=8.0.0":
version: 8.8.0
resolution: "eslint-config-prettier@npm:8.8.0"
peerDependencies: