Skip to content
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

Create Feature less module in UI code and import alias #768

Merged
merged 5 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ui/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://editorconfig.org
root = true

[*]
charset=utf-8
end_of_line=lf
insert_final_newline=false
indent_style=space
indent_size=2

[{.eslintrc,.babelrc,.stylelintrc,*.json}]
Fendoe marked this conversation as resolved.
Show resolved Hide resolved
indent_style=space
indent_size=2

[*.less]
indent_style=space
indent_size=2

[*.{js,jsx,ts,tsx,vue}]
Fendoe marked this conversation as resolved.
Show resolved Hide resolved
indent_style=space
indent_size=2

50 changes: 47 additions & 3 deletions ui/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,67 @@
"es6": true,
"node": true
},
"plugins": ["@typescript-eslint/eslint-plugin"],
"plugins": ["react", "@typescript-eslint/eslint-plugin", "prettier"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".tsx", ".ts", ".jsx", ".js", ".json"]
},
"typescript": {}
}
},
"extends": [
// https://github.com/eslint/eslint/blob/main/conf/eslint-recommended.js
"eslint:recommended",
// https://github.com/facebook/create-react-app/tree/main/packages/eslint-config-react-app
"react-app",
// https://reactjs.org/docs/hooks-rules.html
"plugin:react-hooks/recommended",
"prettier"
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"dot-notation": "error"
"dot-notation": "error",
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never",
"json": "never",
"js": "never",
"jsx": "never"
}
],
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"import/prefer-default-export": "off",
"import/no-unresolved": "error",
"import/no-dynamic-require": "off",
"import/no-mutable-exports": "warn"
// Then import sort is enabled
// "import/order": [
// "error",
// {
// "groups": ["builtin", "external", "internal"],
// "pathGroups": [
// {
// "pattern": "react",
// "group": "external",
// "position": "before"
// }
// ],
// "pathGroupsExcludedImportTypes": ["react"],
// "newlines-between": "always",
// "alphabetize": {
// "order": "asc",
// "caseInsensitive": true
// }
// }
// ]
Fendoe marked this conversation as resolved.
Show resolved Hide resolved
},
"overrides": [
{
Expand Down
3 changes: 3 additions & 0 deletions ui/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
],
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
51 changes: 51 additions & 0 deletions ui/craco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const path = require("path");

const { loaderByName } = require("@craco/craco");
const CracoLessPlugin = require("craco-less");

const resolve = (dir) => path.resolve(__dirname, dir);

module.exports = {
babel: {
plugins: [
[
"import",
{
libraryName: "antd",
libraryDirectory: "es",
style: true,
},
],
],
},
webpack: {
alias: {
"@": resolve("src"),
},
},
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {},
javascriptEnabled: true,
},
},
modifyLessModuleRule(lessModuleRule, context) {
// Configure the file suffix
lessModuleRule.test = /\.module\.less$/;

// Configure the generated local ident name.
const cssLoader = lessModuleRule.use.find(loaderByName("css-loader"));
cssLoader.options.modules = {
localIdentName: "[local]_[hash:base64:5]",
};

return lessModuleRule;
},
},
},
],
};
Loading