Skip to content

Commit 02d90c2

Browse files
committed
fix lint
1 parent b4494df commit 02d90c2

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

src/core/AutoSyncService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class AutoSyncService
7777
{
7878
const { token, id, http_proxy } = syncingSettings;
7979
const localSettings = await this._vscodeSetting.getSettings(true);
80-
const localLastModified = await this._vscodeSetting.getLastModified(localSettings);
80+
const localLastModified = this._vscodeSetting.getLastModified(localSettings);
8181

8282
const api = Gist.create(token, http_proxy);
8383
const remoteSettings = await api.get(id);

src/core/Gist.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class Gist
2323
/**
2424
* The description of Syncing's gists.
2525
*/
26-
private static readonly GIST_DESCRIPTION: string = "VSCode's Settings - Syncing";
26+
private static readonly _GIST_DESCRIPTION: string = "VSCode's Settings - Syncing";
2727

2828
private _api: Github;
2929
private _proxy?: string;
@@ -150,7 +150,7 @@ export class Gist
150150
const gists: GitHubTypes.IGist[] = res.data as any;
151151
const extensionsRemoteFilename = `${SettingType.Extensions}.json`;
152152
return gists
153-
.filter((gist) => (gist.description === Gist.GIST_DESCRIPTION || gist.files[extensionsRemoteFilename]))
153+
.filter((gist) => (gist.description === Gist._GIST_DESCRIPTION || gist.files[extensionsRemoteFilename]))
154154
.sort((a, b) => new Date(a.updated_at).getTime() - new Date(b.updated_at).getTime());
155155
}
156156
catch (err)
@@ -241,7 +241,7 @@ export class Gist
241241
public createSettings(files = {}, isPublic = false): Promise<GitHubTypes.IGist>
242242
{
243243
return this.create({
244-
description: Gist.GIST_DESCRIPTION,
244+
description: Gist._GIST_DESCRIPTION,
245245
files,
246246
public: isPublic
247247
});
@@ -397,7 +397,7 @@ export class Gist
397397
// Add the rest local files.
398398
for (const key of Object.keys(localFiles))
399399
{
400-
if (recordedKeys.indexOf(key) === -1)
400+
if (!recordedKeys.includes(key))
401401
{
402402
// Ignore null local file.
403403
localFile = localFiles[key];

src/core/Syncing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Syncing
1818
/**
1919
* The default settings of `Syncing`.
2020
*/
21-
private static readonly DEFAULT_SETTINGS: ISyncingSettings = {
21+
private static readonly _DEFAULT_SETTINGS: ISyncingSettings = {
2222
id: "",
2323
token: "",
2424
http_proxy: "",
@@ -79,7 +79,7 @@ export class Syncing
7979
*/
8080
public initSettings(): Promise<void>
8181
{
82-
return this.saveSettings(Syncing.DEFAULT_SETTINGS);
82+
return this.saveSettings(Syncing._DEFAULT_SETTINGS);
8383
}
8484

8585
/**
@@ -181,7 +181,7 @@ export class Syncing
181181
*/
182182
public loadSettings(): ISyncingSettings
183183
{
184-
let settings: ISyncingSettings = { ...Syncing.DEFAULT_SETTINGS };
184+
let settings: ISyncingSettings = { ...Syncing._DEFAULT_SETTINGS };
185185
try
186186
{
187187
settings = {

src/core/VSCodeSetting.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export class VSCodeSetting
3535
/**
3636
* Suffix of remote mac files.
3737
*/
38-
private static readonly MAC_SUFFIX: string = "-mac";
38+
private static readonly _MAC_SUFFIX: string = "-mac";
3939

4040
/**
4141
* Prefix of remote snippet files.
4242
*/
43-
private static readonly SNIPPET_PREFIX: string = "snippet-";
43+
private static readonly _SNIPPET_PREFIX: string = "snippet-";
4444

4545
private _env: Environment;
4646
private _ext: Extension;
@@ -120,7 +120,7 @@ export class VSCodeSetting
120120
);
121121
if (separateKeybindings && this._env.isMac)
122122
{
123-
remoteFilename = `${settingType}${VSCodeSetting.MAC_SUFFIX}.json`;
123+
remoteFilename = `${settingType}${VSCodeSetting._MAC_SUFFIX}.json`;
124124
}
125125
}
126126

@@ -248,13 +248,13 @@ export class VSCodeSetting
248248
let filename: string;
249249
for (const key of Object.keys(files))
250250
{
251-
if (existsFileKeys.indexOf(key) === -1)
251+
if (!existsFileKeys.includes(key))
252252
{
253253
gistFile = files[key];
254-
if (gistFile.filename.startsWith(VSCodeSetting.SNIPPET_PREFIX))
254+
if (gistFile.filename.startsWith(VSCodeSetting._SNIPPET_PREFIX))
255255
{
256256
// Snippets.
257-
filename = gistFile.filename.slice(VSCodeSetting.SNIPPET_PREFIX.length);
257+
filename = gistFile.filename.slice(VSCodeSetting._SNIPPET_PREFIX.length);
258258
if (filename)
259259
{
260260
settingsToSave.push({
@@ -370,7 +370,7 @@ export class VSCodeSetting
370370
// Add prefix to all snippets.
371371
results.push({
372372
localFilePath: path.join(snippetsDir, filename),
373-
remoteFilename: `${VSCodeSetting.SNIPPET_PREFIX}${filename}`,
373+
remoteFilename: `${VSCodeSetting._SNIPPET_PREFIX}${filename}`,
374374
type: SettingType.Snippets
375375
});
376376
});

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function _initAutoSync()
6666
{
6767
setTimeout(async () =>
6868
{
69-
const syncingSettings = await _syncing.loadSettings();
69+
const syncingSettings = _syncing.loadSettings();
7070
if (syncingSettings.auto_sync && syncingSettings.token != null && syncingSettings.id != null)
7171
{
7272
_autoSyncService = AutoSyncService.create();

src/i18n/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let instance: I18n;
1010
class I18n
1111
{
1212
private static _instance: I18n;
13-
private static DEFAULT_LOCALE_FILENAME: string = "package.nls.json";
13+
private static _DEFAULT_LOCALE_FILENAME: string = "package.nls.json";
1414

1515
private _bundle: Record<string, string>;
1616
private _extensionPath: string;
@@ -63,7 +63,7 @@ class I18n
6363
private _prepare()
6464
{
6565
const filename = (this.locale === NormalizedLocale.EN_US)
66-
? I18n.DEFAULT_LOCALE_FILENAME
66+
? I18n._DEFAULT_LOCALE_FILENAME
6767
: `package.nls.${this.locale}.json`;
6868
try
6969
{
@@ -75,7 +75,7 @@ class I18n
7575
catch (err)
7676
{
7777
this._bundle = readJsonSync(
78-
path.resolve(this._extensionPath, I18n.DEFAULT_LOCALE_FILENAME),
78+
path.resolve(this._extensionPath, I18n._DEFAULT_LOCALE_FILENAME),
7979
{ encoding: "utf8" }
8080
);
8181
}

src/utils/jsonc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function mergeSettings(sSettingsJSONString: string, dSettingsJSONString:
7575
const sPatterns = sSettingsJSON[SETTING_EXCLUDED_SETTINGS] || [];
7676
const sExcludedKeys = getExcludedKeys(sSettingsJSON, sPatterns);
7777
const dExcludedKeys = getExcludedKeys(dSettingsJSON, sPatterns);
78-
const excludedKeys = Array.from<string>(new Set([...sExcludedKeys, ...dExcludedKeys])).sort();
78+
const excludedKeys = Array.from<string>(new Set([...sExcludedKeys, ...dExcludedKeys])).sort((a, b) => a.localeCompare(b));
7979

8080
// Replace the source properties with the corresponding destination properties values.
8181
let dValue: any;
@@ -125,7 +125,7 @@ export function getExcludedKeys(settingsJSON: object, patterns: string[]): strin
125125
excludeKeys.push(key);
126126
}
127127
}
128-
return excludeKeys.sort();
128+
return excludeKeys.sort((a, b) => a.localeCompare(b));
129129
}
130130

131131
/**

src/watcher/ChokidarFileWatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type ChokidarIgnoredFunction = (path: string, stats: Stats) => boolean;
1616

1717
export class ChokidarFileWatcher extends AbstractWatcher
1818
{
19-
private static readonly DEFAULT_OPTIONS = {
19+
private static readonly _DEFAULT_OPTIONS = {
2020
depth: 2,
2121
interval: 1000, // Increase the intervals when the chokidar fallbacks to polling,
2222
binaryInterval: 1000,
@@ -33,7 +33,7 @@ export class ChokidarFileWatcher extends AbstractWatcher
3333
{
3434
super();
3535
this._paths = paths;
36-
this._options = { ...ChokidarFileWatcher.DEFAULT_OPTIONS, ...options };
36+
this._options = { ...ChokidarFileWatcher._DEFAULT_OPTIONS, ...options };
3737
}
3838

3939
public start()

src/watcher/SettingsWatcherService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface SettingsWatcherServiceOptions
3131

3232
export class SettingsWatcherService extends AbstractWatcher<WatcherEvent.ALL>
3333
{
34-
private static readonly DEFAULT_OPTIONS: SettingsWatcherServiceOptions = {
34+
private static readonly _DEFAULT_OPTIONS: SettingsWatcherServiceOptions = {
3535
debounce: true,
3636
debounceDelay: 8000
3737
};
@@ -43,7 +43,7 @@ export class SettingsWatcherService extends AbstractWatcher<WatcherEvent.ALL>
4343
constructor(options?: SettingsWatcherServiceOptions)
4444
{
4545
super();
46-
this._options = { ...SettingsWatcherService.DEFAULT_OPTIONS, ...options };
46+
this._options = { ...SettingsWatcherService._DEFAULT_OPTIONS, ...options };
4747
if (this._options.debounce)
4848
{
4949
this._handleWatcherEvent = debounce(

0 commit comments

Comments
 (0)