Skip to content

Commit cd713d1

Browse files
committed
feat: add enviroment work
1. add pre commit format work 2. add pre commit lint work 3. add lint and formatter tool prepare work
1 parent dee311e commit cd713d1

File tree

5 files changed

+124
-4
lines changed

5 files changed

+124
-4
lines changed

.clang-tidy

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
Checks: '-*,
3+
modernize-deprecated-headers,
4+
modernize-make-unique,
5+
modernize-make-shared,
6+
modernize-raw-string-literal,
7+
modernize-redundant-void-arg,
8+
modernize-replace-random-shuffle,
9+
modernize-shrink-to-fit,
10+
modernize-use-default-member-init,
11+
modernize-use-bool-literals,
12+
modernize-use-emplace,
13+
modernize-use-equals-default,
14+
modernize-use-nullptr,
15+
modernize-use-override,
16+
modernize-use-starts-ends-with,
17+
performance-faster-string-find,
18+
performance-implicit-conversion-in-loop,
19+
readability-delete-null-pointer,
20+
clang-diagnostic-*,
21+
clang-analyzer-*'
22+
WarningsAsErrors: ''
23+
HeaderFileExtensions:
24+
- ''
25+
- h
26+
- hh
27+
- hpp
28+
- hxx
29+
ImplementationFileExtensions:
30+
- c
31+
- cc
32+
- cpp
33+
- cxx
34+
HeaderFilterRegex: ''
35+
FormatStyle: google
36+
User: JsAudio-Android
37+
CheckOptions:
38+
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
39+
cert-err33-c.AllowCastToVoid: 'true'
40+
cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;'
41+
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
42+
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
43+
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
44+
google-readability-braces-around-statements.ShortStatementLines: '1'
45+
google-readability-function-size.StatementThreshold: '800'
46+
google-readability-namespace-comments.ShortNamespaceLines: '10'
47+
google-readability-namespace-comments.SpacesBeforeComments: '2'
48+
llvm-else-after-return.WarnOnConditionVariables: 'false'
49+
llvm-else-after-return.WarnOnUnfixable: 'false'
50+
llvm-qualified-auto.AddConstToQualified: 'false'
51+
SystemHeaders: false
52+
...
53+

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

lint-staged.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const micromatch = require("micromatch");
2+
3+
third_party_dir = ["node"];
4+
5+
module.exports = {
6+
"**/CMakeLists.txt": (file_path) => {
7+
const match = micromatch.not(file_path, third_party_dir);
8+
return [
9+
`cmake-format -c "./.vscode/cmake_format_config.json" -i ${match.join(" ")}`,
10+
"git add",
11+
];
12+
},
13+
"*.{cpp, c, hpp, h, cc}": (file_path) => {
14+
const match = micromatch.not(file_path, third_party_dir);
15+
return [
16+
`clang-format -i ${match.join(" ")}`,
17+
`clang-tidy -p ./.vscode ${match.join(" ")}`,
18+
"git add",
19+
];
20+
},
21+
"*.js": ["prettier --write"],
22+
"*.py": ["prettier --write"],
23+
};

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
"compress": "node js_task/compress.js",
88
"combine": "node js_task/combine_compile_commands.js",
99
"valid": "ROOT_DIR=$(pwd) node ./js_task/valid_task/valid.js",
10-
"start": "npm run compress && http-server -p 20490"
10+
"start": "npm run compress && http-server -p 20490",
11+
"prepare": "readymate && husky && echo 'npx lint-staged' > .husky/pre-commit"
1112
},
12-
"author": "",
13+
"author": "Intro1997",
1314
"license": "ISC",
1415
"dependencies": {
15-
"http-server": "~14.1.1",
16-
"uglify-js": "^3.18.0"
16+
"http-server": "^14.1.1",
17+
"uglify-js": "^3.18.0",
18+
"husky": "^9.1.7",
19+
"lint-staged": "^15.2.10",
20+
"prettier": "^3.4.1",
21+
"readymate": "^1.0.2"
1722
}
1823
}

ready_mate_config.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"clang-tidy": {
3+
"macos": {
4+
"support": true,
5+
"installer": "brew",
6+
"cmd": "install llvm"
7+
},
8+
"windows": {
9+
"support": true,
10+
"installer": "choco",
11+
"cmd": "install"
12+
},
13+
"linux": {
14+
"support": true,
15+
"root": true,
16+
"installer": "apt-get",
17+
"cmd": "install clang-tidy"
18+
}
19+
},
20+
"clang-format": {
21+
"macos": {
22+
"support": true,
23+
"installer": "brew",
24+
"cmd": "install llvm"
25+
},
26+
"windows": {
27+
"support": true,
28+
"installer": "choco",
29+
"cmd": "install clang-format"
30+
},
31+
"linux": {
32+
"support": true,
33+
"root": true,
34+
"installer": "apt-get",
35+
"cmd": "install clang-format"
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)