├── .npmrc ├── README.md ├── .eslintignore ├── mocha.eslintrc.yaml ├── .travis.yml ├── .gitignore ├── .editorconfig ├── es5.eslintrc.yaml ├── package.json ├── compress-tsconfig.js ├── tsconfig-base.json ├── compress-editorconfig.js ├── .bash_profile ├── .eslintrc.yaml ├── .zshrc ├── src ├── .editorconfig └── tsconfig-base.json ├── check-tsconfig.js └── tsconfig.json /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hax's dotfiles 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | coverage 4 | example 5 | examples 6 | sandbox 7 | -------------------------------------------------------------------------------- /mocha.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | mocha: true 4 | globals: 5 | assert: false 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "12" 4 | - "10" 5 | - "8" 6 | - "6" 7 | - "4" 8 | cache: 9 | directories: 10 | - node_modules 11 | after_success: 12 | - npm run coveralls 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # node.js 2 | node_modules/ 3 | npm-debug.log 4 | 5 | # bower 6 | bower_components/ 7 | 8 | # IDE 9 | .idea/ 10 | 11 | 12 | # Mac 13 | .DS_Store 14 | 15 | # Windows 16 | Thumbs.db 17 | Desktop.ini 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # See https://github.com/hax/dotfiles/tree/master/src/.editorconfig for commented edition 2 | root = true 3 | [*] 4 | charset = utf-8 5 | indent_style = tab 6 | indent_size = 3 7 | end_of_line = lf 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | trim_trailing_newlines = true 11 | max_line_length = 80 12 | [*.{yaml,yml}] 13 | indent_style = space 14 | indent_size = 2 15 | [*.{markdown,md}] 16 | indent_size = 4 -------------------------------------------------------------------------------- /es5.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | rules: 4 | 5 | # Best Practices 6 | 7 | semi: [2, never] 8 | 9 | curly: [2, multi-line] 10 | comma-dangle: [2, always-multiline] 11 | no-use-before-define: [2, nofunc] 12 | 13 | 14 | # Strict Mode 15 | 16 | strict: [2, global] 17 | global-strict: 0 18 | 19 | 20 | # Consistence 21 | 22 | quotes: [2, single, avoid-escape] 23 | new-cap: [2, capIsNew: false] 24 | 25 | no-underscore-dangle: 0 26 | new-parens: 0 27 | 28 | 29 | # Extra 30 | 31 | no-labels: 1 32 | no-proto: 1 33 | no-constant-condition: 1 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "dotfiles", 4 | "version": "1.2.0", 5 | "description": "Hax's dotfiles", 6 | "scripts": { 7 | "prepare": "./build.sh" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/hax/dotfiles.git" 12 | }, 13 | "author": "HE Shi-Jun ", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/hax/dotfiles/issues" 17 | }, 18 | "homepage": "https://github.com/hax/dotfiles#readme", 19 | "devDependencies": { 20 | "eslint": "^7.1.0", 21 | "js-yaml": "^3.14.0", 22 | "node-fetch": "^2.6.0", 23 | "typescript": "^5.2.2" 24 | }, 25 | "dependencies": {} 26 | } 27 | -------------------------------------------------------------------------------- /compress-tsconfig.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const {readFileSync, writeFileSync} = require('fs') 4 | const {resolve} = require('path') 5 | 6 | const srcPath = resolve(__dirname, './src/tsconfig-base.json') 7 | const outPath = resolve(__dirname, './tsconfig-base.json') 8 | 9 | const banner = '// See https://github.com/hax/dotfiles/tree/master/src/tsconfig-base.json for full edition\n' 10 | const src = readFileSync(srcPath, 'utf-8') 11 | const content = JSON.parse(removeComments(src)) 12 | const out = banner + JSON.stringify(content, null, '\t') + '\n' 13 | // console.log(out) 14 | writeFileSync(outPath, out, 'utf-8') 15 | 16 | function removeComments(src) { 17 | return src.replaceAll(/\/\/.*|\/\*[\s\S]*?\*\//g, "") 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig-base.json: -------------------------------------------------------------------------------- 1 | // See https://github.com/hax/dotfiles/tree/master/src/tsconfig-base.json for full edition 2 | { 3 | "compilerOptions": { 4 | "composite": true, 5 | "target": "ESNext", 6 | "lib": [ 7 | "ESNext" 8 | ], 9 | "module": "ES2020", 10 | "moduleResolution": "Bundler", 11 | "allowArbitraryExtensions": true, 12 | "declarationMap": true, 13 | "sourceMap": true, 14 | "downlevelIteration": true, 15 | "isolatedModules": true, 16 | "verbatimModuleSyntax": true, 17 | "allowSyntheticDefaultImports": false, 18 | "esModuleInterop": false, 19 | "forceConsistentCasingInFileNames": true, 20 | "strict": true, 21 | "noImplicitReturns": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "noImplicitOverride": true, 24 | "noPropertyAccessFromIndexSignature": true, 25 | "skipLibCheck": true 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /compress-editorconfig.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const {readFileSync, writeFileSync} = require('fs') 4 | const {resolve} = require('path') 5 | 6 | const srcPath = resolve(__dirname, './src/.editorconfig') 7 | const outPath = resolve(__dirname, './.editorconfig') 8 | 9 | const banner = '# See https://github.com/hax/dotfiles/tree/master/src/.editorconfig for commented edition\n' 10 | const src = readFileSync(srcPath, 'utf-8') 11 | const out = banner + compress(src) 12 | // console.log(out) 13 | writeFileSync(outPath, out, 'utf-8') 14 | 15 | function compress(content) { 16 | return content 17 | .split(/\n/) 18 | .map(l => l.trim()) 19 | .filter(l => l.length > 0 && !isComment(l)) 20 | .reduce(({lines, head}, l) => { 21 | if (isHead(l)) return {lines, head: l} 22 | if (head) lines.push(head) 23 | lines.push(l) 24 | return {lines} 25 | }, {lines: []}) 26 | .lines.join('\n') 27 | } 28 | 29 | function isComment(line) { 30 | const c = line[0] 31 | return c === '#' || c === ';' 32 | } 33 | function isHead(line) { 34 | const c0 = line[0] 35 | const c1 = line[line.length - 1] 36 | return c0 === '[' && c1 === ']' 37 | } 38 | -------------------------------------------------------------------------------- /.bash_profile: -------------------------------------------------------------------------------- 1 | export TNVM_DIR="/Users/hax/.tnvm" 2 | [ -s "$TNVM_DIR/tnvm.sh" ] && . "$TNVM_DIR/tnvm.sh" # This loads nvm 3 | 4 | export PATH=~/.composer/vendor/bin:$PATH 5 | 6 | if [ -f /usr/local/share/liquidprompt ]; then 7 | . /usr/local/share/liquidprompt 8 | fi 9 | 10 | alias l='ls -aFhlG' 11 | alias ll='ls -FhlG' 12 | 13 | alias ..='cd ..' 14 | alias ...='cd ../..' 15 | alias ....='cd ../../..' 16 | alias .....='cd ../../../..' 17 | 18 | alias npmls='npm ls --depth=0' 19 | alias npml='npm ls --depth=0 -g' 20 | #alias cnpm="npm --registry=https://registry.npm.taobao.org \ 21 | #--cache=$HOME/.npm/.cache/cnpm \ 22 | #--disturl=https://npm.taobao.org/dist \ 23 | #--userconfig=$HOME/.cnpmrc" 24 | 25 | alias bfg='java -jar /usr/local/bin/bfg-1.12.12.jar' 26 | 27 | alias gulb='gulp --require babel/register' 28 | 29 | alias dl='cd ~/Downloads' 30 | alias dt='cd ~/Desktop' 31 | 32 | alias dn='node --harmony --expose-gc --trace_opt --trace_deopt --allow-natives-syntax' 33 | alias chd='"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" --allow-file-access-from-files --js-flags="--allow-natives-syntax"' 34 | alias chc='"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" --js-flags="--allow-natives-syntax --expose-gc --trace_opt --trace_deopt"' 35 | 36 | alias hss='http-server -c-1 --cors -S -C ~/localhost-ecc.pem -K ~/localhost-ecc.pem' 37 | 38 | #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! 39 | export SDKMAN_DIR="/Users/hax/.sdkman" 40 | [[ -s "/Users/hax/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/hax/.sdkman/bin/sdkman-init.sh" 41 | -------------------------------------------------------------------------------- /.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | extends: eslint:recommended 3 | 4 | env: 5 | es2020: true 6 | 7 | parserOptions: 8 | # ecmaVersion: 2020 9 | sourceType: module 10 | 11 | # parser: babel-eslint 12 | 13 | 14 | rules: 15 | 16 | # Best Practices 17 | 18 | semi: [2, never] 19 | 20 | curly: [2, multi-line] 21 | comma-dangle: [2, always-multiline] 22 | no-use-before-define: [2, nofunc] 23 | 24 | no-loop-func: 1 # should allow arrow function 25 | 26 | accessor-pairs: 2 27 | complexity: [2, 32] 28 | consistent-return: 2 29 | default-case: 2 30 | dot-notation: 2 31 | eqeqeq: 2 32 | no-else-return: 2 33 | no-eval: 2 34 | no-empty-label: 2 35 | no-floating-decimal: 2 36 | 37 | 38 | # Strict Mode 39 | 40 | strict: [2, global] 41 | global-strict: 0 42 | 43 | 44 | # Consistence 45 | 46 | quotes: [2, single, avoid-escape] 47 | new-cap: [2, capIsNew: false] 48 | 49 | no-underscore-dangle: 0 50 | new-parens: 0 51 | 52 | 53 | # ES6+ 54 | 55 | no-var: 2 56 | prefer-const: 2 57 | no-const-assign: 2 58 | no-class-assign: 2 59 | 60 | constructor-super: 2 61 | no-this-before-super: 2 62 | no-dupe-class-members: 2 63 | 64 | prefer-arrow-callback: 2 65 | prefer-spread: 2 66 | prefer-reflect: 2 67 | prefer-template: 2 68 | object-shorthand: 1 # buggy 69 | require-yield: 1 70 | 71 | arrow-parens: [2, as-needed] 72 | arrow-spacing: 2 73 | generator-star-spacing: 1 # buggy for babel async 74 | 75 | 76 | # Extra 77 | 78 | no-proto: 1 79 | no-constant-condition: 1 80 | 81 | no-multiple-empty-lines: 2 82 | indent: [2, tab] 83 | -------------------------------------------------------------------------------- /.zshrc: -------------------------------------------------------------------------------- 1 | # If you come from bash you might have to change your $PATH. 2 | # export PATH=$HOME/bin:/usr/local/bin:$PATH 3 | 4 | # Path to your oh-my-zsh installation. 5 | export ZSH=/Users/hax/.oh-my-zsh 6 | 7 | # Set name of the theme to load. Optionally, if you set this to "random" 8 | # it'll load a random theme each time that oh-my-zsh is loaded. 9 | # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes 10 | ZSH_THEME="robbyrussell" 11 | 12 | # Uncomment the following line to use case-sensitive completion. 13 | # CASE_SENSITIVE="true" 14 | 15 | # Uncomment the following line to use hyphen-insensitive completion. Case 16 | # sensitive completion must be off. _ and - will be interchangeable. 17 | # HYPHEN_INSENSITIVE="true" 18 | 19 | # Uncomment the following line to disable bi-weekly auto-update checks. 20 | # DISABLE_AUTO_UPDATE="true" 21 | 22 | # Uncomment the following line to change how often to auto-update (in days). 23 | # export UPDATE_ZSH_DAYS=13 24 | 25 | # Uncomment the following line to disable colors in ls. 26 | # DISABLE_LS_COLORS="true" 27 | 28 | # Uncomment the following line to disable auto-setting terminal title. 29 | # DISABLE_AUTO_TITLE="true" 30 | 31 | # Uncomment the following line to enable command auto-correction. 32 | # ENABLE_CORRECTION="true" 33 | 34 | # Uncomment the following line to display red dots whilst waiting for completion. 35 | # COMPLETION_WAITING_DOTS="true" 36 | 37 | # Uncomment the following line if you want to disable marking untracked files 38 | # under VCS as dirty. This makes repository status check for large repositories 39 | # much, much faster. 40 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 41 | 42 | # Uncomment the following line if you want to change the command execution time 43 | # stamp shown in the history command output. 44 | # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 45 | # HIST_STAMPS="mm/dd/yyyy" 46 | 47 | # Would you like to use another custom folder than $ZSH/custom? 48 | # ZSH_CUSTOM=/path/to/new-custom-folder 49 | 50 | # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) 51 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 52 | # Example format: plugins=(rails git textmate ruby lighthouse) 53 | # Add wisely, as too many plugins slow down shell startup. 54 | plugins=(git osx brew colored-man-pages npm node) 55 | 56 | source $ZSH/oh-my-zsh.sh 57 | 58 | # User configuration 59 | 60 | # export MANPATH="/usr/local/man:$MANPATH" 61 | 62 | # You may need to manually set your language environment 63 | # export LANG=en_US.UTF-8 64 | 65 | # Preferred editor for local and remote sessions 66 | # if [[ -n $SSH_CONNECTION ]]; then 67 | # export EDITOR='vim' 68 | # else 69 | # export EDITOR='mvim' 70 | # fi 71 | 72 | # Compilation flags 73 | # export ARCHFLAGS="-arch x86_64" 74 | 75 | # ssh 76 | # export SSH_KEY_PATH="~/.ssh/rsa_id" 77 | 78 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 79 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 80 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 81 | # For a full list of active aliases, run `alias`. 82 | # 83 | # Example aliases 84 | # alias zshconfig="mate ~/.zshrc" 85 | # alias ohmyzsh="mate ~/.oh-my-zsh" 86 | 87 | # export TNVM_DIR="/Users/hax/.tnvm" 88 | # [ -s "$TNVM_DIR/tnvm.sh" ] && . "$TNVM_DIR/tnvm.sh" 89 | 90 | export PATH=~/.composer/vendor/bin:$PATH 91 | 92 | export PATH=~/.npm-global/bin:$PATH 93 | 94 | alias nodem="node --experimental-modules --harmony" 95 | alias npml="npm ls -g --depth=0" 96 | alias npmL="npm ls --depth=0" 97 | alias hss='http-server -c-1 --cors -S -C ~/localhost-self-signed-cert.pem -K ~/localhost-self-signed-cert.pem' 98 | alias chd='"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" --allow-file-access-from-files --js-flags="--allow-natives-syntax --harmony-top-level-await --harmony-explicit-tailcalls"' 99 | 100 | alias hp="https_proxy=http://127.0.0.1:1087" 101 | 102 | alias du='du -ch' 103 | 104 | eval "$(rbenv init -)" 105 | 106 | source "/Users/hax/.jabba/jabba.sh" 107 | 108 | #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! 109 | export SDKMAN_DIR="/Users/hax/.sdkman" 110 | [[ -s "/Users/hax/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/hax/.sdkman/bin/sdkman-init.sh" 111 | -------------------------------------------------------------------------------- /src/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | 7 | [*] 8 | # Stick to UTF-8 9 | charset = utf-8 10 | 11 | # Finally TABs win the war! 12 | indent_style = tab 13 | 14 | # Ideally we should not specify indent_size/tab_width here, because TAB is not 15 | # SPACE, but saddly GitHub use tab-size 8 as default which make reading code 16 | # hard, so let's use 3 as default 17 | indent_size = 3 18 | 19 | # Unix-style newlines with a newline ending every file 20 | end_of_line = lf 21 | 22 | # Trim trailing whitespaces 23 | trim_trailing_whitespace = true 24 | 25 | # Always end with newline 26 | insert_final_newline = true 27 | 28 | # See https://github.com/editorconfig/editorconfig/issues/269 29 | trim_trailing_newlines = true 30 | 31 | # See https://github.com/editorconfig/editorconfig/issues/280 32 | max_line_length = 80 33 | 34 | 35 | [package.json] 36 | # The output of old npm cli always surrender to evil SPACEs, 37 | # but npm 5 come to rescue. 38 | ;indent_style = space 39 | ;indent_size = 2 40 | # Anyway, JSON is too evil that even SPACEs can not add more! 41 | 42 | 43 | [*.{yaml,yml}] 44 | # YAML is far better than JSON, but they choose the dark side... 45 | indent_style = space 46 | indent_size = 2 47 | 48 | 49 | [*.{markdown,md}] 50 | # Trailing whitespaces is part of the syntax of old-style Markdown, Jesus! 51 | # But GFM is not follow that syntax. And some editors such as Atom always trim 52 | # trailing whitespaces as default settings. 53 | # CommonMark spec introduce backslash `\` for hard line breaks, and it should 54 | # be used instead of illegible trailing spaces. You could also use `
` for 55 | # old-style Markdown. 56 | ; trim_trailing_whitespace = true 57 | 58 | # Markdown treat 4 spaces like 1 tab 59 | indent_size = 4 60 | 61 | # But we still prefer TABs :) 62 | ; indent_style = tab 63 | 64 | 65 | [*.{php,phpt,phtml,hh,hphp,php3,php4,php5,php7,inc,shtml,wtfext_for_php}] 66 | # There are some misunderstandings that insert_final_newline can cause unwanted 67 | # output effects in PHP scripts therefore should be disabled. 68 | # 69 | # The fact is: 70 | # 1. insert_final_newline is a Unix convention, and most Unix tools such as Vim 71 | # always do that 72 | # 2. If you follow good coding style, you can rarely go wrong 73 | # 3. In case insert_final_newline introduce extra newlines in buffer output, 74 | # they are usually harmless 75 | # 76 | # Here details: 77 | # 78 | # If a file is pure PHP code, PHP closing tag `?>` can be omitted at the end 79 | # of the file so that insert_final_newline will never make any difference. 80 | # That's the style PHP official documentation recommend. 81 | # 82 | # Even a file ends with closing tag, PHP ignores one newline immediately after 83 | # the closing tag, which means append a newline will also make no difference. 84 | # And note that insert_final_newline will not add extra newline if the file 85 | # already end with newline. 86 | # 87 | # But if a file ends with normal content (everything outside of a pair of 88 | # opening and closing tags), and included/required by other PHP files, 89 | # insert_final_newline may introduce a extra newline. In typical cases, we 90 | # include some html fragments, and normally there are html end tags as 91 | # boundary, so extra whitespaces are not significant for final effect. 92 | # In case of whitespaces are significant, you should not rely on unsound 93 | # include/require, but use the precise output methods like `echo`. 94 | # 95 | # The worst case is trailing whitespaces being treat as normal content, aka 96 | # spaces or multiple newlines after the PHP closing tag. It's very easy to be 97 | # neglected and if cause problem it's very hard to discover. That's a design 98 | # flaw of PHP from its first day, though far from serious to PHP standards :) 99 | # 100 | # As I noted earlier, insert_final_newline has no relation with this case, 101 | # but use trim_trailing_whitespace could prevent the former (trailing space). 102 | # Some editors (eg. Atom) support a stricter form of insert_final_newline, 103 | # ensure the file end with ONEE (one and only one) newline, such feature can 104 | # prevent latter (multiple newlines)... Yes, EditorConfig is awesome, but not 105 | # awesome enough to save PHP :P -- But there is a proposal, 106 | # see https://github.com/editorconfig/editorconfig/issues/269 107 | # 108 | ; insert_final_newline = single 109 | ; trim_trailing_whitespace = true 110 | 111 | 112 | # THE END 113 | -------------------------------------------------------------------------------- /check-tsconfig.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const {readFile} = require('fs').promises 4 | const fetch = require('node-fetch') 5 | 6 | class RegExpMatcher { 7 | constructor(pattern) { 8 | this.re = pattern 9 | } 10 | match(s) { 11 | const m = this.re.exec(s) 12 | if (!m) return null 13 | if (this.re.global || this.re.sticky) this.re.lastIndex = 0 14 | return m 15 | } 16 | *matchAll(s) { 17 | if (this.re.global || this.re.sticky) { 18 | for (;;) { 19 | const {lastIndex} = this.re 20 | const m = this.re.exec(s) 21 | if (!m) return 22 | yield m 23 | if (this.re.lastIndex === lastIndex) ++this.re.lastIndex 24 | } 25 | } else { 26 | let lastIndex = 0 27 | for (;;) { 28 | const m = this.re.exec(s.slice(lastIndex)) 29 | if (!m) return 30 | const offset = m.index + m[0].length 31 | m.index += lastIndex 32 | yield m 33 | lastIndex += offset || 1 34 | } 35 | } 36 | } 37 | } 38 | 39 | class NaiveElementMatcher extends RegExpMatcher { 40 | constructor(tagName) { 41 | super(new RegExp(`<(${tagName})(\s.*?)?>(.*?)`, 'sg')) 42 | } 43 | match(html) { 44 | const m = super.match(html) 45 | return m ? createElement(m) : m 46 | } 47 | *matchAll(html) { 48 | for (const m of super.matchAll(html)) { 49 | yield createElement(m) 50 | } 51 | } 52 | } 53 | function createElement(m) { 54 | return { 55 | tagName: m[1], 56 | attributes: m[2], 57 | innerHTML: m[3], 58 | } 59 | } 60 | 61 | async function compilerOptions() { 62 | const options = [] 63 | 64 | const tr = new NaiveElementMatcher('tr') 65 | const td = new NaiveElementMatcher('td') 66 | const code = new NaiveElementMatcher('code') 67 | const em = new NaiveElementMatcher('em') 68 | 69 | const doc = await fetch('https://www.typescriptlang.org/docs/handbook/compiler-options.html') 70 | for (const row of tr.matchAll(await doc.text())) { 71 | const cells = [...td.matchAll(row.innerHTML)] 72 | if (!cells.length) continue 73 | const _option = code.match(cells[0].innerHTML) 74 | if (!_option) throw new Error() 75 | const option = _option.innerHTML.replace(/^--/, '') 76 | const _type = code.match(cells[1].innerHTML) 77 | const cli = !_type 78 | const type = _type && _type.innerHTML 79 | const _defaultValue = code.match(cells[2].innerHTML) 80 | const defaultValue = _defaultValue && _defaultValue.innerHTML 81 | const description = cells[3].innerHTML 82 | const deprecated = description.includes('DEPRECATED') 83 | options.push({ 84 | option, 85 | type, 86 | defaultValue, 87 | description, 88 | deprecated, 89 | cli, 90 | }) 91 | } 92 | const docb = await fetch('https://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html') 93 | for (const row of tr.matchAll(await docb.text())) { 94 | const cells = [...td.matchAll(row.innerHTML)] 95 | if (!cells.length) continue 96 | const _option = code.match(cells[0].innerHTML) 97 | if (!_option) continue 98 | const option = _option && _option.innerHTML.replace(/^--/, '') 99 | const _notSupported = em.match(cells[1].innerHTML) 100 | const notSupported = _notSupported && _notSupported.innerHTML === 'Not supported in MSBuild' 101 | const type = cells[2].innerHTML 102 | 103 | if (notSupported && type.trim() !== '') console.warn(`${option} ${notSupported.innerHTML} "${type}"`) 104 | 105 | const exist = options.find(({option: o}) => option === o) 106 | if (!exist) { 107 | options.push({option, type, msbuild: true}) 108 | continue 109 | } 110 | 111 | if (notSupported) continue 112 | if (exist.type === 'string' || exist.type === 'string[]') continue 113 | if (exist.type !== type) console.warn(`${option} type mismatch: ${exist.type} / ${type} (msbuild)`) 114 | } 115 | 116 | return options 117 | } 118 | 119 | async function initOptions() { 120 | const text = await readFile(`${__dirname}/tsconfig.json`, 'utf8') 121 | const keys = text.match(/"(.+?)":/g) 122 | return keys.map(k => k.slice(1, -2)) 123 | } 124 | 125 | async function baseOptions() { 126 | const text = await readFile(`${__dirname}/src/tsconfig.yaml`, 'utf8') 127 | const keys = text.match(/(\S+?):/g) 128 | return keys.map(k => k.slice(0, -1)) 129 | } 130 | 131 | void async function main() { 132 | 133 | const doc = (await compilerOptions()).filter(o => !o.deprecated && !o.cli) 134 | const base = await baseOptions() 135 | const init = await initOptions() 136 | 137 | const missingOptions = doc.filter(o => !base.includes(o.option)) 138 | const extraOptions = base.filter(o => !doc.find(x => x.option === o)) 139 | console.log('missing:', missingOptions) 140 | console.log('extra', extraOptions) 141 | 142 | }() 143 | -------------------------------------------------------------------------------- /src/tsconfig-base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | "lib": ["ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "ES2020", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | "moduleResolution": "Bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | "allowSyntheticDefaultImports": false, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": false, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | --------------------------------------------------------------------------------