@mpfrontend/workspace-config 0.1.0 → 1.0.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/README.md +2 -1
- package/dist/eslint-core.d.ts +52 -0
- package/dist/eslint-core.js +105 -0
- package/dist/eslint-core.js.map +1 -0
- package/dist/eslint.d.ts +1 -52
- package/dist/eslint.js +1 -104
- package/dist/eslint.js.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @mpfrontend/workspace-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Part of [MP Frontend](https://github.com/panahister/mpfrontend), released to the public npm registry as one cohort under one version.
|
|
4
|
+
Runtime: tooling. The shared quality profile of a consumer workspace: one
|
|
4
5
|
ESLint flat configuration, one Prettier profile and the TypeScript presets that every generated app and
|
|
5
6
|
package extends. It is versioned with the rest of the MP Frontend cohort, so a workspace upgrades its
|
|
6
7
|
rules by upgrading the cohort, never by copying configuration.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ESLint, Linter } from 'eslint';
|
|
2
|
+
import { type PhysicalAllowance } from './rules/logical-properties.js';
|
|
3
|
+
export { globalEntryAtRules } from './rules/no-handwritten-css.js';
|
|
4
|
+
export { visibleTextAttributes } from './rules/no-literal-text.js';
|
|
5
|
+
export type { PhysicalAllowance } from './rules/logical-properties.js';
|
|
6
|
+
/** One constraint of `@nx/enforce-module-boundaries`, keyed by the project tags the generators write. */
|
|
7
|
+
export type DepConstraint = Readonly<{
|
|
8
|
+
sourceTag: string;
|
|
9
|
+
onlyDependOnLibsWithTags?: readonly string[];
|
|
10
|
+
notDependOnLibsWithTags?: readonly string[];
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Boundaries over the tags that `mpfrontend create app` and the package generator write:
|
|
14
|
+
* `type:app` or `type:package`, `scope:<app>` or `scope:shared`, and a `runtime:*` tag.
|
|
15
|
+
* An app never depends on another app; a shared package never depends on an app.
|
|
16
|
+
*/
|
|
17
|
+
export declare const defaultDepConstraints: readonly DepConstraint[];
|
|
18
|
+
/** Token and theme files: the only files that may hold raw colour values and token CSS. */
|
|
19
|
+
export declare const defaultThemeFiles: readonly string[];
|
|
20
|
+
/** The one global style entry of an app: imports and base element rules only. */
|
|
21
|
+
export declare const defaultGlobalStyleEntries: readonly string[];
|
|
22
|
+
/** Build output, dependencies and generated contracts are never linted by hand-written rules. */
|
|
23
|
+
export declare const defaultIgnores: readonly string[];
|
|
24
|
+
export declare const codeFiles: readonly string[];
|
|
25
|
+
export declare const styleFiles: readonly string[];
|
|
26
|
+
export type WorkspaceConfigOptions = Readonly<{
|
|
27
|
+
/** Replaces the default constraints; spread `defaultDepConstraints` to extend them. */
|
|
28
|
+
depConstraints?: readonly DepConstraint[];
|
|
29
|
+
/** Replaces the default theme and token file globs. */
|
|
30
|
+
themeFiles?: readonly string[];
|
|
31
|
+
/** Replaces the default global style entry globs. */
|
|
32
|
+
globalStyleEntries?: readonly string[];
|
|
33
|
+
/** Added to the default ignores. */
|
|
34
|
+
ignores?: readonly string[];
|
|
35
|
+
/** Names of translator functions whose results must not be joined to other text; default `t`. */
|
|
36
|
+
translators?: readonly string[];
|
|
37
|
+
/** The documented allowlist of literal strings that are not user-visible text, as regular expressions. */
|
|
38
|
+
allowedText?: readonly string[];
|
|
39
|
+
/**
|
|
40
|
+
* Physical left or right values that are allowed, each with its reason: a utility (`left-1/2`), a CSS
|
|
41
|
+
* property (`margin-left`) or an inline style key (`marginLeft`). Empty by default.
|
|
42
|
+
*/
|
|
43
|
+
allowedPhysical?: readonly PhysicalAllowance[];
|
|
44
|
+
}>;
|
|
45
|
+
/** The MP Frontend rules, for consumers that compose their own configuration. */
|
|
46
|
+
export declare const plugin: ESLint.Plugin;
|
|
47
|
+
/**
|
|
48
|
+
* The shared ESLint flat configuration of an MP Frontend workspace. A workspace exports it from its root
|
|
49
|
+
* `eslint.config.mjs`; an app or a package spreads the root array and appends only its own additions.
|
|
50
|
+
*/
|
|
51
|
+
export declare function workspaceConfig(options?: WorkspaceConfigOptions): Linter.Config[];
|
|
52
|
+
export default workspaceConfig;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import css from '@eslint/css';
|
|
2
|
+
import nx from '@nx/eslint-plugin';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import noHandwrittenCss from './rules/no-handwritten-css.js';
|
|
5
|
+
import noRawColor from './rules/no-raw-color.js';
|
|
6
|
+
import publicEntry from './rules/public-entry.js';
|
|
7
|
+
import noLiteralText from './rules/no-literal-text.js';
|
|
8
|
+
import logicalProperties, {} from './rules/logical-properties.js';
|
|
9
|
+
export { globalEntryAtRules } from './rules/no-handwritten-css.js';
|
|
10
|
+
export { visibleTextAttributes } from './rules/no-literal-text.js';
|
|
11
|
+
/**
|
|
12
|
+
* Boundaries over the tags that `mpfrontend create app` and the package generator write:
|
|
13
|
+
* `type:app` or `type:package`, `scope:<app>` or `scope:shared`, and a `runtime:*` tag.
|
|
14
|
+
* An app never depends on another app; a shared package never depends on an app.
|
|
15
|
+
*/
|
|
16
|
+
export const defaultDepConstraints = [
|
|
17
|
+
{ sourceTag: 'type:app', onlyDependOnLibsWithTags: ['type:package'] },
|
|
18
|
+
{ sourceTag: 'type:package', onlyDependOnLibsWithTags: ['type:package'] },
|
|
19
|
+
{ sourceTag: 'scope:shared', onlyDependOnLibsWithTags: ['scope:shared'] },
|
|
20
|
+
{ sourceTag: 'runtime:universal', onlyDependOnLibsWithTags: ['runtime:universal'] },
|
|
21
|
+
{ sourceTag: 'runtime:client', notDependOnLibsWithTags: ['runtime:server'] },
|
|
22
|
+
{ sourceTag: 'runtime:server', notDependOnLibsWithTags: ['runtime:client'] },
|
|
23
|
+
];
|
|
24
|
+
/** Token and theme files: the only files that may hold raw colour values and token CSS. */
|
|
25
|
+
export const defaultThemeFiles = ['**/src/theme/**', '**/themes/**'];
|
|
26
|
+
/** The one global style entry of an app: imports and base element rules only. */
|
|
27
|
+
export const defaultGlobalStyleEntries = ['**/src/app/globals.css'];
|
|
28
|
+
/** Build output, dependencies and generated contracts are never linted by hand-written rules. */
|
|
29
|
+
export const defaultIgnores = [
|
|
30
|
+
'**/node_modules/**', '**/dist/**', '**/.next/**', '**/.nx/**', '**/runtime-assets/**', '**/coverage/**',
|
|
31
|
+
'**/generated/**', '**/*.gen.ts', '**/next-env.d.ts',
|
|
32
|
+
];
|
|
33
|
+
export const codeFiles = ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'];
|
|
34
|
+
export const styleFiles = ['**/*.css'];
|
|
35
|
+
/** The MP Frontend rules, for consumers that compose their own configuration. */
|
|
36
|
+
export const plugin = {
|
|
37
|
+
meta: { name: '@mpfrontend/workspace-config' },
|
|
38
|
+
rules: { 'no-raw-color': noRawColor, 'no-handwritten-css': noHandwrittenCss, 'public-entry': publicEntry, 'no-literal-text': noLiteralText,
|
|
39
|
+
'logical-properties': logicalProperties },
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The shared ESLint flat configuration of an MP Frontend workspace. A workspace exports it from its root
|
|
43
|
+
* `eslint.config.mjs`; an app or a package spreads the root array and appends only its own additions.
|
|
44
|
+
*/
|
|
45
|
+
export function workspaceConfig(options = {}) {
|
|
46
|
+
const themeFiles = [...(options.themeFiles ?? defaultThemeFiles)];
|
|
47
|
+
const globalStyleEntries = [...(options.globalStyleEntries ?? defaultGlobalStyleEntries)];
|
|
48
|
+
const physical = ['error', { allow: (options.allowedPhysical ?? []).map(entry => ({ ...entry })) }];
|
|
49
|
+
const typescript = tseslint.configs.recommended
|
|
50
|
+
.map(config => ({ ...config, files: config.files ?? [...codeFiles] }));
|
|
51
|
+
return [
|
|
52
|
+
{ name: 'mpfrontend/ignores', ignores: [...defaultIgnores, ...(options.ignores ?? [])] },
|
|
53
|
+
...typescript,
|
|
54
|
+
{
|
|
55
|
+
name: 'mpfrontend/code',
|
|
56
|
+
files: [...codeFiles],
|
|
57
|
+
plugins: { '@nx': nx, mpfrontend: plugin },
|
|
58
|
+
rules: {
|
|
59
|
+
'@nx/enforce-module-boundaries': ['error', {
|
|
60
|
+
enforceBuildableLibDependency: true,
|
|
61
|
+
allow: [],
|
|
62
|
+
depConstraints: (options.depConstraints ?? defaultDepConstraints).map(constraint => ({ ...constraint })),
|
|
63
|
+
}],
|
|
64
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
65
|
+
// A leading underscore marks a parameter that a framework passes but the code does not read.
|
|
66
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
67
|
+
'mpfrontend/no-raw-color': 'error',
|
|
68
|
+
'mpfrontend/no-handwritten-css': ['error', { inlineStyle: 'custom-properties' }],
|
|
69
|
+
'mpfrontend/public-entry': 'error',
|
|
70
|
+
'mpfrontend/no-literal-text': ['error', { translators: [...(options.translators ?? ['t'])], allow: [...(options.allowedText ?? [])] }],
|
|
71
|
+
'mpfrontend/logical-properties': physical,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
// Configuration files are tooling glue: an app configuration imports the workspace configuration.
|
|
76
|
+
name: 'mpfrontend/configuration-files',
|
|
77
|
+
files: ['**/*.config.{js,mjs,cjs,ts,mts}'],
|
|
78
|
+
rules: { '@nx/enforce-module-boundaries': 'off' },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'mpfrontend/styles',
|
|
82
|
+
files: [...styleFiles],
|
|
83
|
+
language: 'css/css',
|
|
84
|
+
languageOptions: { tolerant: true },
|
|
85
|
+
plugins: { css: css, mpfrontend: plugin },
|
|
86
|
+
rules: {
|
|
87
|
+
'mpfrontend/no-raw-color': 'error',
|
|
88
|
+
'mpfrontend/no-handwritten-css': ['error', { css: 'forbid' }],
|
|
89
|
+
'mpfrontend/logical-properties': physical,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'mpfrontend/global-style-entry',
|
|
94
|
+
files: globalStyleEntries,
|
|
95
|
+
rules: { 'mpfrontend/no-handwritten-css': ['error', { css: 'global-entry' }] },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'mpfrontend/theme-layer',
|
|
99
|
+
files: themeFiles,
|
|
100
|
+
rules: { 'mpfrontend/no-raw-color': 'off', 'mpfrontend/no-handwritten-css': 'off' },
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
export default workspaceConfig;
|
|
105
|
+
//# sourceMappingURL=eslint-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-core.js","sourceRoot":"","sources":["../src/eslint-core.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,iBAAiB,EAAC,EAAwB,MAAM,+BAA+B,CAAC;AAEvF,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AAUjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA6B;IAC7D,EAAC,SAAS,EAAE,UAAU,EAAE,wBAAwB,EAAE,CAAC,cAAc,CAAC,EAAC;IACnE,EAAC,SAAS,EAAE,cAAc,EAAE,wBAAwB,EAAE,CAAC,cAAc,CAAC,EAAC;IACvE,EAAC,SAAS,EAAE,cAAc,EAAE,wBAAwB,EAAE,CAAC,cAAc,CAAC,EAAC;IACvE,E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|
1
|
-
|
|
2
|
-
import { type PhysicalAllowance } from './rules/logical-properties.js';
|
|
3
|
-
export { globalEntryAtRules } from './rules/no-handwritten-css.js';
|
|
4
|
-
export { visibleTextAttributes } from './rules/no-literal-text.js';
|
|
5
|
-
export type { PhysicalAllowance } from './rules/logical-properties.js';
|
|
6
|
-
/** One constraint of `@nx/enforce-module-boundaries`, keyed by the project tags the generators write. */
|
|
7
|
-
export type DepConstraint = Readonly<{
|
|
8
|
-
sourceTag: string;
|
|
9
|
-
onlyDependOnLibsWithTags?: readonly string[];
|
|
10
|
-
notDependOnLibsWithTags?: readonly string[];
|
|
11
|
-
}>;
|
|
12
|
-
/**
|
|
13
|
-
* Boundaries over the tags that `mpfrontend create app` and the package generator write:
|
|
14
|
-
* `type:app` or `type:package`, `scope:<app>` or `scope:shared`, and a `runtime:*` tag.
|
|
15
|
-
* An app never depends on another app; a shared package never depends on an app.
|
|
16
|
-
*/
|
|
17
|
-
export declare const defaultDepConstraints: readonly DepConstraint[];
|
|
18
|
-
/** Token and theme files: the only files that may hold raw colour values and token CSS. */
|
|
19
|
-
export declare const defaultThemeFiles: readonly string[];
|
|
20
|
-
/** The one global style entry of an app: imports and base element rules only. */
|
|
21
|
-
export declare const defaultGlobalStyleEntries: readonly string[];
|
|
22
|
-
/** Build output, dependencies and generated contracts are never linted by hand-written rules. */
|
|
23
|
-
export declare const defaultIgnores: readonly string[];
|
|
24
|
-
export declare const codeFiles: readonly string[];
|
|
25
|
-
export declare const styleFiles: readonly string[];
|
|
26
|
-
export type WorkspaceConfigOptions = Readonly<{
|
|
27
|
-
/** Replaces the default constraints; spread `defaultDepConstraints` to extend them. */
|
|
28
|
-
depConstraints?: readonly DepConstraint[];
|
|
29
|
-
/** Replaces the default theme and token file globs. */
|
|
30
|
-
themeFiles?: readonly string[];
|
|
31
|
-
/** Replaces the default global style entry globs. */
|
|
32
|
-
globalStyleEntries?: readonly string[];
|
|
33
|
-
/** Added to the default ignores. */
|
|
34
|
-
ignores?: readonly string[];
|
|
35
|
-
/** Names of translator functions whose results must not be joined to other text; default `t`. */
|
|
36
|
-
translators?: readonly string[];
|
|
37
|
-
/** The documented allowlist of literal strings that are not user-visible text, as regular expressions. */
|
|
38
|
-
allowedText?: readonly string[];
|
|
39
|
-
/**
|
|
40
|
-
* Physical left or right values that are allowed, each with its reason: a utility (`left-1/2`), a CSS
|
|
41
|
-
* property (`margin-left`) or an inline style key (`marginLeft`). Empty by default.
|
|
42
|
-
*/
|
|
43
|
-
allowedPhysical?: readonly PhysicalAllowance[];
|
|
44
|
-
}>;
|
|
45
|
-
/** The MP Frontend rules, for consumers that compose their own configuration. */
|
|
46
|
-
export declare const plugin: ESLint.Plugin;
|
|
47
|
-
/**
|
|
48
|
-
* The shared ESLint flat configuration of an MP Frontend workspace. A workspace exports it from its root
|
|
49
|
-
* `eslint.config.mjs`; an app or a package spreads the root array and appends only its own additions.
|
|
50
|
-
*/
|
|
51
|
-
export declare function workspaceConfig(options?: WorkspaceConfigOptions): Linter.Config[];
|
|
52
|
-
export default workspaceConfig;
|
|
1
|
+
export { default, defaultDepConstraints, defaultGlobalStyleEntries, defaultIgnores, defaultThemeFiles, type DepConstraint, type PhysicalAllowance, plugin, workspaceConfig, type WorkspaceConfigOptions, } from './eslint-core.js';
|
package/dist/eslint.js
CHANGED
|
@@ -1,105 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import nx from '@nx/eslint-plugin';
|
|
3
|
-
import tseslint from 'typescript-eslint';
|
|
4
|
-
import noHandwrittenCss from './rules/no-handwritten-css.js';
|
|
5
|
-
import noRawColor from './rules/no-raw-color.js';
|
|
6
|
-
import publicEntry from './rules/public-entry.js';
|
|
7
|
-
import noLiteralText from './rules/no-literal-text.js';
|
|
8
|
-
import logicalProperties, {} from './rules/logical-properties.js';
|
|
9
|
-
export { globalEntryAtRules } from './rules/no-handwritten-css.js';
|
|
10
|
-
export { visibleTextAttributes } from './rules/no-literal-text.js';
|
|
11
|
-
/**
|
|
12
|
-
* Boundaries over the tags that `mpfrontend create app` and the package generator write:
|
|
13
|
-
* `type:app` or `type:package`, `scope:<app>` or `scope:shared`, and a `runtime:*` tag.
|
|
14
|
-
* An app never depends on another app; a shared package never depends on an app.
|
|
15
|
-
*/
|
|
16
|
-
export const defaultDepConstraints = [
|
|
17
|
-
{ sourceTag: 'type:app', onlyDependOnLibsWithTags: ['type:package'] },
|
|
18
|
-
{ sourceTag: 'type:package', onlyDependOnLibsWithTags: ['type:package'] },
|
|
19
|
-
{ sourceTag: 'scope:shared', onlyDependOnLibsWithTags: ['scope:shared'] },
|
|
20
|
-
{ sourceTag: 'runtime:universal', onlyDependOnLibsWithTags: ['runtime:universal'] },
|
|
21
|
-
{ sourceTag: 'runtime:client', notDependOnLibsWithTags: ['runtime:server'] },
|
|
22
|
-
{ sourceTag: 'runtime:server', notDependOnLibsWithTags: ['runtime:client'] },
|
|
23
|
-
];
|
|
24
|
-
/** Token and theme files: the only files that may hold raw colour values and token CSS. */
|
|
25
|
-
export const defaultThemeFiles = ['**/src/theme/**', '**/themes/**'];
|
|
26
|
-
/** The one global style entry of an app: imports and base element rules only. */
|
|
27
|
-
export const defaultGlobalStyleEntries = ['**/src/app/globals.css'];
|
|
28
|
-
/** Build output, dependencies and generated contracts are never linted by hand-written rules. */
|
|
29
|
-
export const defaultIgnores = [
|
|
30
|
-
'**/node_modules/**', '**/dist/**', '**/.next/**', '**/.nx/**', '**/runtime-assets/**', '**/coverage/**',
|
|
31
|
-
'**/generated/**', '**/*.gen.ts', '**/next-env.d.ts',
|
|
32
|
-
];
|
|
33
|
-
export const codeFiles = ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'];
|
|
34
|
-
export const styleFiles = ['**/*.css'];
|
|
35
|
-
/** The MP Frontend rules, for consumers that compose their own configuration. */
|
|
36
|
-
export const plugin = {
|
|
37
|
-
meta: { name: '@mpfrontend/workspace-config' },
|
|
38
|
-
rules: { 'no-raw-color': noRawColor, 'no-handwritten-css': noHandwrittenCss, 'public-entry': publicEntry, 'no-literal-text': noLiteralText,
|
|
39
|
-
'logical-properties': logicalProperties },
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* The shared ESLint flat configuration of an MP Frontend workspace. A workspace exports it from its root
|
|
43
|
-
* `eslint.config.mjs`; an app or a package spreads the root array and appends only its own additions.
|
|
44
|
-
*/
|
|
45
|
-
export function workspaceConfig(options = {}) {
|
|
46
|
-
const themeFiles = [...(options.themeFiles ?? defaultThemeFiles)];
|
|
47
|
-
const globalStyleEntries = [...(options.globalStyleEntries ?? defaultGlobalStyleEntries)];
|
|
48
|
-
const physical = ['error', { allow: (options.allowedPhysical ?? []).map(entry => ({ ...entry })) }];
|
|
49
|
-
const typescript = tseslint.configs.recommended
|
|
50
|
-
.map(config => ({ ...config, files: config.files ?? [...codeFiles] }));
|
|
51
|
-
return [
|
|
52
|
-
{ name: 'mpfrontend/ignores', ignores: [...defaultIgnores, ...(options.ignores ?? [])] },
|
|
53
|
-
...typescript,
|
|
54
|
-
{
|
|
55
|
-
name: 'mpfrontend/code',
|
|
56
|
-
files: [...codeFiles],
|
|
57
|
-
plugins: { '@nx': nx, mpfrontend: plugin },
|
|
58
|
-
rules: {
|
|
59
|
-
'@nx/enforce-module-boundaries': ['error', {
|
|
60
|
-
enforceBuildableLibDependency: true,
|
|
61
|
-
allow: [],
|
|
62
|
-
depConstraints: (options.depConstraints ?? defaultDepConstraints).map(constraint => ({ ...constraint })),
|
|
63
|
-
}],
|
|
64
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
65
|
-
// A leading underscore marks a parameter that a framework passes but the code does not read.
|
|
66
|
-
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
67
|
-
'mpfrontend/no-raw-color': 'error',
|
|
68
|
-
'mpfrontend/no-handwritten-css': ['error', { inlineStyle: 'custom-properties' }],
|
|
69
|
-
'mpfrontend/public-entry': 'error',
|
|
70
|
-
'mpfrontend/no-literal-text': ['error', { translators: [...(options.translators ?? ['t'])], allow: [...(options.allowedText ?? [])] }],
|
|
71
|
-
'mpfrontend/logical-properties': physical,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
// Configuration files are tooling glue: an app configuration imports the workspace configuration.
|
|
76
|
-
name: 'mpfrontend/configuration-files',
|
|
77
|
-
files: ['**/*.config.{js,mjs,cjs,ts,mts}'],
|
|
78
|
-
rules: { '@nx/enforce-module-boundaries': 'off' },
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: 'mpfrontend/styles',
|
|
82
|
-
files: [...styleFiles],
|
|
83
|
-
language: 'css/css',
|
|
84
|
-
languageOptions: { tolerant: true },
|
|
85
|
-
plugins: { css: css, mpfrontend: plugin },
|
|
86
|
-
rules: {
|
|
87
|
-
'mpfrontend/no-raw-color': 'error',
|
|
88
|
-
'mpfrontend/no-handwritten-css': ['error', { css: 'forbid' }],
|
|
89
|
-
'mpfrontend/logical-properties': physical,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'mpfrontend/global-style-entry',
|
|
94
|
-
files: globalStyleEntries,
|
|
95
|
-
rules: { 'mpfrontend/no-handwritten-css': ['error', { css: 'global-entry' }] },
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'mpfrontend/theme-layer',
|
|
99
|
-
files: themeFiles,
|
|
100
|
-
rules: { 'mpfrontend/no-raw-color': 'off', 'mpfrontend/no-handwritten-css': 'off' },
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
|
-
export default workspaceConfig;
|
|
1
|
+
export { default, defaultDepConstraints, defaultGlobalStyleEntries, defaultIgnores, defaultThemeFiles, plugin, workspaceConfig, } from './eslint-core.js';
|
|
105
2
|
//# sourceMappingURL=eslint.js.map
|
package/dist/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EAGjB,MAAM,EACN,eAAe,GAEhB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { codeFiles, globalEntryAtRules, styleFiles, visibleTextAttributes } from './eslint-core.js';
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAC,SAAS,EAAC,kBAAkB,EAAC,UAAU,EAAC,qBAAqB,EAAC,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpfrontend/workspace-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"./tsconfig/base.json": "./tsconfig/base.json",
|
|
21
21
|
"./tsconfig/next.json": "./tsconfig/next.json",
|
|
22
|
-
"./tsconfig/library.json": "./tsconfig/library.json"
|
|
22
|
+
"./tsconfig/library.json": "./tsconfig/library.json",
|
|
23
|
+
"./internal": {
|
|
24
|
+
"types": "./dist/internal.d.ts",
|
|
25
|
+
"import": "./dist/internal.js"
|
|
26
|
+
}
|
|
23
27
|
},
|
|
24
28
|
"files": [
|
|
25
29
|
"dist",
|