1.0.1-beta.14 • Published 1 month ago

eslint-plugin-jimu-theme v1.0.1-beta.14

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

eslint-plugin-jimu-theme

This plug-in is used to assist in migrating jimu-theme variables to the new version.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-jimu-theme:

npm install eslint-plugin-jimu-theme --save-dev

Usage

Add jimu-theme to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "jimu-theme"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "jimu-theme/rule-name": 2
    }
}

Note

This plugin is only for assisting in jimu-theme upgrades and should not be used for other purposes.

The no-classic-* rules are used to upgrade corresponding variables, for example:

theme.colors.primary => theme.sys.color.primary.main

Rule no-classic-variables contains all other rules prefixed with no-classic (except rule no-classic-css-utilities, no-classic-css-vars), so you can choose to replace them with rule no-classic-variables.

The rule no-unnecessary-template-vars is intended to clean up abnormal code after a theme upgrade, such as:

~~const style = `color: ${'transparent'};`~~

const style = `color: transparent;`

The rule no-unnecessary-template-vars need to be placed after no-classic-*.

Then put rule no-classic-variables-left after all rules to check whether any classic theme variables are not recognized.

Furthermore, after automatic fixing, there might still be incorrect code remaining, which requires reviewing each file individually.

For example:

Before fixing:

const colors = theme.colors
const primary = colors.primary

After fixing:

const colors = theme.colors
const primary = theme.sys.color.primary.main

You can see that after the fix, a variable named "theme" is missing, and the definition of the "colors" variable is no longer needed. These require further manual processing. If you perform global automatic fixing, you need to pay attention to the warning and error messages eslint prints on the console to complete this part of the manual fixing.

We recommend autofixing files one by one rather than applying a global autofix directly.

Rules

🔧 Automatically fixable by the --fix CLI option.

Name                        Description🔧
no-classic-borderThis rule facilitates the deprecation of border variables in the classic theme and provides automatic fixes to replace these border variables with variables from the new theme or fallback values.🔧
no-classic-border-radiusThis rule facilitates the deprecation of borderRadiuses variables in the classic theme and provides automatic fixes to replace these borderRadiuses variables with variables from the new theme or fallback values.🔧
no-classic-colorsThis rule updates colors variables from old classic theme to new theme.🔧
no-classic-css-utilitiesThis rule facilitates the upgrade of css utilities from the classic theme to the new theme.🔧
no-classic-css-varsThis rule facilitates the transition of CSS variables representing colors from the classic theme to the new theme.🔧
no-classic-dark-themeThis rule facilitates the deprecation of darkTheme variables in the classic theme and provides automatic fixes to replace it with variables from the new theme.🔧
no-classic-elementsThis rule facilitates the deprecation of elements(e.g header, footer, body, link) variables in the classic theme and provides automatic fixes to replace these elements variables with variables from the new theme or fallback values.🔧
no-classic-focused-stylesThis rule facilitates the deprecation of focusedStyles variables in the classic theme and provides automatic fixes to replace these focusedStyles variables with variables from the new theme or fallback values.🔧
no-classic-shadowThis rule facilitates the deprecation of boxShadows variables in the classic theme and provides automatic fixes to replace these boxShadows variables with variables from the new theme.🔧
no-classic-sizesThis rule facilitates the deprecation of sizes variables in the classic theme and provides automatic fixes to replace these sizes variables with variables from the new theme.🔧
no-classic-surfaceThis rule facilitates the deprecation of surfaces variables in the classic theme and provides automatic fixes to replace these border variables with variables from the new theme or fallback values.🔧
no-classic-typographyThis rule facilitates the deprecation of typography variables in the classic theme and provides automatic fixes to replace these typography variables with variables from the new theme or fallback values.🔧
no-classic-variablesThis rule updates variables from old classic theme to new theme.🔧
no-classic-variables-leftThis rule is to check whether there are any remaining classical variables.🔧
no-guttersThis rule facilitates the deprecation of gutters variables in the theme and provides automatic fixes to replace these gutter variables with specific values.🔧
no-unnecessary-template-varsRemove unnecessary template string variables. Note: If it is used for theme upgrade, this rule should be called after other rules for upgrading the theme to fix abnormal results caused by the upgrade.🔧
1.0.1-beta.14

1 month ago

1.0.1-beta.9

2 months ago

1.0.1-beta.10

2 months ago

1.0.1-beta.11

2 months ago

1.0.1-beta.12

2 months ago

1.0.1-beta.13

2 months ago

1.0.1-beta.8

2 months ago

1.0.1-beta.7

2 months ago

1.0.1-beta.6

2 months ago

1.0.1-beta.5

2 months ago

1.0.1-beta.4

2 months ago

1.0.1-beta.3

2 months ago

1.0.1-beta.2

2 months ago

1.0.1-beta.1

2 months ago