You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
Tools: Add eslint rule "jest/require-top-level-describe"
This commit is contained in:
@ -91,6 +91,8 @@ module.exports = {
|
|||||||
// Disable because of this: https://github.com/facebook/react/issues/16265
|
// Disable because of this: https://github.com/facebook/react/issues/16265
|
||||||
// "react-hooks/exhaustive-deps": "warn",
|
// "react-hooks/exhaustive-deps": "warn",
|
||||||
|
|
||||||
|
'jest/require-top-level-describe': ['error', { 'maxNumberOfTopLevelDescribes': 1 }],
|
||||||
|
|
||||||
'promise/prefer-await-to-then': 'error',
|
'promise/prefer-await-to-then': 'error',
|
||||||
'no-unneeded-ternary': 'error',
|
'no-unneeded-ternary': 'error',
|
||||||
|
|
||||||
@ -155,6 +157,7 @@ module.exports = {
|
|||||||
// 'react-hooks',
|
// 'react-hooks',
|
||||||
'import',
|
'import',
|
||||||
'promise',
|
'promise',
|
||||||
|
'jest',
|
||||||
],
|
],
|
||||||
'overrides': [
|
'overrides': [
|
||||||
{
|
{
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
"eslint": "8.31.0",
|
"eslint": "8.31.0",
|
||||||
"eslint-interactive": "10.3.0",
|
"eslint-interactive": "10.3.0",
|
||||||
"eslint-plugin-import": "2.27.4",
|
"eslint-plugin-import": "2.27.4",
|
||||||
|
"eslint-plugin-jest": "27.2.1",
|
||||||
"eslint-plugin-promise": "6.1.1",
|
"eslint-plugin-promise": "6.1.1",
|
||||||
"eslint-plugin-react": "7.32.0",
|
"eslint-plugin-react": "7.32.0",
|
||||||
"fs-extra": "11.1.0",
|
"fs-extra": "11.1.0",
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable jest/require-top-level-describe */
|
||||||
|
|
||||||
import KeychainService from '@joplin/lib/services/keychain/KeychainService';
|
import KeychainService from '@joplin/lib/services/keychain/KeychainService';
|
||||||
import shim from '@joplin/lib/shim';
|
import shim from '@joplin/lib/shim';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
|
@ -260,10 +260,6 @@ describe('useLayoutItemSizes', () => {
|
|||||||
expect(sizes.col4.width).toBe(50);
|
expect(sizes.col4.width).toBe(50);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('calculateMaxSizeAvailableForItem', () => {
|
|
||||||
|
|
||||||
test('should give maximum available space this item can take up during resizing', () => {
|
test('should give maximum available space this item can take up during resizing', () => {
|
||||||
const layout: LayoutItem = validateLayout({
|
const layout: LayoutItem = validateLayout({
|
||||||
key: 'root',
|
key: 'root',
|
||||||
|
@ -6,15 +6,15 @@ const { shimInit } = require('@joplin/lib/shim-init-node.js');
|
|||||||
const folderId1 = 'aa012345678901234567890123456789';
|
const folderId1 = 'aa012345678901234567890123456789';
|
||||||
const folderId2 = 'bb012345678901234567890123456789';
|
const folderId2 = 'bb012345678901234567890123456789';
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
shimInit();
|
|
||||||
Setting.autoSaveEnabled = false;
|
|
||||||
PerFolderSortOrderService.initialize();
|
|
||||||
Setting.setValue('notes.perFolderSortOrderEnabled', true);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('PerFolderSortOrderService', () => {
|
describe('PerFolderSortOrderService', () => {
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
shimInit();
|
||||||
|
Setting.autoSaveEnabled = false;
|
||||||
|
PerFolderSortOrderService.initialize();
|
||||||
|
Setting.setValue('notes.perFolderSortOrderEnabled', true);
|
||||||
|
});
|
||||||
|
|
||||||
test('get(), isSet() and set()', async () => {
|
test('get(), isSet() and set()', async () => {
|
||||||
// Clear all per-folder sort order
|
// Clear all per-folder sort order
|
||||||
expect(PerFolderSortOrderService.isSet(folderId1)).toBe(false);
|
expect(PerFolderSortOrderService.isSet(folderId1)).toBe(false);
|
||||||
|
@ -2,13 +2,13 @@ import { notesSortOrderFieldArray, notesSortOrderNextField, setNotesSortOrder }
|
|||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
const { shimInit } = require('@joplin/lib/shim-init-node.js');
|
const { shimInit } = require('@joplin/lib/shim-init-node.js');
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
shimInit();
|
|
||||||
Setting.autoSaveEnabled = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('notesSortOrderUtils', () => {
|
describe('notesSortOrderUtils', () => {
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
shimInit();
|
||||||
|
Setting.autoSaveEnabled = false;
|
||||||
|
});
|
||||||
|
|
||||||
it('should always provide the same ordered fields', async () => {
|
it('should always provide the same ordered fields', async () => {
|
||||||
const expected = ['user_updated_time', 'user_created_time', 'title', 'order'];
|
const expected = ['user_updated_time', 'user_created_time', 'title', 'order'];
|
||||||
expect(notesSortOrderFieldArray()).toStrictEqual(expected);
|
expect(notesSortOrderFieldArray()).toStrictEqual(expected);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
const { setupDatabaseAndSynchronizer, switchClient, supportDir } = require('./testing/test-utils.js');
|
const { setupDatabaseAndSynchronizer, switchClient, supportDir } = require('./testing/test-utils.js');
|
||||||
const shim = require('./shim').default;
|
const shim = require('./shim').default;
|
||||||
const { enexXmlToHtml } = require('./import-enex-html-gen.js');
|
const { enexXmlToHtml } = require('./import-enex-html-gen.js');
|
||||||
@ -50,6 +49,7 @@ const compareOutputToExpected = (options) => {
|
|||||||
const outputFile = fileWithPath(`${options.testName}.html`);
|
const outputFile = fileWithPath(`${options.testName}.html`);
|
||||||
const testTitle = `should convert from Enex to Html: ${options.testName}`;
|
const testTitle = `should convert from Enex to Html: ${options.testName}`;
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/require-top-level-describe
|
||||||
it(testTitle, (async () => {
|
it(testTitle, (async () => {
|
||||||
const enexInput = await shim.fsDriver().readFile(inputFile);
|
const enexInput = await shim.fsDriver().readFile(inputFile);
|
||||||
const expectedOutput = await shim.fsDriver().readFile(outputFile);
|
const expectedOutput = await shim.fsDriver().readFile(outputFile);
|
||||||
|
@ -409,13 +409,10 @@ describe('models/Note', () => {
|
|||||||
expect(movedNote.conflict_original_id).toBe('');
|
expect(movedNote.conflict_original_id).toBe('');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('models/Note_replacePaths', () => {
|
|
||||||
|
|
||||||
function testResourceReplacment(body: string, pathsToTry: string[], expected: string) {
|
function testResourceReplacment(body: string, pathsToTry: string[], expected: string) {
|
||||||
expect(Note['replaceResourceExternalToInternalLinks_'](pathsToTry, body)).toBe(expected);
|
expect(Note['replaceResourceExternalToInternalLinks_'](pathsToTry, body)).toBe(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Basic replacement', () => {
|
test('Basic replacement', () => {
|
||||||
const body = '';
|
const body = '';
|
||||||
const pathsToTry = ['file:///C:Users/Username/resources'];
|
const pathsToTry = ['file:///C:Users/Username/resources'];
|
||||||
@ -443,4 +440,5 @@ describe('models/Note_replacePaths', () => {
|
|||||||
const expected = '';
|
const expected = '';
|
||||||
testResourceReplacment(body, pathsToTry, expected);
|
testResourceReplacment(body, pathsToTry, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable jest/require-top-level-describe */
|
||||||
|
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import { Item } from '../../../services/database/types';
|
import { Item } from '../../../services/database/types';
|
||||||
import { ErrorCode } from '../../../utils/errors';
|
import { ErrorCode } from '../../../utils/errors';
|
||||||
|
81
yarn.lock
81
yarn.lock
@ -8067,6 +8067,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/scope-manager@npm:5.54.1":
|
||||||
|
version: 5.54.1
|
||||||
|
resolution: "@typescript-eslint/scope-manager@npm:5.54.1"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 5.54.1
|
||||||
|
"@typescript-eslint/visitor-keys": 5.54.1
|
||||||
|
checksum: 9add24cf3a7852634ad0680a827646860ac4698a6ac8aae31e8b781e29f59e84b51f0cdaacffd0747811012647f01b51969d988da9b302ead374ceebffbe204b
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/type-utils@npm:5.48.2":
|
"@typescript-eslint/type-utils@npm:5.48.2":
|
||||||
version: 5.48.2
|
version: 5.48.2
|
||||||
resolution: "@typescript-eslint/type-utils@npm:5.48.2"
|
resolution: "@typescript-eslint/type-utils@npm:5.48.2"
|
||||||
@ -8105,6 +8115,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/types@npm:5.54.1":
|
||||||
|
version: 5.54.1
|
||||||
|
resolution: "@typescript-eslint/types@npm:5.54.1"
|
||||||
|
checksum: 84a8f725cfa10646af389659e09c510c38d82c65960c7b613f844a264acc0e197471cba03f3e8f4b6411bc35dca28922c8352a7bd44621411c73fd6dd4096da2
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/typescript-estree@npm:5.48.2":
|
"@typescript-eslint/typescript-estree@npm:5.48.2":
|
||||||
version: 5.48.2
|
version: 5.48.2
|
||||||
resolution: "@typescript-eslint/typescript-estree@npm:5.48.2"
|
resolution: "@typescript-eslint/typescript-estree@npm:5.48.2"
|
||||||
@ -8123,6 +8140,24 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/typescript-estree@npm:5.54.1":
|
||||||
|
version: 5.54.1
|
||||||
|
resolution: "@typescript-eslint/typescript-estree@npm:5.54.1"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 5.54.1
|
||||||
|
"@typescript-eslint/visitor-keys": 5.54.1
|
||||||
|
debug: ^4.3.4
|
||||||
|
globby: ^11.1.0
|
||||||
|
is-glob: ^4.0.3
|
||||||
|
semver: ^7.3.7
|
||||||
|
tsutils: ^3.21.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
typescript:
|
||||||
|
optional: true
|
||||||
|
checksum: ea42bdb4832fa96fa1121237c9b664ac4506e2836646651e08a8542c8601d78af6c288779707f893ca4c884221829bb7d7b4b43c4a9c3ed959519266d03a139b
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/typescript-estree@npm:^4.8.2":
|
"@typescript-eslint/typescript-estree@npm:^4.8.2":
|
||||||
version: 4.33.0
|
version: 4.33.0
|
||||||
resolution: "@typescript-eslint/typescript-estree@npm:4.33.0"
|
resolution: "@typescript-eslint/typescript-estree@npm:4.33.0"
|
||||||
@ -8177,6 +8212,24 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/utils@npm:^5.10.0":
|
||||||
|
version: 5.54.1
|
||||||
|
resolution: "@typescript-eslint/utils@npm:5.54.1"
|
||||||
|
dependencies:
|
||||||
|
"@types/json-schema": ^7.0.9
|
||||||
|
"@types/semver": ^7.3.12
|
||||||
|
"@typescript-eslint/scope-manager": 5.54.1
|
||||||
|
"@typescript-eslint/types": 5.54.1
|
||||||
|
"@typescript-eslint/typescript-estree": 5.54.1
|
||||||
|
eslint-scope: ^5.1.1
|
||||||
|
eslint-utils: ^3.0.0
|
||||||
|
semver: ^7.3.7
|
||||||
|
peerDependencies:
|
||||||
|
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||||
|
checksum: 8f428ea4d338ce85d55fd0c9ae2b217b323f29f51b7c9f8077fef7001ca21d28b032c5e5165b67ae6057aef69edb0e7a164c3c483703be6f3e4e574248bbc399
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@typescript-eslint/visitor-keys@npm:4.33.0":
|
"@typescript-eslint/visitor-keys@npm:4.33.0":
|
||||||
version: 4.33.0
|
version: 4.33.0
|
||||||
resolution: "@typescript-eslint/visitor-keys@npm:4.33.0"
|
resolution: "@typescript-eslint/visitor-keys@npm:4.33.0"
|
||||||
@ -8207,6 +8260,16 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"@typescript-eslint/visitor-keys@npm:5.54.1":
|
||||||
|
version: 5.54.1
|
||||||
|
resolution: "@typescript-eslint/visitor-keys@npm:5.54.1"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/types": 5.54.1
|
||||||
|
eslint-visitor-keys: ^3.3.0
|
||||||
|
checksum: 3a691abd2a43b86a0c41526d14a2afcc93a2e0512b5f8b9ec43f6029c493870808036eae5ee4fc655d26e1999017c4a4dffb241f47c36c2a1238ec9fbd08719c
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"@webassemblyjs/ast@npm:1.11.1":
|
"@webassemblyjs/ast@npm:1.11.1":
|
||||||
version: 1.11.1
|
version: 1.11.1
|
||||||
resolution: "@webassemblyjs/ast@npm:1.11.1"
|
resolution: "@webassemblyjs/ast@npm:1.11.1"
|
||||||
@ -15194,6 +15257,23 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"eslint-plugin-jest@npm:27.2.1":
|
||||||
|
version: 27.2.1
|
||||||
|
resolution: "eslint-plugin-jest@npm:27.2.1"
|
||||||
|
dependencies:
|
||||||
|
"@typescript-eslint/utils": ^5.10.0
|
||||||
|
peerDependencies:
|
||||||
|
"@typescript-eslint/eslint-plugin": ^5.0.0
|
||||||
|
eslint: ^7.0.0 || ^8.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
"@typescript-eslint/eslint-plugin":
|
||||||
|
optional: true
|
||||||
|
jest:
|
||||||
|
optional: true
|
||||||
|
checksum: 579a4d26304cc6748b2e6dff6c965ea7a21b618d8b051eb02727d25cf5c7767f6db8ef5237531635ff77e242b983b973e7cb8c820a4d20d5bda73358c452a8ab
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"eslint-plugin-n@npm:^15.1.0":
|
"eslint-plugin-n@npm:^15.1.0":
|
||||||
version: 15.5.1
|
version: 15.5.1
|
||||||
resolution: "eslint-plugin-n@npm:15.5.1"
|
resolution: "eslint-plugin-n@npm:15.5.1"
|
||||||
@ -28041,6 +28121,7 @@ __metadata:
|
|||||||
eslint: 8.31.0
|
eslint: 8.31.0
|
||||||
eslint-interactive: 10.3.0
|
eslint-interactive: 10.3.0
|
||||||
eslint-plugin-import: 2.27.4
|
eslint-plugin-import: 2.27.4
|
||||||
|
eslint-plugin-jest: 27.2.1
|
||||||
eslint-plugin-promise: 6.1.1
|
eslint-plugin-promise: 6.1.1
|
||||||
eslint-plugin-react: 7.32.0
|
eslint-plugin-react: 7.32.0
|
||||||
fs-extra: 11.1.0
|
fs-extra: 11.1.0
|
||||||
|
Reference in New Issue
Block a user