Skip to content

Commit

Permalink
chore: Make eslint rules stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
svsool committed Jan 23, 2022
1 parent 9b7cc58 commit 8c2fa64
Show file tree
Hide file tree
Showing 30 changed files with 118 additions and 33 deletions.
23 changes: 22 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,29 @@
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": ["@typescript-eslint", "prettier"],
"plugins": ["@typescript-eslint", "prettier", "folders", "unicorn"],
"rules": {
// kebab-case
"folders/match-regex": [2, "^[a-z-]+$", "/src/"],
"unicorn/filename-case": [
"error",
{
"cases": {
"camelCase": true,
"pascalCase": true
}
}
],
"import/no-internal-modules": [
"error", {
"forbid": [
"commands/*",
"features/*",
"utils/*",
"test/utils/*"
]
}
],
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,10 @@
"del-cli": "^4.0.1",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-folders": "^1.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unicorn": "^40.1.0",
"glob": "^7.2.0",
"husky": "^7.0.4",
"jest": "^27.4.5",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/extractRangeToNewNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
rndName,
createFile,
openTextDocument,
} from '../test/testUtils';
} from '../test/utils';

describe('extractRangeToNewNote command', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openDailyNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { commands, workspace } from 'vscode';
import moment from 'moment';

import openDailyNote from './openDailyNote';
import { closeEditorsAndCleanWorkspace } from '../test/testUtils';
import { closeEditorsAndCleanWorkspace } from '../test/utils';

describe('openDailyNote command', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openDocumentByReference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
closeEditorsAndCleanWorkspace,
toPlainObject,
updateMemoConfigProperty,
} from '../test/testUtils';
} from '../test/utils';

describe('openDocumentByReference command', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openRandomNote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
rndName,
getOpenedFilenames,
closeEditorsAndCleanWorkspace,
} from '../test/testUtils';
} from '../test/utils';

describe('openRandomNote command', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openReferenceBeside.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
rndName,
toPlainObject,
waitForExpect,
} from '../test/testUtils';
} from '../test/utils';

describe('openReferenceBeside command', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openReferenceInDefaultApp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
closeEditorsAndCleanWorkspace,
openTextDocument,
getWorkspaceFolder,
} from '../test/testUtils';
} from '../test/utils';

describe('openReferenceInDefaultApp command', () => {
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode';

import { closeEditorsAndCleanWorkspace } from './test/testUtils';
import { closeEditorsAndCleanWorkspace } from './test/utils';

const MEMO_EXTENSION_ID = 'svsool.markdown-memo';

Expand Down
2 changes: 1 addition & 1 deletion src/features/BacklinksTreeDataProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
toPlainObject,
updateMemoConfigProperty,
getMemoConfigProperty,
} from '../test/testUtils';
} from '../test/utils';

const getChildren = async () => {
const backlinksTreeDataProvider = new BacklinksTreeDataProvider();
Expand Down
2 changes: 1 addition & 1 deletion src/features/DocumentLinkProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
openTextDocument,
closeEditorsAndCleanWorkspace,
toPlainObject,
} from '../test/testUtils';
} from '../test/utils';

describe('DocumentLinkProvider', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/ReferenceHoverProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
openTextDocument,
closeEditorsAndCleanWorkspace,
toPlainObject,
} from '../test/testUtils';
} from '../test/utils';

describe('ReferenceHoverProvider', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/ReferenceProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
openTextDocument,
closeEditorsAndCleanWorkspace,
toPlainObject,
} from '../test/testUtils';
} from '../test/utils';

describe('ReferenceProvider', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/ReferenceRenameProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
rndName,
openTextDocument,
closeEditorsAndCleanWorkspace,
} from '../test/testUtils';
} from '../test/utils';

describe('ReferenceRenameProvider', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/codeActionProvider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import vscode from 'vscode';

import codeActionProvider from './codeActionProvider';
import { rndName, createFile, openTextDocument } from '../test/testUtils';
import { rndName, createFile, openTextDocument } from '../test/utils';

describe('codeActionProvider', () => {
it('should provide code actions', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/features/completionProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
openTextDocument,
closeEditorsAndCleanWorkspace,
updateMemoConfigProperty,
} from '../test/testUtils';
} from '../test/utils';

describe('provideCompletionItems()', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/extendMarkdownIt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getImgUrlForMarkdownPreview,
getFileUrlForMarkdownPreview,
escapeForRegExp,
} from '../test/testUtils';
} from '../test/utils';

describe('extendMarkdownIt feature', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/newVersionNotifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExtensionContext } from 'vscode';
import path from 'path';

import * as newVersionNotifier from './newVersionNotifier';
import { closeEditorsAndCleanWorkspace } from '../test/testUtils';
import { closeEditorsAndCleanWorkspace } from '../test/utils';

describe('newVersionNotifier feature', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/referenceContextWatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExtensionContext } from 'vscode';

import * as referenceContextWatcher from './referenceContextWatcher';
import { closeEditorsAndCleanWorkspace } from '../test/testUtils';
import { closeEditorsAndCleanWorkspace } from '../test/utils';

describe('referenceContextWatcher feature', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/features/syntaxDecorations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
rndName,
openTextDocument,
closeEditorsAndCleanWorkspace,
} from '../test/testUtils';
} from '../test/utils';

describe('getDecorations', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
1 change: 1 addition & 0 deletions src/test/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './utils';
4 changes: 2 additions & 2 deletions src/test/testUtils.spec.ts → src/test/utils/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';

import { createFile, rndName, cleanWorkspace, closeEditorsAndCleanWorkspace } from './testUtils';
import { createFile, rndName, cleanWorkspace, closeEditorsAndCleanWorkspace } from './utils';

describe('cleanWorkspace()', function () {
describe('cleanWorkspace()', () => {
beforeEach(closeEditorsAndCleanWorkspace);

afterEach(closeEditorsAndCleanWorkspace);
Expand Down
8 changes: 4 additions & 4 deletions src/test/testUtils.ts → src/test/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import path from 'path';
import { workspace, Uri, commands, ConfigurationTarget } from 'vscode';
export { default as waitForExpect } from 'wait-for-expect';

import { cache } from '../workspace';
import * as utils from '../utils';
import { WorkspaceCache } from '../types';
import { cache } from '../../workspace';
import * as utils from '../../utils';
import { WorkspaceCache } from '../../types';

const {
getWorkspaceFolder,
Expand Down Expand Up @@ -126,7 +126,7 @@ const getDefaultConfigProperties = (): {
description?: string;
type?: string;
}[] => {
return require('../../package.json').contributes.configuration.properties;
return require('../../../package.json').contributes.configuration.properties;
};

export const updateConfigProperty = async (
Expand Down
2 changes: 1 addition & 1 deletion src/utils/createDailyQuickPick.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment';

import createDailyQuickPick from './createDailyQuickPick';
import { closeEditorsAndCleanWorkspace, createFile } from '../test/testUtils';
import { closeEditorsAndCleanWorkspace, createFile } from '../test/utils';

describe('createDailyQuickPick()', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/externalUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
createFile,
openTextDocument,
rndName,
} from '../test/testUtils';
} from '../test/utils';

describe('lineBreakOffsetsByLineIndex()', () => {
it('should return offset for a single empty line', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/searchUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
createFile,
getWorkspaceFolder,
rndName,
} from '../test/testUtils';
} from '../test/utils';

describe('search()', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
rndName,
toPlainObject,
updateConfigProperty,
} from '../test/testUtils';
} from '../test/utils';

describe('containsImageExt()', () => {
test.each(['png', 'jpg', 'jpeg', 'gif'])(
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/cache/cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
closeEditorsAndCleanWorkspace,
createFile,
rndName,
} from '../../test/testUtils';
} from '../../test/utils';

describe('cacheWorkspace()', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/file-watcher/fileWatcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
getWorkspaceCache,
updateMemoConfigProperty,
waitForExpect,
} from '../../test/testUtils';
} from '../../test/utils';

describe('fileWatcher', () => {
beforeEach(closeEditorsAndCleanWorkspace);
Expand Down
Loading

0 comments on commit 8c2fa64

Please sign in to comment.