Skip to content

Instantly share code, notes, and snippets.

@Luke-zhang-04
Last active April 18, 2025 19:34
Show Gist options
  • Select an option

  • Save Luke-zhang-04/47b0a7267d78e1a9dd1b0a613b3ef692 to your computer and use it in GitHub Desktop.

Select an option

Save Luke-zhang-04/47b0a7267d78e1a9dd1b0a613b3ef692 to your computer and use it in GitHub Desktop.
Clang-format, ESLint, and Prettier config
---
BasedOnStyle: LLVM
Language: Cpp
PointerAlignment: Left
AccessModifierOffset: 4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: true
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
# BitFieldColonSpacing: After
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 99
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
FixNamespaceComments: true
IncludeBlocks: Regroup
IndentCaseBlocks: true
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
# SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
UseCRLF: false
UseTab: Never
...
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{json,html,yml,yaml,css,scss}]
indent_style = space
indent_size = 2
*/node_modules/
/src/serviceWorker.ts
lint
start
lib
function* range(min, max) {
for (let num = min; num < max; num++) {
yield num
}
}
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
],
parser: "@typescript-eslint/parser",
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaVersion: 2021,
sourceType: "module",
project: ["./tsconfig.json"],
},
plugins: ["@typescript-eslint", "prefer-arrow"],
rules: {
// General ESLint rules
"arrow-body-style": ["warn", "as-needed"],
"default-case-last": "warn",
"dot-location": ["warn", "property"],
eqeqeq: "error",
"id-length": ["error", {exceptions: ["_", "$"]}],
"max-len": "off",
"max-lines": ["warn", 500],
"max-statements": ["warn", {max: 25}],
"no-else-return": "warn",
"no-empty": ["warn", {allowEmptyCatch: true}],
"no-extra-semi": "off",
"no-negated-condition": "warn",
"no-nested-ternary": "warn",
"no-unused-vars": "off",
"no-var": "warn",
"object-shorthand": "warn",
"one-var": ["warn", "never"],
"padding-line-between-statements": [
"warn",
{blankLine: "always", prev: "*", next: "return"},
{blankLine: "always", prev: ["const", "let", "var"], next: "*"},
{blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]},
{blankLine: "always", prev: "function", next: "*"},
],
"prefer-const": "warn",
"prefer-destructuring": [
"error",
{
array: false,
object: true,
},
],
"prefer-exponentiation-operator": "warn",
"prefer-object-spread": "warn",
"prefer-template": "warn",
"require-await": "warn",
"require-unicode-regexp": "warn",
"sort-imports": ["warn"],
// Typescript Rules
"@typescript-eslint/array-type": "warn",
"@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
"@typescript-eslint/consistent-type-assertions": ["warn", {assertionStyle: "as"}],
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variableLike",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "property",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "should", "has", "can", "did", "will"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "property",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
{
selector: "enumMember",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
],
"@typescript-eslint/no-magic-numbers": [
"warn",
{
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreArrayIndexes: true,
ignore: [...Array.from(range(-10, 11)), 16, 32, 64, 128, 256, 512],
},
],
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
// Typescript extension rules
"@typescript-eslint/default-param-last": "warn",
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/lines-between-class-members": ["warn", "always"],
"@typescript-eslint/no-dupe-class-members": "warn",
"@typescript-eslint/no-duplicate-imports": "warn",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars-experimental": "warn",
"@typescript-eslint/no-use-before-define": "warn",
// Preter arrow rules
"prefer-arrow-callback": "warn",
"prefer-arrow/prefer-arrow-functions": [
"warn",
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: true,
allowStandaloneDeclarations: false,
},
],
},
}
function* range(min, max) {
for (let num = min; num < max; num++) {
yield num
}
}
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:jsx-a11y/recommended",
],
parser: "@typescript-eslint/parser",
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2021,
sourceType: "module",
project: ["./tsconfig.json"],
},
plugins: ["react", "@typescript-eslint", "prefer-arrow", "jsx-a11y"],
rules: {
// General ESLint rules
"arrow-body-style": ["warn", "as-needed"],
"default-case-last": "warn",
"dot-location": ["warn", "property"],
eqeqeq: "error",
"id-length": ["error", {exceptions: ["_", "$"]}],
"max-len": "off",
"max-lines": ["warn", 500],
"max-statements": ["warn", {max: 25}],
"no-else-return": "warn",
"no-empty": ["warn", {allowEmptyCatch: true}],
"no-extra-semi": "off",
"no-negated-condition": "warn",
"no-nested-ternary": "warn",
"no-unused-vars": "off",
"no-var": "warn",
"object-shorthand": "warn",
"one-var": ["warn", "never"],
"padding-line-between-statements": [
"warn",
{blankLine: "always", prev: "*", next: "return"},
{blankLine: "always", prev: ["const", "let", "var"], next: "*"},
{blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]},
{blankLine: "always", prev: "function", next: "*"},
],
"prefer-const": "warn",
"prefer-destructuring": [
"error",
{
array: false,
object: true,
},
],
"prefer-exponentiation-operator": "warn",
"prefer-object-spread": "warn",
"prefer-template": "warn",
"require-await": "warn",
"require-unicode-regexp": "warn",
"sort-imports": ["warn"],
// Typescript Rules
"@typescript-eslint/array-type": "warn",
"@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
"@typescript-eslint/consistent-type-assertions": ["warn", {assertionStyle: "as"}],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variableLike",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "property",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "should", "has", "can", "did", "will"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "property",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
{
selector: "enumMember",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
],
"@typescript-eslint/no-magic-numbers": [
"warn",
{
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreArrayIndexes: true,
ignore: [...Array.from(range(-10, 11)), 16, 32, 64, 128, 256, 512],
},
],
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
// Typescript extension rules
"@typescript-eslint/default-param-last": "warn",
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/lines-between-class-members": ["warn", "always"],
"@typescript-eslint/no-dupe-class-members": "warn",
"@typescript-eslint/no-duplicate-imports": "warn",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars-experimental": "warn",
"@typescript-eslint/no-use-before-define": "warn",
// Preter arrow rules
"prefer-arrow-callback": "warn",
"prefer-arrow/prefer-arrow-functions": [
"warn",
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: true,
allowStandaloneDeclarations: false,
},
],
// React rules
"react/prop-types": "off",
"react/sort-comp": "error",
"react/react-in-jsx-scope": "off",
},
settings: {react: {version: "detect"}},
}
*/node_modules/
build
.serverless
.vscode
lib/
tsconfig*.json
public/css
public/js
pnpm-lock.yaml
# Normal Options
arrowParens: "always"
bracketSpacing: false
embeddedLanguageFormatting: "auto"
endOfLine: "lf"
htmlWhitespaceSensitivity: "strict"
jsxBracketSameLine: false
jsxSingleQuote: false
printWidth: 99
quoteProps: "as-needed"
semi: false
singleQuote: false
tabWidth: 4
trailingComma: "all"
useTabs: false
# JSDoc plugin
jsdocSpaces: 1
jsdocDescriptionWithDot: false
jsdocDescriptionTag: false
jsdocVerticalAlignment: false
jsdocKeepUnParseAbleExampleIndent: false
jsdocSingleLineComment: false
tsdoc: true
overrides:
- files:
- "*.html"
- "*.yml"
- "*.yaml"
- "*.json"
- "*.css"
- "*.scss"
options:
tabWidth: 2
module.exports = {
extends: "stylelint-config-standard",
ignoreFiles: ["public/**", "build/**", "*.{tsx,ts,js,jsx}"],
rules: {
indentation: null, // Work with prettier
"declaration-colon-newline-after": null,
"at-rule-no-unknown": [
true,
{
ignoreAtRules: [
"function",
"if",
"each",
"include",
"mixin",
"use",
"for",
"debug",
],
},
],
"no-eol-whitespace": [
true,
{
ignore: ["empty-lines"],
},
],
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment