Skip to content

dprint codebase #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"include": ["src/**", "built/local/**"],
"exclude": ["**/node_modules/**"],
"mergeAsync": true
}
}
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash",
"icon": "terminal-bash",
},
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this undo the trailing-comma eslint rule you enabled elsewhere?

Copy link
Owner Author

@jakebailey jakebailey Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, since this is a JSON file, which aren't linted. If you open this file now in our repo, VS Code actually already complains, we just have nothing that can fix it.

"icon": "terminal-bash"
}
}
},
"extensions": [
"dbaeumer.vscode-eslint"
Expand Down
6 changes: 3 additions & 3 deletions .eslintplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const path = require("path");

const rulesDir = path.join(__dirname, "scripts", "eslint", "rules");
const ext = ".cjs";
const ruleFiles = fs.readdirSync(rulesDir).filter((p) => p.endsWith(ext));
const ruleFiles = fs.readdirSync(rulesDir).filter(p => p.endsWith(ext));

module.exports = {
rules: Object.fromEntries(ruleFiles.map((p) => {
rules: Object.fromEntries(ruleFiles.map(p => {
return [p.slice(0, -ext.length), require(path.join(rulesDir, p))];
})),
}
};
60 changes: 11 additions & 49 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"es6": true
},
"plugins": [
"@typescript-eslint", "no-null", "import", "eslint-plugin-local", "simple-import-sort"
"@typescript-eslint",
"no-null",
"import",
"eslint-plugin-local",
"simple-import-sort"
],
"ignorePatterns": [
"**/node_modules/**",
Expand All @@ -32,9 +36,6 @@
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-array-constructor": "error",

"brace-style": "off",
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],

"@typescript-eslint/naming-convention": [
"error",
{ "selector": "typeLike", "format": ["PascalCase"], "filter": { "regex": "^(__String|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
Expand All @@ -51,55 +52,33 @@
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-assertions": ["error", { "assertionStyle": "as" }],

"max-statements-per-line": ["error", { "max": 1 }],

"no-duplicate-imports": "off",
"@typescript-eslint/no-duplicate-imports": "error",

"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-this-alias": "error",

"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],

"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-as-const": "error",

"quotes": "off",
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],

"semi": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/no-extra-semi": "error",

"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": ["error", {
"asyncArrow": "always",
"anonymous": "always",
"named": "never"
}],

"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",

"@typescript-eslint/no-extra-non-null-assertion": "error",

// scripts/eslint/rules
"local/object-literal-surrounding-space": "error",
"local/no-type-assertion-whitespace": "error",
"local/type-operator-spacing": "error",
// TODO(jakebailey): no-double-space covers formatting of code that dprint handles, but also reads the text in comments.
"local/no-double-space": "error",
"local/only-arrow-functions": ["error", {
"allowNamedFunctions": true ,
"allowNamedFunctions": true,
"allowDeclarations": true
}],
"local/no-double-space": "error",
"local/argument-trivia": "error",
"local/no-in-operator": "error",
"local/simple-indent": "error",
"local/debug-assert": "error",
"local/no-keywords": "error",
"local/jsdoc-format": "error",
Expand All @@ -112,11 +91,9 @@

// eslint
"constructor-super": "error",
"curly": ["error", "multi-line"],
"dot-notation": "error",
"eqeqeq": "error",
"linebreak-style": ["error", "windows"],
"new-parens": "error",
"no-caller": "error",
"no-duplicate-case": "error",
"no-empty": "error",
Expand All @@ -126,18 +103,10 @@
"no-new-func": "error",
"no-new-wrappers": "error",
"no-return-await": "error",
"no-restricted-globals": ["error",
{ "name": "setTimeout" },
{ "name": "clearTimeout" },
{ "name": "setInterval" },
{ "name": "clearInterval" },
{ "name": "setImmediate" },
{ "name": "clearImmediate" }
],
"no-restricted-globals": ["error", { "name": "setTimeout" }, { "name": "clearTimeout" }, { "name": "setInterval" }, { "name": "clearInterval" }, { "name": "setImmediate" }, { "name": "clearImmediate" }],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-unsafe-finally": "error",
"no-unused-labels": "error",
Expand All @@ -146,7 +115,6 @@
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": ["error", "consistent-as-needed"],
"space-in-parens": "error",
"unicode-bom": ["error", "never"],
"use-isnan": "error",
"no-prototype-builtins": "error",
Expand All @@ -156,7 +124,7 @@
"overrides": [
// By default, the ESLint CLI only looks at .js files. But, it will also look at
// any files which are referenced in an override config. Most users of typescript-eslint
// get this behavior by default by extending a recommended typescript-eslint config, which
// get this behavior by default by extending a recommended typescript-eslint config, which
// just so happens to override some core ESLint rules. We don't extend from any config, so
// explicitly reference TS files here so the CLI picks them up.
//
Expand All @@ -169,13 +137,7 @@
"files": ["*.mjs", "*.mts"],
"rules": {
// These globals don't exist outside of CJS files.
"no-restricted-globals": ["error",
{ "name": "__filename" },
{ "name": "__dirname" },
{ "name": "require" },
{ "name": "module" },
{ "name": "exports" }
]
"no-restricted-globals": ["error", { "name": "__filename" }, { "name": "__dirname" }, { "name": "require" }, { "name": "module" }, { "name": "exports" }]
}
},
{
Expand Down
10 changes: 5 additions & 5 deletions .github/workflow-resources/.lsifrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"project": "../../src/tsconfig.json",
"source": "../../package.json",
"package": "../../package.json",
"out": "../../typescript.lsif"
}
"project": "../../src/tsconfig.json",
"source": "../../package.json",
"package": "../../package.json",
"out": "../../typescript.lsif"
}
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"rbuckton.tsserver-live-reload"
"rbuckton.tsserver-live-reload",
"dprint.dprint"
],

"unwantedRecommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
}
98 changes: 49 additions & 49 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*

Copy this file into '.vscode/launch.json' or merge its
contents into your existing configurations.
Expand All @@ -13,52 +13,52 @@
*/

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests (currently opened test)",
"runtimeArgs": ["--nolazy"],
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"bdd",
"--no-timeouts",
"--colors",
"built/local/run.js",
"-f",
// You can change this to be the name of a specific test file (without the file extension)
// to consistently launch the same test
"${fileBasenameNoExtension}",
"--skip-percent",
"0"
],
"env": {
"NODE_ENV": "testing"
},
"outFiles": [
"${workspaceFolder}/built/**/*.js",
"${workspaceFolder}/built/**/*.mjs",
"${workspaceFolder}/built/**/*.cjs",
"!**/node_modules/**"
],
"sourceMaps": true,
"smartStep": true,
"preLaunchTask": "npm: build:tests",
"console": "integratedTerminal",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests (currently opened test)",
"runtimeArgs": ["--nolazy"],
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"bdd",
"--no-timeouts",
"--colors",
"built/local/run.js",
"-f",
// You can change this to be the name of a specific test file (without the file extension)
// to consistently launch the same test
"${fileBasenameNoExtension}",
"--skip-percent",
"0"
],
"env": {
"NODE_ENV": "testing"
},
"outFiles": [
"${workspaceFolder}/built/**/*.js",
"${workspaceFolder}/built/**/*.mjs",
"${workspaceFolder}/built/**/*.cjs",
"!**/node_modules/**"
],
"sourceMaps": true,
"smartStep": true,
"preLaunchTask": "npm: build:tests",
"console": "integratedTerminal",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
// To use the locally built compiler, after 'npm run build':
// "typescript.tsdk": "built/local"

"[typescript][javascript][json][jsonc]": {
// "editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint"
},

// To ignore commits listed in .git-blame-ignore-revs in GitLens:
"gitlens.advanced.blame.customArguments": [
"--ignore-revs-file",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
"problemMatcher": [
"$tsc"
]
},
}
]
}
Loading