Skip to content

Commit a8e9b29

Browse files
authoredOct 27, 2022
WIP - Commitlint, Editorconfig, ESLint, Prettier with NX (#7)
* (chore): init commit for opening a wip pr * feat(commitlint): added the configs and dependencies required for commitlint * feat(husky): added husky install to an npm prepare script required for husky to work * refactor(web-sdk prettier): now loading the prettier config from a global config directory the new config extends a base config, now prettier is installed in root and removed from web-sdk * refactor(eslint): moved eslint to root, now extending the config from a base config eslint configs are now within the config directory * refactor(editorconfig): moved editorconfig to the root of the monorepo * build(web-sdk deps): removed commitlint deps since they are now root level * refactor(eslint plugins): moved general eslint plugins and configs such as ts and prettier to root * revert(root/local packages): readded eslint and prettier to web-sdk's deps * refactor(config directory): refactored package-specific configs to higher level i.e svelte this change would allow a number of packages to share a single broad config and still have their own package specific overrides.
1 parent baafacd commit a8e9b29

22 files changed

+3285
-1621
lines changed
 

‎sdks/web-sdk/.czrc ‎.czrc

File renamed without changes.
File renamed without changes.
File renamed without changes.

‎.prettierrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./packages/config/prettierrc.base.cjs');

‎commitlint.config.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

‎nx.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
"default": {
44
"runner": "nx/tasks-runners/default",
55
"options": {
6-
"cacheableOperations": [
7-
"build"
8-
]
6+
"cacheableOperations": ["build"]
97
}
108
}
119
},
1210
"targetDefaults": {
1311
"build": {
14-
"outputs": [
15-
"{projectRoot}/dist"
16-
]
12+
"outputs": ["{projectRoot}/dist"]
1713
}
1814
},
1915
"defaultBase": "main"

‎package.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@
77
"web-sdk:dev": "pnpm exec nx dev web-sdk",
88
"web-sdk:build": "pnpm exec nx build web-sdk",
99
"web-sdk:example": "pnpm exec nx example web-sdk",
10+
"web-sdk:format": "pnpm exec nx format web-sdk",
11+
"web-sdk:lint": "pnpm exec nx lint web-sdk",
12+
"web-sdk:lint:fix": "pnpm exec nx lint:fix web-sdk",
13+
"format": "pnpm exec nx run-many --target=format",
14+
"lint": "pnpm exec nx run-many --target=lint",
15+
"lint:fix": "pnpm exec nx run-many --target=lint:fix",
1016
"start:backoffice:dev": "echo \"Error: no test specified\" && exit 1",
1117
"start:workflow-builder:dev": "echo \"Error: no test specified\" && exit 1",
12-
"start:web-ui:dev": "echo \"Error: no test specified\" && exit 1"
18+
"start:web-ui:dev": "echo \"Error: no test specified\" && exit 1",
19+
"commit": "git add . && git-cz",
20+
"prepare": "husky install"
1321
},
1422
"license": "ISC",
1523
"devDependencies": {
16-
"nx": "15.0.2"
24+
"@commitlint/cli": "^17.1.2",
25+
"@commitlint/config-conventional": "^17.1.0",
26+
"commitizen": "^4.2.5",
27+
"editorconfig": "^1.0.1",
28+
"husky": "^8.0.1",
29+
"nx": "15.0.2",
30+
"prettier": "^2.7.1"
1731
}
1832
}

‎packages/config/eslintrc.base.cjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
7+
'prettier',
8+
],
9+
parserOptions: {
10+
ecmaVersion: 2020,
11+
sourceType: 'module',
12+
},
13+
env: {
14+
es6: true,
15+
},
16+
plugins: ['@typescript-eslint'],
17+
ignorePatterns: ['node_modules', '.eslintrc.cjs'],
18+
};

‎packages/config/eslintrc.svelte.cjs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { env, plugins, extends: extendsRest, ...base } = require('./eslintrc.base.cjs');
2+
3+
module.exports = {
4+
...base,
5+
extends: [
6+
'plugin:storybook/recommended',
7+
// Make sure the prettier config is always last
8+
...extendsRest,
9+
],
10+
env: {
11+
...env,
12+
browser: true,
13+
},
14+
overrides: [
15+
{
16+
files: ['*.svelte'],
17+
processor: 'svelte3/svelte3',
18+
},
19+
],
20+
settings: {
21+
'svelte3/typescript': require('typescript'),
22+
'svelte3/ignore-styles': () => true,
23+
},
24+
plugins: [
25+
'svelte3',
26+
// Make sure plugins that have to be last are always last
27+
...plugins,
28+
],
29+
};

‎packages/config/prettierrc.base.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
arrowParens: 'avoid',
6+
};

‎packages/config/prettierrc.svelte.cjs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
...require('./prettierrc.base.cjs'),
3+
plugins: ['prettier-plugin-svelte'],
4+
svelteSortOrder: 'options-scripts-markup-styles',
5+
svelteStrictMode: false,
6+
svelteBracketNewLine: true,
7+
svelteIndentScriptAndStyle: true,
8+
svelteAllowShorthand: true,
9+
};

0 commit comments

Comments
 (0)