@mui/internal-code-infra 0.0.1 โ†’ 0.0.2-canary.1

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.
Files changed (32) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/package.json +26 -31
  4. package/src/eslint/airbnb/base.mjs +18 -0
  5. package/src/eslint/airbnb/typescript.mjs +126 -0
  6. package/src/eslint/baseConfig.mjs +67 -0
  7. package/src/eslint/docsConfig.mjs +20 -0
  8. package/src/eslint/extensions.mjs +5 -0
  9. package/src/eslint/index.mjs +7 -0
  10. package/src/eslint/material-ui/config.mjs +193 -0
  11. package/src/eslint/material-ui/index.mjs +27 -0
  12. package/src/eslint/material-ui/rules/disallow-active-element-as-key-event-target.mjs +65 -0
  13. package/src/eslint/material-ui/rules/disallow-active-elements-as-key-event-target.test.mjs +71 -0
  14. package/src/eslint/material-ui/rules/disallow-react-api-in-server-components.mjs +64 -0
  15. package/src/eslint/material-ui/rules/docgen-ignore-before-comment.mjs +34 -0
  16. package/src/eslint/material-ui/rules/docgen-ignore-before-comment.test.mjs +56 -0
  17. package/src/eslint/material-ui/rules/mui-name-matches-component-name.mjs +161 -0
  18. package/src/eslint/material-ui/rules/mui-name-matches-component-name.test.mjs +257 -0
  19. package/src/eslint/material-ui/rules/no-empty-box.mjs +60 -0
  20. package/src/eslint/material-ui/rules/no-empty-box.test.mjs +42 -0
  21. package/src/eslint/material-ui/rules/no-restricted-resolved-imports.mjs +95 -0
  22. package/src/eslint/material-ui/rules/no-styled-box.mjs +53 -0
  23. package/src/eslint/material-ui/rules/no-styled-box.test.mjs +75 -0
  24. package/src/eslint/material-ui/rules/rules-of-use-theme-variants.mjs +124 -0
  25. package/src/eslint/material-ui/rules/rules-of-use-theme-variants.test.mjs +149 -0
  26. package/src/eslint/material-ui/rules/straight-quotes.mjs +43 -0
  27. package/src/eslint/material-ui/rules/straight-quotes.test.mjs +69 -0
  28. package/src/eslint/testConfig.mjs +111 -0
  29. package/src/estree-typescript.d.ts +21 -0
  30. package/src/prettier.mjs +34 -0
  31. package/src/setupVitest.ts +14 -0
  32. package/src/untyped-plugins.d.ts +96 -0
@@ -0,0 +1,69 @@
1
+ /* eslint-disable material-ui/straight-quotes */
2
+
3
+ import eslint from 'eslint';
4
+ import parser from '@typescript-eslint/parser';
5
+ import rule from './straight-quotes.mjs';
6
+
7
+ const ruleTester = new eslint.RuleTester({
8
+ languageOptions: {
9
+ parser,
10
+ },
11
+ });
12
+
13
+ ruleTester.run('straight-quotes', rule, {
14
+ valid: [
15
+ `
16
+ const values = [
17
+ {
18
+ title: 'Put community first ๐Ÿ’™',
19
+ },
20
+ ];
21
+ `,
22
+ ],
23
+ invalid: [
24
+ {
25
+ code: `
26
+ const values = [
27
+ {
28
+ title: 'Put community first ๐Ÿ’™',
29
+ description: 'We never lose sight of who weโ€™re serving and why.',
30
+ },
31
+ ];
32
+ `,
33
+ errors: [
34
+ {
35
+ messageId: 'wrongQuotes',
36
+ line: 5,
37
+ },
38
+ ],
39
+ },
40
+ {
41
+ code: `
42
+ // reference ID (also known as โ€œSHAโ€ or โ€œhashโ€) of the commit we're building.
43
+ const values = 'foo';
44
+ `,
45
+ errors: [
46
+ {
47
+ line: 2,
48
+ column: 32,
49
+ messageId: 'wrongQuotes',
50
+ },
51
+ {
52
+ line: 2,
53
+ column: 36,
54
+ messageId: 'wrongQuotes',
55
+ },
56
+ {
57
+ line: 2,
58
+ column: 41,
59
+ messageId: 'wrongQuotes',
60
+ },
61
+ {
62
+ line: 2,
63
+ column: 46,
64
+ messageId: 'wrongQuotes',
65
+ },
66
+ ],
67
+ },
68
+ ],
69
+ });
@@ -0,0 +1,111 @@
1
+ import mochaPlugin from 'eslint-plugin-mocha';
2
+ import testingLibrary from 'eslint-plugin-testing-library';
3
+ import globals from 'globals';
4
+ import * as tseslint from 'typescript-eslint';
5
+
6
+ /**
7
+ * @type {import('eslint').Linter.Config}
8
+ */
9
+ export const baseSpecRules = {
10
+ files: ['**/*.spec.*'],
11
+ rules: {
12
+ 'no-alert': 'off',
13
+ 'no-console': 'off',
14
+ 'no-empty-pattern': 'off',
15
+ 'no-lone-blocks': 'off',
16
+ 'no-shadow': 'off',
17
+
18
+ '@typescript-eslint/no-unused-expressions': 'off',
19
+ '@typescript-eslint/no-unused-vars': 'off',
20
+ '@typescript-eslint/no-use-before-define': 'off',
21
+
22
+ 'import/prefer-default-export': 'off',
23
+
24
+ 'jsx-a11y/anchor-has-content': 'off',
25
+ 'jsx-a11y/anchor-is-valid': 'off',
26
+ 'jsx-a11y/tabindex-no-positive': 'off',
27
+
28
+ 'react/default-props-match-prop-types': 'off',
29
+ 'react/no-access-state-in-setstate': 'off',
30
+ 'react/no-unused-prop-types': 'off',
31
+ 'react/prefer-stateless-function': 'off',
32
+ 'react/prop-types': 'off',
33
+ 'react/require-default-props': 'off',
34
+ 'react/state-in-constructor': 'off',
35
+ 'react/static-property-placement': 'off',
36
+ 'react/function-component-definition': 'off',
37
+ },
38
+ };
39
+
40
+ /**
41
+ * @param {Object} [options]
42
+ * @param {boolean} [options.useMocha]
43
+ * @returns {import('eslint').Linter.Config[]}
44
+ */
45
+ export function createTestConfig(options = {}) {
46
+ const { useMocha = true } = options;
47
+ return /** @type {import('eslint').Linter.Config[]} */ (
48
+ tseslint.config(
49
+ // @ts-expect-error The types don't make sense here.
50
+ useMocha ? mochaPlugin.configs.recommended : {},
51
+ testingLibrary.configs['flat/dom'],
52
+ testingLibrary.configs['flat/react'],
53
+ {
54
+ languageOptions: {
55
+ parser: tseslint.parser,
56
+ parserOptions: {
57
+ ecmaVersion: 7,
58
+ },
59
+ globals: globals.mocha,
60
+ },
61
+ rules: {
62
+ // does not work with wildcard imports. Mistakes will throw at runtime anyway
63
+ 'import/named': 'off',
64
+ 'material-ui/disallow-active-element-as-key-event-target': 'error',
65
+
66
+ // disable eslint-plugin-jsx-a11y
67
+ // tests are not driven by assistive technology
68
+ // add `jsx-a11y` rules once you encounter them in tests
69
+ 'jsx-a11y/click-events-have-key-events': 'off',
70
+ 'jsx-a11y/control-has-associated-label': 'off',
71
+ 'jsx-a11y/iframe-has-title': 'off',
72
+ 'jsx-a11y/label-has-associated-control': 'off',
73
+ 'jsx-a11y/mouse-events-have-key-events': 'off',
74
+ 'jsx-a11y/no-noninteractive-tabindex': 'off',
75
+ 'jsx-a11y/no-static-element-interactions': 'off',
76
+ 'jsx-a11y/tabindex-no-positive': 'off',
77
+
78
+ // In tests this is generally intended.
79
+ 'react/button-has-type': 'off',
80
+ // They are accessed to test custom validator implementation with PropTypes.checkPropTypes
81
+ 'react/forbid-foreign-prop-types': 'off',
82
+ // components that are defined in test are isolated enough
83
+ // that they don't need type-checking
84
+ 'react/prop-types': 'off',
85
+ '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
+ : {}),
107
+ },
108
+ },
109
+ )
110
+ );
111
+ }
@@ -0,0 +1,21 @@
1
+ import { BaseExpression, Expression } from 'estree';
2
+
3
+ export * from 'estree';
4
+
5
+ declare module 'estree' {
6
+ interface ExpressionMap {
7
+ TSNonNullExpression: TSNonNullExpression;
8
+ TSAsExpression: TSAsExpression;
9
+ }
10
+ }
11
+
12
+ export interface TSNonNullExpression extends BaseExpression {
13
+ type: 'TSNonNullExpression';
14
+ expression: Expression;
15
+ }
16
+
17
+ export interface TSAsExpression extends BaseExpression {
18
+ type: 'TSAsExpression';
19
+ expression: Expression;
20
+ typeAnnotation: Expression;
21
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @returns {import('prettier').Options}
3
+ */
4
+ export function createBaseConfig() {
5
+ return {
6
+ printWidth: 100,
7
+ singleQuote: true,
8
+ trailingComma: 'all',
9
+ overrides: [
10
+ {
11
+ files: ['docs/**/*.md', 'docs/src/pages/**/*.{js,tsx}', 'docs/data/**/*.{js,tsx}'],
12
+ options: {
13
+ // otherwise code blocks overflow on the docs website
14
+ // The container is 751px
15
+ printWidth: 85,
16
+ },
17
+ },
18
+ {
19
+ files: ['docs/pages/blog/**/*.md'],
20
+ options: {
21
+ // otherwise code blocks overflow on the blog website
22
+ // The container is 692px
23
+ printWidth: 82,
24
+ },
25
+ },
26
+ {
27
+ files: ['**/*.json'],
28
+ options: {
29
+ trailingComma: 'none',
30
+ },
31
+ },
32
+ ],
33
+ };
34
+ }
@@ -0,0 +1,14 @@
1
+ import { RuleTester as EslintRuleTester } from 'eslint';
2
+ import { RuleTester as TypescriptEslintRuleTester } from '@typescript-eslint/rule-tester';
3
+ import { describe, it, afterAll } from 'vitest';
4
+
5
+ EslintRuleTester.describe = describe;
6
+ EslintRuleTester.it = it;
7
+ EslintRuleTester.itOnly = it.only;
8
+
9
+ TypescriptEslintRuleTester.afterAll = afterAll;
10
+ TypescriptEslintRuleTester.describe = describe;
11
+ TypescriptEslintRuleTester.describeSkip = describe.skip;
12
+ TypescriptEslintRuleTester.it = it;
13
+ TypescriptEslintRuleTester.itSkip = it.skip;
14
+ TypescriptEslintRuleTester.itOnly = it.only;
@@ -0,0 +1,96 @@
1
+ declare module 'eslint-config-airbnb-base' {
2
+ import type { Linter } from 'eslint';
3
+
4
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
5
+ export default config;
6
+ }
7
+
8
+ declare module 'eslint-config-airbnb' {
9
+ import type { Linter } from 'eslint';
10
+
11
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
12
+ export default config;
13
+ }
14
+
15
+ declare module 'eslint-config-airbnb-base/rules/best-practices' {
16
+ import { Linter } from 'eslint';
17
+
18
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
19
+ export default config;
20
+ }
21
+
22
+ declare module 'eslint-config-airbnb-base/rules/errors' {
23
+ import { Linter } from 'eslint';
24
+
25
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
26
+ export default config;
27
+ }
28
+
29
+ declare module 'eslint-config-airbnb-base/rules/es6' {
30
+ import { Linter } from 'eslint';
31
+
32
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
33
+ export default config;
34
+ }
35
+
36
+ declare module 'eslint-config-airbnb-base/rules/imports' {
37
+ import { Linter } from 'eslint';
38
+
39
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
40
+ export default config;
41
+ }
42
+
43
+ declare module 'eslint-config-airbnb-base/rules/node' {
44
+ import { Linter } from 'eslint';
45
+
46
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
47
+ export default config;
48
+ }
49
+
50
+ declare module 'eslint-config-airbnb-base/rules/strict' {
51
+ import { Linter } from 'eslint';
52
+
53
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
54
+ export default config;
55
+ }
56
+
57
+ declare module 'eslint-config-airbnb-base/rules/style' {
58
+ import { Linter } from 'eslint';
59
+
60
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
61
+ export default config;
62
+ }
63
+
64
+ declare module 'eslint-config-airbnb-base/rules/variables' {
65
+ import { Linter } from 'eslint';
66
+
67
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
68
+ export default config;
69
+ }
70
+
71
+ declare module 'eslint-config-airbnb/rules/react' {
72
+ import { Linter } from 'eslint';
73
+
74
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
75
+ export default config;
76
+ }
77
+
78
+ declare module 'eslint-config-airbnb/rules/react-a11y' {
79
+ import { Linter } from 'eslint';
80
+
81
+ declare const config: Omit<Linter.LegacyConfig, 'extends' | 'plugins'>;
82
+ export default config;
83
+ }
84
+
85
+ declare module '@next/eslint-plugin-next' {
86
+ import { Linter } from 'eslint';
87
+
88
+ interface NextEslintPluginConfig extends Linter.LegacyConfig {
89
+ flatConfig: {
90
+ recommended: Linter.Config;
91
+ };
92
+ }
93
+
94
+ declare const config: NextEslintPluginConfig;
95
+ export default config;
96
+ }