Skip to content

Latest commit

 

History

History
183 lines (151 loc) · 4.19 KB

MIGRATING.md

File metadata and controls

183 lines (151 loc) · 4.19 KB

Migrating (1.x to 2.x)

Migrating guide is provided as a list of different cases "before" and "after".

Case 1: Inline disable / disable except

Inline comments syntax have not changed, but now you need to specify a processor in ESLint config in order for inline comments to work. Same applies for "except" case.

source.js

/* eslint-plugin-disable react */

function greet(name) {
  console.log('Hi, ' + name);
}
Before

.eslintrc

{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
}
After
{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
+ "processor": "disable/disable"
}

Case 2: Disable file path patterns

Disables specific plugins for specific file path patterns. In new version all paths options have been removed from settings. Using ESLlint 6+ Overrides from now on (make sure to review the docs for extended configuration options).

Before

.eslintrc

{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
- "settings": {
-   "eslint-plugin-disable": {
-     "paths": {
-       "jsx-a11y": ["**/lib/**/*.js"],
-       "react": ["**/app/module/*.service.js", "**/*.test.jsx"],
-       "*": ["config.js"]
-     }
-   }
- }
}
After
{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
+ "processor": "disable/disable",
+ "overrides": [
+   {
+     "files": ["lib/**/*.js"],
+     "settings": {
+       "disable/plugins": ["jsx-a11y"],
+     }
+   },
+   {
+     "files": ["app/module/*.service.js", "**/*.test.jsx"],
+     "settings": {
+       "disable/plugins": ["react"]
+     }
+   },
+   {
+     "files": ["config.js"],
+     "settings": {
+       "disable/plugins": "*"
+     }
+   }
+ ]
}

Case 3: Disable all except file patterns

Disables all registered plugins except the ones specified in settings. In new version all paths options have been removed from settings. Using ESLlint 6+ Overrides from now on (make sure to review the docs for extended configuration options).

Before

.eslintrc

{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
- "settings": {
-   "eslint-plugin-disable": {
-     "allExceptPaths": {
-       "jsx-a11y": ["**/lib/**/*.js"],
-       "react": ["**/app/module/*.service.js", "**/*.test.jsx"]
-     }
-   }
- }
}
After
{
  "plugins": ["import", "react", "jsx-a11y", "disable"],
+ "processor": "disable/disable",
+ "overrides": [
+   {
+     "files": ["lib/**/*.js"],
+     "settings": {
+       "disable/disableAllExcept": true,
+       "disable/plugins": ["jsx-a11y"],
+     }
+   },
+   {
+     "files": ["app/module/*.service.js", "**/*.test.jsx"],
+     "settings": {
+       "disable/disableAllExcept": true,
+       "disable/plugins": ["react"]
+     }
+   }
+ ]
}

Case 4: Using vue-cli-service

Some ESLint plugins also use processors, which creates a conflict with this plugin, because ESLint does not allow to chain processors for the same source files without processing it and producing another files. "cliArgs" have been used to pass extensions and are now replaced with ESLlint 6+ Overrides so that you can specify which files will be processed. Also hidden integration of conflicting processors now moved to a configurable option "externalProcessor", which accepts a processor identifier "pluginName/processorName" and makes this plugin to call other plugin's processor before disabling the rules.

Before

.eslintrc

{
  "extends": [
    "plugin:vue/essential",
    "plugin:vue/strongly-recommended"
  ],
  "plugins": ["disable"],
- "settings": {
-   "eslint-plugin-disable": {
-     "paths": {
-       "vue": ["**/lib/**/*.vue"]
-     },
-     "cliArgs": ["--ext", ".js,.vue"]
-   }
- }
}
After
{
  "extends": [
    "plugin:vue/essential",
    "plugin:vue/strongly-recommended"
  ],
  "plugins": ["disable"],
+ "overrides": [
+   {
+     "files": ["lib/**/*.vue"],
+     "processor": "disable/disable",
+     "settings": {
+       "disable/plugins": ["vue"],
+       "disable/externalProcessor": "vue/.vue"
+     }
+   }
+ ]
}