Skip to content

Commit 1077cc1

Browse files
committed
Update prettier settings indent 2, line length 100
1 parent 11a4d76 commit 1077cc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+17272
-20174
lines changed

.eslintrc.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
module.exports = {
2-
root: true,
3-
parser: '@typescript-eslint/parser',
4-
parserOptions: {
5-
ecmaFeatures: {
6-
jsx: true,
7-
},
8-
sourceType: 'module',
9-
project: './tsconfig.eslint.json',
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaFeatures: {
6+
jsx: true,
107
},
11-
extends: [
12-
'eslint:recommended',
13-
'plugin:@typescript-eslint/eslint-recommended',
14-
'plugin:@typescript-eslint/recommended',
15-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
16-
'plugin:import/recommended',
17-
'plugin:import/typescript',
18-
'prettier',
19-
],
20-
plugins: ['@typescript-eslint', 'import'],
21-
env: {
22-
browser: true,
23-
commonjs: true,
24-
es6: true,
25-
node: true,
26-
},
27-
rules: {
28-
curly: ['error'],
29-
'import/no-unresolved': ['error', { ignore: ['^vscode$'] }], // errors
30-
'no-constant-condition': ['error', { checkLoops: false }],
31-
'prefer-const': ['error'],
32-
'prefer-rest-params': ['error'],
33-
'prefer-spread': ['error'],
34-
'array-callback-return': ['error'],
35-
'no-constructor-return': ['error'],
36-
'@typescript-eslint/no-inferrable-types': 'off',
37-
'@typescript-eslint/unbound-method': 'off',
38-
'@typescript-eslint/no-floating-promises': ['error'],
8+
sourceType: 'module',
9+
project: './tsconfig.eslint.json',
10+
},
11+
extends: [
12+
'eslint:recommended',
13+
'plugin:@typescript-eslint/eslint-recommended',
14+
'plugin:@typescript-eslint/recommended',
15+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
16+
'plugin:import/recommended',
17+
'plugin:import/typescript',
18+
'prettier',
19+
],
20+
plugins: ['@typescript-eslint', 'import'],
21+
env: {
22+
browser: true,
23+
commonjs: true,
24+
es6: true,
25+
node: true,
26+
},
27+
rules: {
28+
curly: ['error'],
29+
'import/no-unresolved': ['error', { ignore: ['^vscode$'] }], // errors
30+
'no-constant-condition': ['error', { checkLoops: false }],
31+
'prefer-const': ['error'],
32+
'prefer-rest-params': ['error'],
33+
'prefer-spread': ['error'],
34+
'array-callback-return': ['error'],
35+
'no-constructor-return': ['error'],
36+
'@typescript-eslint/no-inferrable-types': 'off',
37+
'@typescript-eslint/unbound-method': 'off',
38+
'@typescript-eslint/no-floating-promises': ['error'],
3939

40-
// 'no-unused-vars': 'off',
41-
// '@typescript-eslint/no-unused-vars': [
42-
// 'error',
43-
// {
44-
// vars: 'all',
45-
// args: 'after-used',
46-
// ignoreRestSiblings: true,
47-
// argsIgnorePattern: '^_',
48-
// },
49-
// ],
40+
// 'no-unused-vars': 'off',
41+
// '@typescript-eslint/no-unused-vars': [
42+
// 'error',
43+
// {
44+
// vars: 'all',
45+
// args: 'after-used',
46+
// ignoreRestSiblings: true,
47+
// argsIgnorePattern: '^_',
48+
// },
49+
// ],
5050

51-
'@typescript-eslint/no-explicit-any': 'off',
52-
'@typescript-eslint/no-unsafe-argument': 'off',
53-
'@typescript-eslint/no-unsafe-assignment': 'off',
54-
'@typescript-eslint/no-unsafe-call': 'off',
55-
'@typescript-eslint/no-unsafe-member-access': 'off',
56-
'@typescript-eslint/no-unsafe-return': 'off',
57-
'@typescript-eslint/no-unused-vars': 'off',
58-
'@typescript-eslint/restrict-plus-operands': 'off',
59-
'@typescript-eslint/restrict-template-expressions': 'off',
51+
'@typescript-eslint/no-explicit-any': 'off',
52+
'@typescript-eslint/no-unsafe-argument': 'off',
53+
'@typescript-eslint/no-unsafe-assignment': 'off',
54+
'@typescript-eslint/no-unsafe-call': 'off',
55+
'@typescript-eslint/no-unsafe-member-access': 'off',
56+
'@typescript-eslint/no-unsafe-return': 'off',
57+
'@typescript-eslint/no-unused-vars': 'off',
58+
'@typescript-eslint/restrict-plus-operands': 'off',
59+
'@typescript-eslint/restrict-template-expressions': 'off',
60+
},
61+
overrides: [
62+
{
63+
files: ['*.js'],
64+
rules: {
65+
'@typescript-eslint/no-var-requires': 'off',
66+
},
6067
},
61-
overrides: [
62-
{
63-
files: ['*.js'],
64-
rules: {
65-
'@typescript-eslint/no-var-requires': 'off',
66-
},
67-
},
68-
],
68+
],
6969
};

.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"printWidth": 80,
3-
"tabWidth": 4,
2+
"printWidth": 100,
3+
"tabWidth": 2,
44
"useTabs": false,
55
"semi": true,
66
"singleQuote": true,

src/analytics.ts

Lines changed: 56 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,73 @@ import * as os from 'os';
77
// debug.log = console.info.bind(console);
88

99
function userAllowsTelemetry(): boolean {
10-
const config = vscode.workspace.getConfiguration('telemetry');
11-
return config.get<boolean>('enableTelemetry', false);
10+
const config = vscode.workspace.getConfiguration('telemetry');
11+
return config.get<boolean>('enableTelemetry', false);
1212
}
1313

1414
export default class Analytics {
15-
private visitor: UA.Visitor;
16-
private extension: vscode.Extension<any>;
17-
private extensionVersion: string;
18-
private store: vscode.Memento;
19-
private GA_ID = (process.env.CALVA_DEV_GA
20-
? process.env.CALVA_DEV_GA
21-
: 'FUBAR-69796730-3'
22-
).replace(/^FUBAR/, 'UA');
15+
private visitor: UA.Visitor;
16+
private extension: vscode.Extension<any>;
17+
private extensionVersion: string;
18+
private store: vscode.Memento;
19+
private GA_ID = (process.env.CALVA_DEV_GA
20+
? process.env.CALVA_DEV_GA
21+
: 'FUBAR-69796730-3'
22+
).replace(/^FUBAR/, 'UA');
2323

24-
constructor(context: vscode.ExtensionContext) {
25-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26-
this.extension = vscode.extensions.getExtension(
27-
'betterthantomorrow.calva'
28-
)!;
29-
this.extensionVersion = this.extension.packageJSON.version;
30-
this.store = context.globalState;
24+
constructor(context: vscode.ExtensionContext) {
25+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26+
this.extension = vscode.extensions.getExtension('betterthantomorrow.calva')!;
27+
this.extensionVersion = this.extension.packageJSON.version;
28+
this.store = context.globalState;
3129

32-
this.visitor = UA(this.GA_ID, this.userID());
33-
this.visitor.set('cd1', this.extensionVersion);
34-
this.visitor.set('cd2', vscode.version);
35-
this.visitor.set('cd3', this.extensionVersion);
36-
this.visitor.set('cd4', `${os.platform()}/${os.release()}`);
37-
this.visitor.set('cn', `calva-${this.extensionVersion}`);
38-
this.visitor.set(
39-
'ua',
40-
`Calva/${
41-
this.extensionVersion
42-
} (${os.platform()}; ${os.release()}; ${os.type}) VSCode/${
43-
vscode.version
44-
}`
45-
);
46-
}
30+
this.visitor = UA(this.GA_ID, this.userID());
31+
this.visitor.set('cd1', this.extensionVersion);
32+
this.visitor.set('cd2', vscode.version);
33+
this.visitor.set('cd3', this.extensionVersion);
34+
this.visitor.set('cd4', `${os.platform()}/${os.release()}`);
35+
this.visitor.set('cn', `calva-${this.extensionVersion}`);
36+
this.visitor.set(
37+
'ua',
38+
`Calva/${this.extensionVersion} (${os.platform()}; ${os.release()}; ${os.type}) VSCode/${
39+
vscode.version
40+
}`
41+
);
42+
}
4743

48-
private userID(): string | undefined {
49-
const KEY = 'userLogID';
50-
if (this.store.get(KEY) == undefined) {
51-
const newID = uuid.uuid();
52-
void this.store.update(KEY, newID);
53-
return newID;
54-
} else {
55-
return this.store.get(KEY);
56-
}
44+
private userID(): string | undefined {
45+
const KEY = 'userLogID';
46+
if (this.store.get(KEY) == undefined) {
47+
const newID = uuid.uuid();
48+
void this.store.update(KEY, newID);
49+
return newID;
50+
} else {
51+
return this.store.get(KEY);
5752
}
53+
}
5854

59-
logPath(path: string): Analytics {
60-
if (userAllowsTelemetry()) {
61-
this.visitor.pageview(path);
62-
}
63-
return this;
55+
logPath(path: string): Analytics {
56+
if (userAllowsTelemetry()) {
57+
this.visitor.pageview(path);
6458
}
59+
return this;
60+
}
6561

66-
logEvent(
67-
category: string,
68-
action: string,
69-
label?: string,
70-
value?: string
71-
): Analytics {
72-
if (userAllowsTelemetry()) {
73-
this.visitor.event({
74-
ec: category,
75-
ea: action,
76-
el: label,
77-
ev: value,
78-
});
79-
}
80-
return this;
62+
logEvent(category: string, action: string, label?: string, value?: string): Analytics {
63+
if (userAllowsTelemetry()) {
64+
this.visitor.event({
65+
ec: category,
66+
ea: action,
67+
el: label,
68+
ev: value,
69+
});
8170
}
71+
return this;
72+
}
8273

83-
send() {
84-
if (userAllowsTelemetry()) {
85-
this.visitor.send();
86-
}
74+
send() {
75+
if (userAllowsTelemetry()) {
76+
this.visitor.send();
8777
}
78+
}
8879
}

src/calva-fmt/src/config.ts

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as filesCache from '../../files-cache';
33
import * as cljsLib from '../../../out/cljs-lib/cljs-lib.js';
44
import * as lsp from '../../lsp/main';
55
const defaultCljfmtContent =
6-
'\
6+
'\
77
{:remove-surrounding-whitespace? true\n\
88
:remove-trailing-whitespace? true\n\
99
:remove-consecutive-blank-lines? false\n\
@@ -13,57 +13,55 @@ const defaultCljfmtContent =
1313
const LSP_CONFIG_KEY = 'CLOJURE-LSP';
1414
let lspFormatConfig: string;
1515

16-
function configuration(
17-
workspaceConfig: vscode.WorkspaceConfiguration,
18-
cljfmt: string
19-
) {
20-
return {
21-
'format-as-you-type': workspaceConfig.get<boolean>('formatAsYouType'),
22-
'keep-comment-forms-trail-paren-on-own-line?':
23-
workspaceConfig.get<boolean>('keepCommentTrailParenOnOwnLine'),
24-
'cljfmt-options-string': cljfmt,
25-
'cljfmt-options': cljsLib.cljfmtOptionsFromString(cljfmt),
26-
};
16+
function configuration(workspaceConfig: vscode.WorkspaceConfiguration, cljfmt: string) {
17+
return {
18+
'format-as-you-type': workspaceConfig.get<boolean>('formatAsYouType'),
19+
'keep-comment-forms-trail-paren-on-own-line?': workspaceConfig.get<boolean>(
20+
'keepCommentTrailParenOnOwnLine'
21+
),
22+
'cljfmt-options-string': cljfmt,
23+
'cljfmt-options': cljsLib.cljfmtOptionsFromString(cljfmt),
24+
};
2725
}
2826

2927
async function readConfiguration(): Promise<{
30-
'format-as-you-type': boolean;
31-
'keep-comment-forms-trail-paren-on-own-line?': boolean;
32-
'cljfmt-options-string': string;
33-
'cljfmt-options': object;
28+
'format-as-you-type': boolean;
29+
'keep-comment-forms-trail-paren-on-own-line?': boolean;
30+
'cljfmt-options-string': string;
31+
'cljfmt-options': object;
3432
}> {
35-
const workspaceConfig = vscode.workspace.getConfiguration('calva.fmt');
36-
const configPath: string = workspaceConfig.get('configPath');
37-
if (configPath === LSP_CONFIG_KEY) {
38-
lspFormatConfig = await lsp.getCljFmtConfig();
39-
}
40-
if (configPath === LSP_CONFIG_KEY && !lspFormatConfig) {
41-
void vscode.window.showErrorMessage(
42-
'Fetching formatting settings from clojure-lsp failed. Check that you are running a version of clojure-lsp that provides "cljfmt-raw" in serverInfo.',
43-
'Roger that'
44-
);
45-
}
46-
const cljfmtContent: string =
47-
configPath === LSP_CONFIG_KEY
48-
? lspFormatConfig
49-
? lspFormatConfig
50-
: defaultCljfmtContent
51-
: filesCache.content(configPath);
52-
const config = configuration(
53-
workspaceConfig,
54-
cljfmtContent ? cljfmtContent : defaultCljfmtContent
33+
const workspaceConfig = vscode.workspace.getConfiguration('calva.fmt');
34+
const configPath: string = workspaceConfig.get('configPath');
35+
if (configPath === LSP_CONFIG_KEY) {
36+
lspFormatConfig = await lsp.getCljFmtConfig();
37+
}
38+
if (configPath === LSP_CONFIG_KEY && !lspFormatConfig) {
39+
void vscode.window.showErrorMessage(
40+
'Fetching formatting settings from clojure-lsp failed. Check that you are running a version of clojure-lsp that provides "cljfmt-raw" in serverInfo.',
41+
'Roger that'
5542
);
56-
if (!config['cljfmt-options']['error']) {
57-
return config;
58-
} else {
59-
void vscode.window.showErrorMessage(
60-
`Error parsing ${configPath}: ${config['cljfmt-options']['error']}\n\nUsing default formatting configuration.`
61-
);
62-
return configuration(workspaceConfig, defaultCljfmtContent);
63-
}
43+
}
44+
const cljfmtContent: string =
45+
configPath === LSP_CONFIG_KEY
46+
? lspFormatConfig
47+
? lspFormatConfig
48+
: defaultCljfmtContent
49+
: filesCache.content(configPath);
50+
const config = configuration(
51+
workspaceConfig,
52+
cljfmtContent ? cljfmtContent : defaultCljfmtContent
53+
);
54+
if (!config['cljfmt-options']['error']) {
55+
return config;
56+
} else {
57+
void vscode.window.showErrorMessage(
58+
`Error parsing ${configPath}: ${config['cljfmt-options']['error']}\n\nUsing default formatting configuration.`
59+
);
60+
return configuration(workspaceConfig, defaultCljfmtContent);
61+
}
6462
}
6563

6664
export async function getConfig() {
67-
const config = await readConfiguration();
68-
return config;
65+
const config = await readConfiguration();
66+
return config;
6967
}

0 commit comments

Comments
 (0)