Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] web: prettier and eslint tooling
Provide an opt in js tooling system by adding a node env with prettier and eslint configured. 3 bash scripts are provided: enable.sh, disable.sh and reload.sh. Enable.sh: add to the community root (and optionaly to the enterprise root) the env. Disable.sh: remove the env. Reload.sh: disable then enable.
- Loading branch information
1 parent
84a4859
commit 8d57a5c
Showing
18 changed files
with
1,048 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Ignore everything | ||
* | ||
|
||
# Whitelist web | ||
!addons | ||
addons/* | ||
!addons/web | ||
!addons/web/**/* | ||
|
||
# Whitelist web_enterprise | ||
!web_enterprise | ||
!web_enterprise/**/* | ||
|
||
# Whitelist web_studio | ||
!web_studio | ||
!web_studio/**/* | ||
|
||
# BlackList libs | ||
addons/web/static/lib | ||
|
||
# Ignore everything in web legacy but the top level (adapters) | ||
addons/web/static/src/legacy/**/* | ||
!addons/web/static/src/legacy | ||
!addons/web/static/src/legacy/*.js | ||
|
||
# Ignore everything in web_enterprise legacy but the top level (adapters) | ||
web_enterprise/static/src/legacy/**/* | ||
!web_enterprise/static/src/legacy | ||
!web_enterprise/static/src/legacy/*.js | ||
|
||
# Ignore everything in web_studio legacy but the top level (adapters) | ||
web_studio/static/src/legacy/**/* | ||
!web_studio/static/src/legacy | ||
!web_studio/static/src/legacy/*.js | ||
|
||
# Ignore all legacy related tests | ||
addons/web/static/tests/**/legacy/* | ||
web_enterprise/static/tests/**/legacy/* | ||
web_studio/static/tests/**/legacy/* |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": ["eslint:recommended", "plugin:prettier/recommended"], | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2019 | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es2017": true, | ||
"qunit": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"no-undef": "error" | ||
}, | ||
"globals": { | ||
"odoo": "writable", | ||
"owl": "readonly", | ||
"luxon": "readonly" | ||
} | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run format-staged |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "odoo-js-config", | ||
"version": "0.0.1", | ||
"description": "JS Config for better DX in javascript", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"format-web": "prettier-eslint --write 'addons/web/static/src/**/*.js' 'addons/web/static/tests/**/*.js' 'addons/web/doc/**/*.md'", | ||
"format-staged": "lint-staged", | ||
"lint-web": "prettier-eslint --list-different 'addons/web/static/src/**/*.js' 'addons/web/static/tests/**/*.js' 'addons/web/doc/**/*.md'", | ||
"format-all": "prettier-eslint --write '**/*.js' '**/*.md'" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.25.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"husky": "^6.0.0", | ||
"lint-staged": "^10.5.4", | ||
"prettier": "2.2.1", | ||
"prettier-eslint-cli": "^5.0.1" | ||
}, | ||
"lint-staged": { | ||
"*.{js,md}": [ | ||
"prettier-eslint --write" | ||
] | ||
} | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Ignore everything | ||
* | ||
|
||
# Whitelist web | ||
!addons | ||
addons/* | ||
!addons/web | ||
!addons/web/**/* | ||
|
||
# Whitelist web_enterprise | ||
!web_enterprise | ||
!web_enterprise/**/* | ||
|
||
# Whitelist web_studio | ||
!web_studio | ||
!web_studio/**/* | ||
|
||
# BlackList libs | ||
addons/web/static/lib | ||
|
||
# Ignore everything in web legacy but the top level (adapters) | ||
addons/web/static/src/legacy/**/* | ||
!addons/web/static/src/legacy | ||
!addons/web/static/src/legacy/*.js | ||
|
||
# Ignore everything in web_enterprise legacy but the top level (adapters) | ||
web_enterprise/static/src/legacy/**/* | ||
!web_enterprise/static/src/legacy | ||
!web_enterprise/static/src/legacy/*.js | ||
|
||
# Ignore everything in web_studio legacy but the top level (adapters) | ||
web_studio/static/src/legacy/**/* | ||
!web_studio/static/src/legacy | ||
!web_studio/static/src/legacy/*.js | ||
|
||
# Ignore all legacy related tests | ||
addons/web/static/tests/**/legacy/* | ||
web_enterprise/static/tests/**/legacy/* | ||
web_studio/static/tests/**/legacy/* |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tabWidth": 4, | ||
"semi": true, | ||
"singleQuote": false, | ||
"printWidth": 100, | ||
"endOfLine": "auto" | ||
} | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
script="$0" | ||
basename="$(dirname $script)" | ||
|
||
read -p "Do you want to delete the tooling installed in enterprise too ? [y, n]" willingToDeleteToolingInEnterprise | ||
if [[ $willingToDeleteToolingInEnterprise != "n" ]] | ||
then | ||
read -p "What is the relative path from community to enterprise ? (../enterprise)" pathToEnterprise | ||
pathToEnterprise=${pathToEnterprise:-../enterprise} | ||
fi | ||
|
||
rm -rf $basename/../../../.husky | ||
rm -rf $basename/../../../.eslintignore | ||
rm -rf $basename/../../../.prettierignore | ||
rm -rf $basename/../../../.eslintrc.json | ||
rm -rf $basename/../../../.prettierrc.json | ||
rm -rf $basename/../../../package.json | ||
rm -rf $basename/../../../package-lock.json | ||
rm -rf $basename/../../../node_modules | ||
|
||
if [[ $willingToDeleteToolingInEnterprise != "n" ]] | ||
then | ||
rm -rf $basename/../../../$pathToEnterprise/.husky | ||
rm -rf $basename/../../../$pathToEnterprise/.eslintignore | ||
rm -rf $basename/../../../$pathToEnterprise/.prettierignore | ||
rm -rf $basename/../../../$pathToEnterprise/.eslintrc.json | ||
rm -rf $basename/../../../$pathToEnterprise/.prettierrc.json | ||
rm -rf $basename/../../../$pathToEnterprise/package.json | ||
rm -rf $basename/../../../$pathToEnterprise/package-lock.json | ||
rm -rf $basename/../../../$pathToEnterprise/node_modules | ||
fi | ||
|
||
|
||
echo "" | ||
echo "JS tooling have been removed from the roots" | ||
echo "" |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
script="$0" | ||
basename="$(dirname $script)" | ||
|
||
read -p "Do you want the tooling installed in enterprise too ? [y, n]" willingToInstallToolingInEnterprise | ||
if [[ $willingToInstallToolingInEnterprise != "n" ]] | ||
then | ||
read -p "What is the relative path from community to enterprise ? (../enterprise)" pathToEnterprise | ||
pathToEnterprise=${pathToEnterprise:-../enterprise} | ||
fi | ||
|
||
cp -r $basename/_husky $basename/../../../.husky | ||
cp $basename/_eslintignore $basename/../../../.eslintignore | ||
cp $basename/_prettierignore $basename/../../../.prettierignore | ||
cp $basename/_eslintrc.json $basename/../../../.eslintrc.json | ||
cp $basename/_prettierrc.json $basename/../../../.prettierrc.json | ||
cp $basename/_package.json $basename/../../../package.json | ||
|
||
if [[ $willingToInstallToolingInEnterprise != "n" ]] | ||
then | ||
cp -r $basename/_husky $basename/../../../$pathToEnterprise/.husky | ||
cp $basename/_eslintignore $basename/../../../$pathToEnterprise/.eslintignore | ||
cp $basename/_prettierignore $basename/../../../$pathToEnterprise/.prettierignore | ||
cp $basename/_eslintrc.json $basename/../../../$pathToEnterprise/.eslintrc.json | ||
cp $basename/_prettierrc.json $basename/../../../$pathToEnterprise/.prettierrc.json | ||
cp $basename/_package.json $basename/../../../$pathToEnterprise/package.json | ||
fi | ||
|
||
cd $basename | ||
npm install | ||
cd - | ||
|
||
if [[ $willingToInstallToolingInEnterprise != "n" ]] | ||
then | ||
cd $basename/../../../$pathToEnterprise | ||
npm install | ||
cd - | ||
fi | ||
|
||
echo "" | ||
echo "JS tooling have been added to the roots" | ||
echo "Make sure to refresh the eslint service and configure your IDE so it uses the config files" | ||
echo 'For VSCode, look inside your .vscode/settings.json file ("editor.defaultFormatter": "dbaeumer.vscode-eslint")' | ||
echo "" |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
script="$0" | ||
basename="$(dirname $script)" | ||
|
||
$basename/disable.sh | ||
$basename/enable.sh |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare const owl: typeof import("../../static/lib/owl/owl.js"); | ||
declare const luxon: typeof import("../../static/lib/luxon/luxon.js"); | ||
declare const QUnit: QUnit; |
Oops, something went wrong.