Last active
June 3, 2023 19:28
-
-
Save chill-cod3r/22a29bd6565fb679959c83c5bc40fea5 to your computer and use it in GitHub Desktop.
Revisions
-
John Wolfe revised this gist
Apr 16, 2021 . 1 changed file with 14 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,16 +35,20 @@ const eslintRc = { 'plugin:prettier/recommended', ], rules: { complexity: [ 'warn', 10 ], 'prefer-const': 'error', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', 'padding-line-between-statements': [ 'error', { blankLine: 'always', prev: '*', next: 'if' }, { blankLine: 'always', prev: '*', next: 'block-like' }, { blankLine: 'always', prev: '*', next: 'block' }, { blankLine: 'always', prev: '*', next: 'return' } ] }, }; -
John Wolfe revised this gist
Feb 24, 2021 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -64,10 +64,6 @@ const packages = [ 'prettier', ]; (async () => { const vscodeDirPath = path.join(__dirname, '.vscode'); @@ -111,4 +107,6 @@ const packages = [ .then(({ stdout }) => console.log(stdout)) .catch(console.log), ]); console.log('Finished installing all dependencies and configuring files.\nYou may need to restart vscode for the eslint / prettier settings to take effect.\nI believe you also need the prettier and eslint extensions installed in vscode.'); })(); -
John Wolfe created this gist
Feb 24, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,114 @@ const fs = require('fs'); const cp = require('child_process'); const util = require('util'); const path = require('path'); const exec = util.promisify(cp.exec); const writeFile = util.promisify(fs.writeFile); const prettierConfigVscode = { 'editor.codeActionsOnSave': { 'source.fixAll': true, }, '[json]': { 'editor.defaultFormatter': 'vscode.json-language-features', }, '[javascript]': { 'editor.defaultFormatter': 'esbenp.prettier-vscode', }, '[typescript]': { 'editor.defaultFormatter': 'esbenp.prettier-vscode', }, }; const eslintRc = { parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2020, }, env: { node: true, }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', ], rules: { complexity: ['warn', 10], 'prefer-const': 'error', '@typescript-eslint/no-unused-vars': 'error', 'padding-line-between-statements': [ 'error', { blankLine: 'always', prev: '*', next: 'if' }, { blankLine: 'always', prev: '*', next: 'block-like' }, { blankLine: 'always', prev: '*', next: 'block' }, { blankLine: 'always', prev: '*', next: 'return' }, ], }, }; const prettierRc = { tabWidth: 4, singleQuote: true, printWidth: 80, trailingComma: 'all', }; const packages = [ '@typescript-eslint/eslint-plugin', '@typescript-eslint/parser', 'eslint-config-prettier', 'eslint-plugin-prettier', 'eslint', 'prettier', ]; // write config files // echo message to restart vscode // see if it works (async () => { const vscodeDirPath = path.join(__dirname, '.vscode'); try { fs.statSync(vscodeDirPath).isDirectory(); } catch (error) { fs.mkdirSync(vscodeDirPath); } const workspacePath = path.join( __dirname, '.vscode', 'settings.json', ); let workspaceSettings = {}; try { fs.statSync(workspacePath).isFile(); } catch (error) {} workspaceSettings = { ...workspaceSettings, ...prettierConfigVscode, }; await Promise.all([ writeFile( workspacePath, JSON.stringify(workspaceSettings, null, 2), ).then(() => console.log('writing new .vscode/settings.json')), writeFile( '.eslintrc.json', JSON.stringify(eslintRc, null, 2), ).then(() => console.log('writing new .eslintrc.json')), writeFile( '.prettierrc.json', JSON.stringify(prettierRc, null, 2), ).then(() => console.log('writing new .prettierrc.json')), exec(`npm i -D ${packages.join(' ')}`) .then(({ stdout }) => console.log(stdout)) .catch(console.log), ]); })();