@zimbra/eslint-config 0.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +1 -0
- package/.husky/prepare-commit-message +1 -0
- package/eslint.config.mjs +2 -4
- package/package.json +17 -10
- package/scripts/git-commit-msg.sh +20 -0
- package/src/configs/automation-config.js +1 -1
- package/src/configs/core-js-config.js +19 -10
- package/src/configs/custom-config.js +1 -1
- package/src/configs/locale-json-config.js +1 -1
- package/src/configs/preact-i18n-config.js +31 -0
- package/src/configs/react-config.js +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run lint
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
./scripts/git-commit-msg.sh $1
|
package/eslint.config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zimbra/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ESLint configuration for Zimbra javascript projects.",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,12 +9,19 @@
|
|
|
9
9
|
"./typescript": "./src/typescript.js"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"lint": "eslint src",
|
|
13
|
-
"lint:fix": "npm run lint -- --fix"
|
|
12
|
+
"lint": "eslint src --config eslint.config.mjs",
|
|
13
|
+
"lint:fix": "npm run lint -- --fix",
|
|
14
|
+
"prepublishOnly": "npm run lint && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags",
|
|
15
|
+
"prepare": "husky || true"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "^18.20.0",
|
|
19
|
+
"npm": "^6"
|
|
14
20
|
},
|
|
15
21
|
"dependencies": {
|
|
16
22
|
"@eslint/compat": "^1.0.0",
|
|
17
23
|
"@eslint/js": "^9.37.0",
|
|
24
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
18
25
|
"eslint-config-prettier": "^9.1.0",
|
|
19
26
|
"eslint-plugin-i18n-json": "^4.0.1",
|
|
20
27
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -24,13 +31,12 @@
|
|
|
24
31
|
"eslint-plugin-react": "^7.37.5",
|
|
25
32
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
26
33
|
"eslint-plugin-testcafe": "^0.2.1",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"prettier": "^3.6.2"
|
|
34
|
+
"globals": "^17.3.0",
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
|
+
"typescript": "^5.9.3"
|
|
31
37
|
},
|
|
32
38
|
"peerDependencies": {
|
|
33
|
-
"eslint": "^9.
|
|
39
|
+
"eslint": "^9.39.3",
|
|
34
40
|
"@typescript-eslint/eslint-plugin": "^8.50.1"
|
|
35
41
|
},
|
|
36
42
|
"peerDependenciesMeta": {
|
|
@@ -39,7 +45,8 @@
|
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
"devDependencies": {
|
|
42
|
-
"eslint": "^
|
|
43
|
-
"
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
49
|
+
"eslint": "^9.39.3",
|
|
50
|
+
"husky": "^9.1.7"
|
|
44
51
|
}
|
|
45
52
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# This way you can customize which branches should be skipped when
|
|
4
|
+
# prepending commit message.
|
|
5
|
+
if [ -z "$BRANCHES_TO_SKIP" ]; then
|
|
6
|
+
BRANCHES_TO_SKIP=(main)
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
# Get the current branch name
|
|
10
|
+
BRANCH_NAME=$(git symbolic-ref --short HEAD)
|
|
11
|
+
|
|
12
|
+
# Strip any leading prefix, up to and including, the last "/". e.g. turn "feature/ISSUE-1234" into "ISSUE-1234"
|
|
13
|
+
BRANCH_NAME="${BRANCH_NAME##*/}"
|
|
14
|
+
|
|
15
|
+
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
|
|
16
|
+
BRANCH_IN_COMMIT=$(grep -c "^$BRANCH_NAME" $1)
|
|
17
|
+
|
|
18
|
+
if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then
|
|
19
|
+
sed -i.bak -e "1s/^/$BRANCH_NAME /" $1
|
|
20
|
+
fi
|
|
@@ -4,7 +4,7 @@ import { automationRules } from '../rules/automation.js';
|
|
|
4
4
|
export default [
|
|
5
5
|
{
|
|
6
6
|
files: ['test/**/*.{js,jsx,mjs,cjs}', 'tests/**/*.{js,jsx,mjs,cjs}'],
|
|
7
|
-
ignores: ['**/node_modules
|
|
7
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
8
8
|
plugins: {
|
|
9
9
|
testcafePlugin: testcafePlugin
|
|
10
10
|
},
|
|
@@ -20,6 +20,9 @@ import { i18nRules, LANGUAGE_FILES_RELATIVE, i18nTextComponents } from '../rules
|
|
|
20
20
|
import prettierRules from '../rules/prettier.js';
|
|
21
21
|
import parserConfig from '../rules/parser.js';
|
|
22
22
|
|
|
23
|
+
const intlPath = process.env.ESLINT_INTL_PATH ?? 'src/intl';
|
|
24
|
+
const disableIntl = process.env.ESLINT_DISABLE_INTL === 'true';
|
|
25
|
+
|
|
23
26
|
const coreRules = {
|
|
24
27
|
...styleRules,
|
|
25
28
|
...reactRules,
|
|
@@ -27,11 +30,9 @@ const coreRules = {
|
|
|
27
30
|
...importRules,
|
|
28
31
|
...prettierRules,
|
|
29
32
|
...securityRules,
|
|
30
|
-
...i18nRules
|
|
33
|
+
...(disableIntl ? {} : i18nRules)
|
|
31
34
|
};
|
|
32
35
|
|
|
33
|
-
const intlPath = process.env.ESLINT_INTL_PATH ?? 'src/intl';
|
|
34
|
-
|
|
35
36
|
const languageFilesAbsolute = LANGUAGE_FILES_RELATIVE.map(entry => ({
|
|
36
37
|
name: entry.name,
|
|
37
38
|
path: path.join(intlPath, entry.filename)
|
|
@@ -41,7 +42,7 @@ export default [
|
|
|
41
42
|
{
|
|
42
43
|
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
43
44
|
|
|
44
|
-
ignores: ['**/node_modules
|
|
45
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/build/**', '**/*.graphql', '**/*.gql'],
|
|
45
46
|
|
|
46
47
|
languageOptions: {
|
|
47
48
|
...parserConfig,
|
|
@@ -57,8 +58,12 @@ export default [
|
|
|
57
58
|
mocha: fixupPluginRules(pluginMocha),
|
|
58
59
|
prettier: pluginPrettier,
|
|
59
60
|
import: importPlugin,
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
...(disableIntl
|
|
62
|
+
? {}
|
|
63
|
+
: {
|
|
64
|
+
// TODO: Upgrade `pluginPreactI18n` to a modern version to ensure compatibility with current tooling and React/Preact best practices
|
|
65
|
+
'preact-i18n': fixupPluginRules(pluginPreactI18n)
|
|
66
|
+
})
|
|
62
67
|
},
|
|
63
68
|
|
|
64
69
|
rules: {
|
|
@@ -73,10 +78,14 @@ export default [
|
|
|
73
78
|
settings: {
|
|
74
79
|
// Requires exactly version 16.0. See: https://github.com/jsx-eslint/eslint-plugin-react/issues/1754
|
|
75
80
|
react: { pragma: 'createElement', version: '16.0' },
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
...(disableIntl
|
|
82
|
+
? {}
|
|
83
|
+
: {
|
|
84
|
+
'preact-i18n': {
|
|
85
|
+
languageFiles: languageFilesAbsolute,
|
|
86
|
+
textComponents: i18nTextComponents
|
|
87
|
+
}
|
|
88
|
+
})
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
91
|
];
|
|
@@ -4,7 +4,7 @@ import noDirectMemoize from '../rules/custom-rules/no-direct-memoize.js';
|
|
|
4
4
|
export default [
|
|
5
5
|
{
|
|
6
6
|
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
7
|
-
ignores: ['**/node_modules
|
|
7
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
8
8
|
plugins: {
|
|
9
9
|
custom: {
|
|
10
10
|
rules: {
|
|
@@ -4,7 +4,7 @@ import { i18nJsonRules } from '../rules/i18n.js';
|
|
|
4
4
|
export default [
|
|
5
5
|
{
|
|
6
6
|
files: ['**/*.json'],
|
|
7
|
-
ignores: ['**/node_modules
|
|
7
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
8
8
|
plugins: {
|
|
9
9
|
'i18n-json': pluginI18nJson
|
|
10
10
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fixupPluginRules } from '@eslint/compat';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import pluginPreactI18n from 'eslint-plugin-preact-i18n';
|
|
5
|
+
|
|
6
|
+
import { i18nRules, LANGUAGE_FILES_RELATIVE, i18nTextComponents } from '../rules/i18n.js';
|
|
7
|
+
|
|
8
|
+
const intlPath = process.env.ESLINT_INTL_PATH ?? 'src/intl';
|
|
9
|
+
|
|
10
|
+
const languageFilesAbsolute = LANGUAGE_FILES_RELATIVE.map(entry => ({
|
|
11
|
+
name: entry.name,
|
|
12
|
+
path: path.join(intlPath, entry.filename)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
17
|
+
|
|
18
|
+
plugins: {
|
|
19
|
+
// TODO: Upgrade `pluginPreactI18n` to a modern version to ensure compatibility with current tooling and React/Preact best practices
|
|
20
|
+
'preact-i18n': fixupPluginRules(pluginPreactI18n)
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
rules: i18nRules,
|
|
24
|
+
|
|
25
|
+
settings: {
|
|
26
|
+
'preact-i18n': {
|
|
27
|
+
languageFiles: languageFilesAbsolute,
|
|
28
|
+
textComponents: i18nTextComponents
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pluginReact from 'eslint-plugin-react';
|
|
2
|
+
import pluginReactHooks from 'eslint-plugin-react-hooks';
|
|
3
|
+
|
|
4
|
+
import reactRules from '../rules/react.js';
|
|
5
|
+
import reactHooksRules from '../rules/react-hooks.js';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
9
|
+
|
|
10
|
+
plugins: {
|
|
11
|
+
react: pluginReact,
|
|
12
|
+
'react-hooks': pluginReactHooks
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
rules: {
|
|
16
|
+
...pluginReact.configs.recommended.rules,
|
|
17
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
18
|
+
...reactRules,
|
|
19
|
+
...reactHooksRules
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
settings: {
|
|
23
|
+
// Requires exactly version 16.0. See: https://github.com/jsx-eslint/eslint-plugin-react/issues/1754
|
|
24
|
+
react: { pragma: 'createElement', version: '16.0' }
|
|
25
|
+
}
|
|
26
|
+
};
|