Skip to content

Commit 3c62849

Browse files
author
Brijesh Bittu
committed
[code-infra] Infra package followup #344
Addresses some of the comments from the previous PR #344
1 parent 8391aed commit 3c62849

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

.github/workflows/scripts/prs/checkTargetBranchLabel.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @ts-check
22
const vBranchRegex = /^v\d{1,3}\.x$/;
3-
// const transferLabels = ['cherry-pick'];
43

54
/**
65
* @param {Object} params

packages/code-infra/package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/mui/mui-public.git",
9-
"directory": "packages/mui-internal-code-infra"
9+
"directory": "packages/code-infra"
1010
},
1111
"sideEffects": false,
1212
"exports": {
@@ -45,14 +45,6 @@
4545
"eslint": "^9.0.0",
4646
"prettier": "^3.0.0"
4747
},
48-
"peerDependenciesMeta": {
49-
"eslint": {
50-
"optional": true
51-
},
52-
"prettier": {
53-
"optional": true
54-
}
55-
},
5648
"devDependencies": {
5749
"@next/eslint-plugin-next": "^15.3.3",
5850
"@types/eslint-plugin-jsx-a11y": "^6.10.0",

packages/code-infra/src/eslint/testConfig.mjs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ export const baseSpecRules = {
3838
};
3939

4040
/**
41+
* @param {Object} [options]
42+
* @param {boolean} [options.useMocha]
4143
* @returns {import('eslint').Linter.Config[]}
4244
*/
43-
export function createTestConfig() {
45+
export function createTestConfig(options = {}) {
46+
const { useMocha = true } = options;
4447
return /** @type {import('eslint').Linter.Config[]} */ (
4548
tseslint.config(
4649
// @ts-expect-error The types don't make sense here.
47-
mochaPlugin.configs.recommended,
50+
useMocha ? mochaPlugin.configs.recommended : null,
4851
testingLibrary.configs['flat/dom'],
4952
testingLibrary.configs['flat/react'],
5053
{
@@ -59,23 +62,6 @@ export function createTestConfig() {
5962
// does not work with wildcard imports. Mistakes will throw at runtime anyway
6063
'import/named': 'off',
6164
'material-ui/disallow-active-element-as-key-event-target': 'error',
62-
'mocha/consistent-spacing-between-blocks': 'off',
63-
64-
// upgraded level from recommended
65-
'mocha/no-pending-tests': 'error',
66-
67-
// no rationale provided in /recommended
68-
'mocha/no-mocha-arrows': 'off',
69-
// definitely a useful rule but too many false positives
70-
// due to `describeConformance`
71-
// "If you're using dynamically generated tests, you should disable this rule.""
72-
'mocha/no-setup-in-describe': 'off',
73-
// `beforeEach` for a single case is optimized for change
74-
// when we add a test we don't have to refactor the existing
75-
// test to `beforeEach`.
76-
// `beforeEach`+`afterEach` also means that the `beforeEach`
77-
// is cleaned up in `afterEach` if the test causes a crash
78-
'mocha/no-hooks-for-single-case': 'off',
7965

8066
// disable eslint-plugin-jsx-a11y
8167
// tests are not driven by assistive technology
@@ -97,6 +83,27 @@ export function createTestConfig() {
9783
// that they don't need type-checking
9884
'react/prop-types': 'off',
9985
'react/no-unused-prop-types': 'off',
86+
...(useMocha
87+
? {
88+
'mocha/consistent-spacing-between-blocks': 'off',
89+
90+
// upgraded level from recommended
91+
'mocha/no-pending-tests': 'error',
92+
93+
// no rationale provided in /recommended
94+
'mocha/no-mocha-arrows': 'off',
95+
// definitely a useful rule but too many false positives
96+
// due to `describeConformance`
97+
// "If you're using dynamically generated tests, you should disable this rule.""
98+
'mocha/no-setup-in-describe': 'off',
99+
// `beforeEach` for a single case is optimized for change
100+
// when we add a test we don't have to refactor the existing
101+
// test to `beforeEach`.
102+
// `beforeEach`+`afterEach` also means that the `beforeEach`
103+
// is cleaned up in `afterEach` if the test causes a crash
104+
'mocha/no-hooks-for-single-case': 'off',
105+
}
106+
: {}),
100107
},
101108
},
102109
)

0 commit comments

Comments
 (0)