mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-13 08:04:40 +08:00
lint(*): correct eslint errors, warnings still exist
There are warnings in `spellcheck-composer-extension.es6` for the `while (true)` loops.
This commit is contained in:
parent
876aea0ad9
commit
a1b9775b6d
2 changed files with 16 additions and 11 deletions
|
@ -113,7 +113,7 @@ export default class SpellcheckComposerExtension extends ComposerExtension {
|
||||||
// Traverses all of the text nodes within the provided `editor`. If it finds a
|
// Traverses all of the text nodes within the provided `editor`. If it finds a
|
||||||
// text node with a misspelled word, it splits it, wraps the misspelled word
|
// text node with a misspelled word, it splits it, wraps the misspelled word
|
||||||
// with a <spelling> node and updates the selection to account for the change.
|
// with a <spelling> node and updates the selection to account for the change.
|
||||||
static _wrapMisspelledWords = (editor)=> {
|
static _wrapMisspelledWords = (editor) => {
|
||||||
SpellcheckComposerExtension._whileApplyingSelectionChanges((selectionSnapshot)=> {
|
SpellcheckComposerExtension._whileApplyingSelectionChanges((selectionSnapshot)=> {
|
||||||
const treeWalker = document.createTreeWalker(editor.rootNode, NodeFilter.SHOW_TEXT);
|
const treeWalker = document.createTreeWalker(editor.rootNode, NodeFilter.SHOW_TEXT);
|
||||||
const nodeList = [];
|
const nodeList = [];
|
||||||
|
@ -179,14 +179,15 @@ export default class SpellcheckComposerExtension extends ComposerExtension {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static finalizeSessionBeforeSending = ({session})=> {
|
static finalizeSessionBeforeSending = ({session}) => {
|
||||||
const body = session.draft().body;
|
const body = session.draft().body;
|
||||||
const clean = body.replace(/<\/?spelling[^>]*>/g, '');
|
const clean = body.replace(/<\/?spelling[^>]*>/g, '');
|
||||||
|
|
||||||
if (body !== clean) {
|
if (body !== clean) {
|
||||||
return session.changes.add({body: clean});
|
return session.changes.add({body: clean});
|
||||||
} else {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
import AutoloadImagesExtension from '../lib/autoload-images-extension';
|
import AutoloadImagesExtension from '../lib/autoload-images-extension';
|
||||||
import AutoloadImagesStore from '../lib/autoload-images-store';
|
import AutoloadImagesStore from '../lib/autoload-images-store';
|
||||||
|
|
||||||
describe("AutoloadImagesExtension", ()=> {
|
describe("AutoloadImagesExtension", () => {
|
||||||
describe("formatMessageBody", ()=> {
|
describe("formatMessageBody", () => {
|
||||||
const scenarios = [];
|
const scenarios = [];
|
||||||
const fixtures = path.resolve(path.join(__dirname, 'fixtures'));
|
const fixtures = path.resolve(path.join(__dirname, 'fixtures'));
|
||||||
|
|
||||||
fs.readdirSync(fixtures).forEach((filename)=> {
|
fs.readdirSync(fixtures).forEach((filename) => {
|
||||||
if (filename.endsWith('-in.html')) {
|
if (filename.endsWith('-in.html')) {
|
||||||
const name = filename.replace('-in.html', '');
|
const name = filename.replace('-in.html', '');
|
||||||
|
|
||||||
scenarios.push({
|
scenarios.push({
|
||||||
name: name,
|
name: name,
|
||||||
in: fs.readFileSync(path.join(fixtures, filename)).toString(),
|
in: fs.readFileSync(path.join(fixtures, filename)).toString(),
|
||||||
|
@ -19,13 +21,15 @@ describe("AutoloadImagesExtension", ()=> {
|
||||||
});
|
});
|
||||||
|
|
||||||
scenarios.forEach((scenario)=> {
|
scenarios.forEach((scenario)=> {
|
||||||
it(`should process ${scenario.name}`, ()=> {
|
it(`should process ${scenario.name}`, () => {
|
||||||
spyOn(AutoloadImagesStore, 'shouldBlockImagesIn').andReturn(true);
|
spyOn(AutoloadImagesStore, 'shouldBlockImagesIn').andReturn(true);
|
||||||
message = {
|
|
||||||
body: scenario.in
|
const message = {
|
||||||
|
body: scenario.in,
|
||||||
};
|
};
|
||||||
AutoloadImagesExtension.formatMessageBody({message});
|
AutoloadImagesExtension.formatMessageBody({message});
|
||||||
expect(message.body == scenario.out).toBe(true);
|
|
||||||
|
expect(message.body === scenario.out).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue