Skip to content

Commit b482413

Browse files
authored
Improve linting / Fix typos / Security Audit (#81)
* Remove "debug" from allowed console methods in ESLint configuration * Fix typos * Fix More typos * Fix Security Audit
1 parent a0a5367 commit b482413

8 files changed

Lines changed: 66 additions & 68 deletions

File tree

.eslintrc.release

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
"allow": [
1010
"warn",
1111
"error",
12-
"debug"
1312
]
1413
}
1514
],
1615
"multiline-comment-style": [
1716
"error",
18-
"starred-block"
17+
"starred-block",
1918
]
2019
}
2120
}

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If not related issue exists, open a new one using the appropriate <a href="../..
2525
### Start working:
2626
#### 1. Fork the repository.
2727
#### 2. Create a new vault
28-
Just for testing the plugin so you **can't** exedentially destroy your real vault
28+
Just for testing the plugin so you **can't** accidentally destroy your real vault
2929
#### 3. Clone repository to your local machine.
3030
```shell
3131
cd path/to/vault

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ Fixes # <!-- Issue number --->
2020
- [<!-- x --> ] I have performed a self-review of my code
2121
- [<!-- x --> ] I have commented my code, particularly in hard-to-understand areas
2222
- [<!-- x --> ] I have made corresponding changes to the documentation
23-
- [<!-- x --> ] I have tested my changes in Obsidian and describte how I tested in [Tests](#tests)
23+
- [<!-- x --> ] I have tested my changes in Obsidian and described how I tested in [Tests](#tests)
2424
- [<!-- x --> ] My code fixes the feature discussed in [Related Issues](#related-issues) if not or not fully describe what is missing in [Missing changes](#missing-changes)

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ Allows you to create various global settings profiles. You can sync them between
1111
![SettingsProfiles-VaultSwitchDemo_v5](https://github.com/4Source/settings-profiles-obsidian-plugin/assets/38220764/5c68105f-6613-4ba6-ab6b-c581b4badab7)
1212
The demo shows creating a new profile for an existing vault with a theme set and plugin installed. Then a new vault is created and settings profiles are installed. After installation, the previously created profile will be automatically recognized. This is selected and loads all settings including themes and plugins. The newly created vault will then have the same settings as the existing vault.
1313

14-
1514
# Usage
1615
After enabling the plugin in the settings menu, you need to create a new profile.
1716

18-
You can do this in the settings tab. Just click on the "Add new Profile". Give it a name and select whitch options should be enabled. To switch between profiles click on "Switch to Profile" obsidian should reload.
17+
You can do this in the settings tab. Just click on the "Add new Profile". Give it a name and select which options should be enabled. To switch between profiles click on "Switch to Profile" obsidian should reload.
1918

2019
# Features
21-
- Multible profile settings
20+
- Multiple profile settings
2221
- Easy and fast switch settings
2322
- Global settings
2423

@@ -91,7 +90,7 @@ The [profiles list](#Profiles-list) below will be reloaded from the files.
9190
## Profiles list
9291
As soon as you have created a profile, all profiles stored in the [Profile save path](#Profile-save-path-) will be listed here.
9392
### Profile ![settings](https://github.com/4Source/settings-profiles-obsidian-plugin/assets/38220764/88596802-e7b7-4bba-986d-6972758fce99) *Button*
94-
Let you cange the [Profile options](#Profile-options) for the profile.
93+
Let you change the [Profile options](#Profile-options) for the profile.
9594
### Profile ![trash-2](https://github.com/4Source/settings-profiles-obsidian-plugin/assets/38220764/ec7767a9-1b49-4cc1-874e-7ee85aec907f) *Button*
9695
Deletes this profile and all settings. **Attention!** This will delete this profile globally. You can no longer access it in any vault.
9796
<!-- ### Profile ![plus-circle](https://github.com/4Source/settings-profiles-obsidian-plugin/assets/38220764/228a9cd7-1904-48d2-9c9c-5c1b5f2691c9) *Button*
@@ -106,10 +105,10 @@ Indicates that this profile is not selected. By pressing this button you can swi
106105

107106
# Profile options
108107
### Name
109-
Containes the name of the profile.
108+
Contains the name of the profile.
110109
### Auto-Sync
111110
If activated, changes in the settings are automatically saved as long as the profile is active and [Profile update](#Profile_update) is enabled.
112-
### Apperance
111+
### Appearance
113112
Controls whether the appearance settings should be saved in this profile. This includes CSS snippets and themes.
114113
### App
115114
Controls whether the app settings should be saved in this profile. The app settings includes the "Editor"-tab and "Files and links"-tab.
@@ -118,11 +117,11 @@ Controls whether the bookmarks should be saved in this profile.
118117
### Community plugins
119118
Controls the community plugins should be saved in this profile. This includes which plugins are activated, the source code and the settings that were made for the plugin.
120119
### Core plugins
121-
Controls wheter the core plugins settings should be saved in this profile.
120+
Controls whether the core plugins settings should be saved in this profile.
122121
### Graph
123-
Controls wheter the graph settings should be saved in this profile.
122+
Controls whether the graph settings should be saved in this profile.
124123
### Hotkeys
125-
Controls wheter the hotkeys settings should be saved in this profile.
124+
Controls whether the hotkeys settings should be saved in this profile.
126125

127126
# Status-Bar
128127
### Status-Bar ![users](https://github.com/4Source/settings-profiles-obsidian-plugin/assets/38220764/d3bee41e-57be-478d-bbf0-a691f165a02e)
@@ -148,7 +147,7 @@ Updates the UI elements.
148147

149148
# Admittance
150149
### Access file outside vault
151-
Is requiered to save setting profiles at a global space so they could be accessed from different vaults.
150+
Is required to save setting profiles at a global space so they could be accessed from different vaults.
152151

153152
# Contribution
154153
Feel free to contribute.

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
3535
this.updateProfile();
3636
}
3737
else if (!getIgnoreFilesList(profile).contains(filename)) {
38+
// TODO: Maybe use like git reference by content with a hash over the content to identify changes instead of modifiedAt date should be more stable with synchronizing across devices
3839
profile.modifiedAt = new Date();
3940
this.updateCurrentProfile(profile);
4041
}
@@ -319,12 +320,12 @@ export default class SettingsProfilesPlugin extends PluginExtended {
319320
/**
320321
* Check relevant files for profile are changed
321322
* @param profile The profile to check
322-
* @returns `ture` if at least one file has changed and is newer than the saved profile
323+
* @returns `true` if at least one file has changed and is newer than the saved profile
323324
*/
324325
areSettingsChanged(profile: ProfileOptions): boolean {
325326
try {
326327
const sourcePath = [getVaultPath(), this.app.vault.configDir];
327-
const targetPath = [this.getAbsolutProfilesPath(), profile.name];
328+
const targetPath = [this.getAbsoluteProfilesPath(), profile.name];
328329

329330
// Check target dir exist
330331
if (!existsSync(join(...sourcePath))) {
@@ -351,12 +352,12 @@ export default class SettingsProfilesPlugin extends PluginExtended {
351352
/**
352353
* Check relevant files for profile are saved
353354
* @param profile The profile to check
354-
* @returns `ture` if at no file has changed or all are older than the saved profile
355+
* @returns `true` if at no file has changed or all are older than the saved profile
355356
*/
356357
areSettingsSaved(profile: ProfileOptions): boolean {
357358
try {
358359
const sourcePath = [getVaultPath(), this.app.vault.configDir];
359-
const targetPath = [this.getAbsolutProfilesPath(), profile.name];
360+
const targetPath = [this.getAbsoluteProfilesPath(), profile.name];
360361

361362
// Check target dir exist
362363
if (!existsSync(join(...sourcePath))) {
@@ -392,7 +393,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
392393
// Load profile data
393394
this.getProfilesList().forEach((value, index, array) => {
394395
if (value.name === profile.name) {
395-
array[index] = loadProfileOptions(profile, this.getAbsolutProfilesPath()) || value;
396+
array[index] = loadProfileOptions(profile, this.getAbsoluteProfilesPath()) || value;
396397
}
397398
});
398399
return this.getProfile(profile.name);
@@ -413,7 +414,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
413414
await this.saveProfile(profile.name);
414415

415416
// Save profile data
416-
await saveProfileOptions(profile, this.getAbsolutProfilesPath());
417+
await saveProfileOptions(profile, this.getAbsoluteProfilesPath());
417418

418419
// Reload profiles list from files
419420
this.refreshProfilesList();
@@ -439,7 +440,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
439440
if (profileName === '') {
440441
// Open dialog save current profile
441442
if (currentProfile) {
442-
new DialogModal(this.app, 'Save befor deselect profile?', 'Otherwise, unsaved changes will be lost.', async () => {
443+
new DialogModal(this.app, 'Save before deselect profile?', 'Otherwise, unsaved changes will be lost.', async () => {
443444
// Save current profile
444445
await this.saveProfileSettings(currentProfile);
445446
}, async () => { }, 'Save', false, 'Do not Save')
@@ -459,7 +460,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
459460

460461
// Check is current profile
461462
if (currentProfile?.name === targetProfile.name) {
462-
new Notice('Allready current profile!');
463+
new Notice('Already current profile!');
463464
return;
464465
}
465466

@@ -474,7 +475,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
474475
this.updateCurrentProfile(profile);
475476
});
476477

477-
// Open dialog obsidain should be reloaded
478+
// Open dialog obsidian should be reloaded
478479
new DialogModal(this.app, 'Reload Obsidian now?', 'This is required for changes to take effect.', () => {
479480
// Save Settings
480481
this.saveSettings().then(() => {
@@ -503,7 +504,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
503504
// Add profile to profileList
504505
this.appendProfilesList(profile);
505506

506-
// Enabel new Profile
507+
// Enable new Profile
507508
const selectedProfile = this.getProfilesList().find(value => value.name === profile.name);
508509
if (selectedProfile) {
509510
// Sync the profile settings
@@ -578,7 +579,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
578579
}
579580

580581
// Remove to profile settings
581-
removeDirectoryRecursiveSync([this.getAbsolutProfilesPath(), profileName]);
582+
removeDirectoryRecursiveSync([this.getAbsoluteProfilesPath(), profileName]);
582583
this.refreshProfilesList();
583584
await this.saveSettings();
584585
}
@@ -599,7 +600,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
599600
const profile = this.getProfile(profileName);
600601

601602
const sourcePath = [getVaultPath(), this.app.vault.configDir];
602-
const targetPath = [this.getAbsolutProfilesPath(), profileName];
603+
const targetPath = [this.getAbsoluteProfilesPath(), profileName];
603604
let changed = false;
604605

605606
// Check target dir exist
@@ -641,7 +642,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
641642
try {
642643
const profile = this.getProfile(profileName);
643644

644-
const sourcePath = [this.getAbsolutProfilesPath(), profileName];
645+
const sourcePath = [this.getAbsoluteProfilesPath(), profileName];
645646
const targetPath = [getVaultPath(), this.app.vault.configDir];
646647

647648
// Check target dir exist
@@ -721,7 +722,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
721722
* @throws {Error} If the device ID cannot be determined.
722723
* @throws {Error} If no valid profiles path can be found.
723724
*/
724-
getAbsolutProfilesPath(): string {
725+
getAbsoluteProfilesPath(): string {
725726
const relativePath = this.getProfilesPath();
726727
let path = relativePath;
727728

@@ -768,7 +769,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
768769
*/
769770
refreshProfilesList() {
770771
try {
771-
this.globalSettings.profilesList = loadProfilesOptions(this.getAbsolutProfilesPath());
772+
this.globalSettings.profilesList = loadProfilesOptions(this.getAbsoluteProfilesPath());
772773
return;
773774
}
774775
catch (e) {
@@ -827,7 +828,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
827828

828829
/**
829830
* Set the refresh interval in current settings
830-
* @param interval To what the invervall should be set to
831+
* @param interval To what the interval should be set to
831832
*/
832833
setUiRefreshInterval(interval: number) {
833834
if (interval > 0 && interval < 900000) {
@@ -897,7 +898,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
897898

898899
/**
899900
* Set the delay time for profile update in current settings
900-
* @param delay To what the invervall should be set to
901+
* @param delay To what the interval should be set to
901902
*/
902903
setProfileUpdateDelay(delay: number) {
903904
if (delay > 100 && delay < 900000) {
@@ -926,7 +927,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
926927
}
927928

928929
/**
929-
* Gets the currently enabeled profile.
930+
* Gets the currently enabled profile.
930931
* @returns The ProfileSetting object. Or undefined if not found.
931932
*/
932933
getCurrentProfile(): ProfileOptions | undefined {
@@ -973,9 +974,9 @@ export default class SettingsProfilesPlugin extends PluginExtended {
973974
}
974975

975976
/**
976-
* Checks profile contains all requiered properties
977+
* Checks profile contains all required properties
977978
* @param profile The profile to check
978-
* @returns True if profile contains all requiered properties
979+
* @returns True if profile contains all required properties
979980
*/
980981
isValidProfile(profile: ProfileOptions): boolean {
981982
let result = true;
@@ -1005,7 +1006,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
10051006
* @returns Is loaded profile newer/equal than saved profile
10061007
*/
10071008
isProfileUpToDate(profile: ProfileOptions): boolean {
1008-
const profileOptions = loadProfileOptions(profile, this.getAbsolutProfilesPath());
1009+
const profileOptions = loadProfileOptions(profile, this.getAbsoluteProfilesPath());
10091010

10101011
if (!profileOptions || !profileOptions.modifiedAt) {
10111012
return true;
@@ -1024,7 +1025,7 @@ export default class SettingsProfilesPlugin extends PluginExtended {
10241025
* @returns Is saved profile newer/equal than saved profile
10251026
*/
10261027
isProfileSaved(profile: ProfileOptions): boolean {
1027-
const profileOptions = loadProfileOptions(profile, this.getAbsolutProfilesPath());
1028+
const profileOptions = loadProfileOptions(profile, this.getAbsoluteProfilesPath());
10281029

10291030
if (!profileOptions || !profileOptions.modifiedAt) {
10301031
return false;

0 commit comments

Comments
 (0)