1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +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', 'project': './tsconfig.eslint.json',
}, },
'rules': { 'rules': {
'@typescript-eslint/ban-ts-comment': ['error'],
'@typescript-eslint/explicit-member-accessibility': ['error'], '@typescript-eslint/explicit-member-accessibility': ['error'],
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }], '@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
'@typescript-eslint/array-type': 'error', '@typescript-eslint/array-type': 'error',

View File

@ -846,9 +846,7 @@ class MainScreenComponent extends React.Component<Props, State> {
{this.renderPluginDialogs()} {this.renderPluginDialogs()}
{noteContentPropertiesDialogOptions.visible && <NoteContentPropertiesDialog markupLanguage={noteContentPropertiesDialogOptions.markupLanguage} themeId={this.props.themeId} onClose={this.noteContentPropertiesDialog_close} text={noteContentPropertiesDialogOptions.text}/>} {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} />} {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} />} {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} />} {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} /> <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 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'] }); 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... // Can't make any sense of this code so...
// @ts-ignore const notesById = notes.reduce((obj, { id, body, markup_language }) => ((obj[[id] as any] = { id, body, markup_language }), obj), {});
const notesById = notes.reduce((obj, { id, body, markup_language }) => ((obj[[id]] = { id, body, markup_language }), obj), {});
// Filter out search results that are associated with non-existing notes. // Filter out search results that are associated with non-existing notes.
// https://github.com/laurent22/joplin/issues/5417 // 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 { EventHandlers } from '@joplin/lib/services/plugins/utils/mapEventHandlersToIds';
import shim from '@joplin/lib/shim'; import shim from '@joplin/lib/shim';
import Logger from '@joplin/lib/Logger'; import Logger from '@joplin/lib/Logger';
import BackOffHandler from './BackOffHandler'; // import BackOffHandler from './BackOffHandler';
const ipcRenderer = require('electron').ipcRenderer; const ipcRenderer = require('electron').ipcRenderer;
const logger = Logger.create('PluginRunner'); const logger = Logger.create('PluginRunner');
@ -84,7 +84,7 @@ function mapEventIdsToHandlers(pluginId: string, arg: any) {
export default class PluginRunner extends BasePluginRunner { export default class PluginRunner extends BasePluginRunner {
protected eventHandlers_: EventHandlers = {}; protected eventHandlers_: EventHandlers = {};
private backOffHandlers_: Record<string, BackOffHandler> = {}; // private backOffHandlers_: Record<string, BackOffHandler> = {};
public constructor() { public constructor() {
super(); super();
@ -97,13 +97,12 @@ export default class PluginRunner extends BasePluginRunner {
return cb(...args); return cb(...args);
} }
// @ts-ignore // private backOffHandler(pluginId: string): BackOffHandler {
private backOffHandler(pluginId: string): BackOffHandler { // if (!this.backOffHandlers_[pluginId]) {
if (!this.backOffHandlers_[pluginId]) { // this.backOffHandlers_[pluginId] = new BackOffHandler(pluginId);
this.backOffHandlers_[pluginId] = new BackOffHandler(pluginId); // }
} // return this.backOffHandlers_[pluginId];
return this.backOffHandlers_[pluginId]; // }
}
public async run(plugin: Plugin, pluginApi: Global) { public async run(plugin: Plugin, pluginApi: Global) {
const scriptPath = `${Setting.value('tempDir')}/plugin_${plugin.id}.js`; const scriptPath = `${Setting.value('tempDir')}/plugin_${plugin.id}.js`;

View File

@ -230,27 +230,23 @@ const appReducer = (state = appDefaultState, action: any) => {
try { try {
switch (action.type) { switch (action.type) {
// @ts-ignore
case 'NAV_BACK': 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': 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; const currentRoute = state.route;
@ -426,7 +422,6 @@ async function initialize(dispatch: Function) {
value: profileConfig, value: profileConfig,
}); });
// @ts-ignore
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod'); Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
Setting.setConstant('appId', 'net.cozic.joplin-mobile'); Setting.setConstant('appId', 'net.cozic.joplin-mobile');
Setting.setConstant('appType', 'mobile'); Setting.setConstant('appType', 'mobile');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -192,8 +192,7 @@ export default class ResourceEditWatcher {
// that event is not event triggered. // that event is not event triggered.
// https://github.com/laurent22/joplin/issues/3407 // 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') : ''; const watchedPath = options.watchedPath ? toSystemSlashes(options.watchedPath, 'linux') : '';
this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${watchedPath}`); this.logger().debug(`ResourceEditWatcher: Raw event: ${event}: ${watchedPath}`);

View File

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

View File

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

View File

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

View File

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

View File

@ -9,8 +9,7 @@
// the code. // the code.
function plugin(markdownIt: any) { 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], let token = tokens[idx],
info = token.info ? markdownIt.utils.unescapeAll(token.info).trim() : '', info = token.info ? markdownIt.utils.unescapeAll(token.info).trim() : '',
langName = '', langName = '',

View File

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