Skip to content

Commit

Permalink
Update prettier settings indent 2, line length 100
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Mar 19, 2022
1 parent 11a4d76 commit 1077cc1
Show file tree
Hide file tree
Showing 96 changed files with 17,272 additions and 20,174 deletions.
126 changes: 63 additions & 63 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
project: './tsconfig.eslint.json',
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
plugins: ['@typescript-eslint', 'import'],
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
},
rules: {
curly: ['error'],
'import/no-unresolved': ['error', { ignore: ['^vscode$'] }], // errors
'no-constant-condition': ['error', { checkLoops: false }],
'prefer-const': ['error'],
'prefer-rest-params': ['error'],
'prefer-spread': ['error'],
'array-callback-return': ['error'],
'no-constructor-return': ['error'],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-floating-promises': ['error'],
sourceType: 'module',
project: './tsconfig.eslint.json',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
plugins: ['@typescript-eslint', 'import'],
env: {
browser: true,
commonjs: true,
es6: true,
node: true,
},
rules: {
curly: ['error'],
'import/no-unresolved': ['error', { ignore: ['^vscode$'] }], // errors
'no-constant-condition': ['error', { checkLoops: false }],
'prefer-const': ['error'],
'prefer-rest-params': ['error'],
'prefer-spread': ['error'],
'array-callback-return': ['error'],
'no-constructor-return': ['error'],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-floating-promises': ['error'],

// 'no-unused-vars': 'off',
// '@typescript-eslint/no-unused-vars': [
// 'error',
// {
// vars: 'all',
// args: 'after-used',
// ignoreRestSiblings: true,
// argsIgnorePattern: '^_',
// },
// ],
// 'no-unused-vars': 'off',
// '@typescript-eslint/no-unused-vars': [
// 'error',
// {
// vars: 'all',
// args: 'after-used',
// ignoreRestSiblings: true,
// argsIgnorePattern: '^_',
// },
// ],

'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
overrides: [
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
],
};
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"printWidth": 80,
"tabWidth": 4,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
Expand Down
121 changes: 56 additions & 65 deletions src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,73 @@ import * as os from 'os';
// debug.log = console.info.bind(console);

function userAllowsTelemetry(): boolean {
const config = vscode.workspace.getConfiguration('telemetry');
return config.get<boolean>('enableTelemetry', false);
const config = vscode.workspace.getConfiguration('telemetry');
return config.get<boolean>('enableTelemetry', false);
}

export default class Analytics {
private visitor: UA.Visitor;
private extension: vscode.Extension<any>;
private extensionVersion: string;
private store: vscode.Memento;
private GA_ID = (process.env.CALVA_DEV_GA
? process.env.CALVA_DEV_GA
: 'FUBAR-69796730-3'
).replace(/^FUBAR/, 'UA');
private visitor: UA.Visitor;
private extension: vscode.Extension<any>;
private extensionVersion: string;
private store: vscode.Memento;
private GA_ID = (process.env.CALVA_DEV_GA
? process.env.CALVA_DEV_GA
: 'FUBAR-69796730-3'
).replace(/^FUBAR/, 'UA');

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

this.visitor = UA(this.GA_ID, this.userID());
this.visitor.set('cd1', this.extensionVersion);
this.visitor.set('cd2', vscode.version);
this.visitor.set('cd3', this.extensionVersion);
this.visitor.set('cd4', `${os.platform()}/${os.release()}`);
this.visitor.set('cn', `calva-${this.extensionVersion}`);
this.visitor.set(
'ua',
`Calva/${
this.extensionVersion
} (${os.platform()}; ${os.release()}; ${os.type}) VSCode/${
vscode.version
}`
);
}
this.visitor = UA(this.GA_ID, this.userID());
this.visitor.set('cd1', this.extensionVersion);
this.visitor.set('cd2', vscode.version);
this.visitor.set('cd3', this.extensionVersion);
this.visitor.set('cd4', `${os.platform()}/${os.release()}`);
this.visitor.set('cn', `calva-${this.extensionVersion}`);
this.visitor.set(
'ua',
`Calva/${this.extensionVersion} (${os.platform()}; ${os.release()}; ${os.type}) VSCode/${
vscode.version
}`
);
}

private userID(): string | undefined {
const KEY = 'userLogID';
if (this.store.get(KEY) == undefined) {
const newID = uuid.uuid();
void this.store.update(KEY, newID);
return newID;
} else {
return this.store.get(KEY);
}
private userID(): string | undefined {
const KEY = 'userLogID';
if (this.store.get(KEY) == undefined) {
const newID = uuid.uuid();
void this.store.update(KEY, newID);
return newID;
} else {
return this.store.get(KEY);
}
}

logPath(path: string): Analytics {
if (userAllowsTelemetry()) {
this.visitor.pageview(path);
}
return this;
logPath(path: string): Analytics {
if (userAllowsTelemetry()) {
this.visitor.pageview(path);
}
return this;
}

logEvent(
category: string,
action: string,
label?: string,
value?: string
): Analytics {
if (userAllowsTelemetry()) {
this.visitor.event({
ec: category,
ea: action,
el: label,
ev: value,
});
}
return this;
logEvent(category: string, action: string, label?: string, value?: string): Analytics {
if (userAllowsTelemetry()) {
this.visitor.event({
ec: category,
ea: action,
el: label,
ev: value,
});
}
return this;
}

send() {
if (userAllowsTelemetry()) {
this.visitor.send();
}
send() {
if (userAllowsTelemetry()) {
this.visitor.send();
}
}
}
90 changes: 44 additions & 46 deletions src/calva-fmt/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as filesCache from '../../files-cache';
import * as cljsLib from '../../../out/cljs-lib/cljs-lib.js';
import * as lsp from '../../lsp/main';
const defaultCljfmtContent =
'\
'\
{:remove-surrounding-whitespace? true\n\
:remove-trailing-whitespace? true\n\
:remove-consecutive-blank-lines? false\n\
Expand All @@ -13,57 +13,55 @@ const defaultCljfmtContent =
const LSP_CONFIG_KEY = 'CLOJURE-LSP';
let lspFormatConfig: string;

function configuration(
workspaceConfig: vscode.WorkspaceConfiguration,
cljfmt: string
) {
return {
'format-as-you-type': workspaceConfig.get<boolean>('formatAsYouType'),
'keep-comment-forms-trail-paren-on-own-line?':
workspaceConfig.get<boolean>('keepCommentTrailParenOnOwnLine'),
'cljfmt-options-string': cljfmt,
'cljfmt-options': cljsLib.cljfmtOptionsFromString(cljfmt),
};
function configuration(workspaceConfig: vscode.WorkspaceConfiguration, cljfmt: string) {
return {
'format-as-you-type': workspaceConfig.get<boolean>('formatAsYouType'),
'keep-comment-forms-trail-paren-on-own-line?': workspaceConfig.get<boolean>(
'keepCommentTrailParenOnOwnLine'
),
'cljfmt-options-string': cljfmt,
'cljfmt-options': cljsLib.cljfmtOptionsFromString(cljfmt),
};
}

async function readConfiguration(): Promise<{
'format-as-you-type': boolean;
'keep-comment-forms-trail-paren-on-own-line?': boolean;
'cljfmt-options-string': string;
'cljfmt-options': object;
'format-as-you-type': boolean;
'keep-comment-forms-trail-paren-on-own-line?': boolean;
'cljfmt-options-string': string;
'cljfmt-options': object;
}> {
const workspaceConfig = vscode.workspace.getConfiguration('calva.fmt');
const configPath: string = workspaceConfig.get('configPath');
if (configPath === LSP_CONFIG_KEY) {
lspFormatConfig = await lsp.getCljFmtConfig();
}
if (configPath === LSP_CONFIG_KEY && !lspFormatConfig) {
void vscode.window.showErrorMessage(
'Fetching formatting settings from clojure-lsp failed. Check that you are running a version of clojure-lsp that provides "cljfmt-raw" in serverInfo.',
'Roger that'
);
}
const cljfmtContent: string =
configPath === LSP_CONFIG_KEY
? lspFormatConfig
? lspFormatConfig
: defaultCljfmtContent
: filesCache.content(configPath);
const config = configuration(
workspaceConfig,
cljfmtContent ? cljfmtContent : defaultCljfmtContent
const workspaceConfig = vscode.workspace.getConfiguration('calva.fmt');
const configPath: string = workspaceConfig.get('configPath');
if (configPath === LSP_CONFIG_KEY) {
lspFormatConfig = await lsp.getCljFmtConfig();
}
if (configPath === LSP_CONFIG_KEY && !lspFormatConfig) {
void vscode.window.showErrorMessage(
'Fetching formatting settings from clojure-lsp failed. Check that you are running a version of clojure-lsp that provides "cljfmt-raw" in serverInfo.',
'Roger that'
);
if (!config['cljfmt-options']['error']) {
return config;
} else {
void vscode.window.showErrorMessage(
`Error parsing ${configPath}: ${config['cljfmt-options']['error']}\n\nUsing default formatting configuration.`
);
return configuration(workspaceConfig, defaultCljfmtContent);
}
}
const cljfmtContent: string =
configPath === LSP_CONFIG_KEY
? lspFormatConfig
? lspFormatConfig
: defaultCljfmtContent
: filesCache.content(configPath);
const config = configuration(
workspaceConfig,
cljfmtContent ? cljfmtContent : defaultCljfmtContent
);
if (!config['cljfmt-options']['error']) {
return config;
} else {
void vscode.window.showErrorMessage(
`Error parsing ${configPath}: ${config['cljfmt-options']['error']}\n\nUsing default formatting configuration.`
);
return configuration(workspaceConfig, defaultCljfmtContent);
}
}

export async function getConfig() {
const config = await readConfiguration();
return config;
const config = await readConfiguration();
return config;
}
Loading

0 comments on commit 1077cc1

Please sign in to comment.