eslint-plugin-uilib
Advanced tools
Comparing version 1.0.28 to 1.0.30
@@ -5,9 +5,12 @@ const MAP_SCHEMA = { | ||
origin: { | ||
type: 'string', | ||
type: 'string' | ||
}, | ||
destination: { | ||
type: 'string', | ||
type: 'string' | ||
}, | ||
applyAutofix: { | ||
type: 'boolean' | ||
} | ||
}, | ||
additionalProperties: false, | ||
additionalProperties: false | ||
}; | ||
@@ -23,3 +26,3 @@ | ||
messages: { | ||
uiLib: 'Do not import directly from this source. Please use another import source (autofix available).', | ||
uiLib: 'Do not import directly from this source. Please use another import source (autofix may be available).', | ||
}, | ||
@@ -36,3 +39,5 @@ fixable: 'code', | ||
const destination = context.options[0].destination; | ||
const message = `Do not import directly from '${origin}'. Please use '${destination}' (autofix available).`; | ||
const applyAutofix = context.options[0].applyAutofix; | ||
const autofixMessage = applyAutofix ? ' (autofix available)' : ''; | ||
const message = `Do not import directly from '${origin}'. Please use '${destination}'${autofixMessage}.`; | ||
context.report({ | ||
@@ -42,3 +47,3 @@ node, | ||
fix(fixer) { | ||
if (node && destination) { | ||
if (node && applyAutofix && destination) { | ||
return fixer.replaceText(node.source, `'${destination}'`); | ||
@@ -45,0 +50,0 @@ } |
{ | ||
"name": "eslint-plugin-uilib", | ||
"version": "1.0.28", | ||
"version": "1.0.30", | ||
"description": "uilib set of eslint rules", | ||
@@ -10,3 +10,3 @@ "keywords": [ | ||
], | ||
"author": "Tnbal Tish <inbalti@wix.com>", | ||
"author": "Inbal Tish <inbalti@wix.com>", | ||
"license": "MIT", | ||
@@ -13,0 +13,0 @@ "publishConfig": { |
const RuleTester = require('eslint').RuleTester; | ||
const rule = require('../../../lib/rules/no-direct-import'); | ||
const ruleOptions = [{ origin: 'some-module', destination: 'another-module' }]; | ||
const ruleOptions = [{origin: 'some-module', destination: 'another-module', applyAutofix: true}]; | ||
RuleTester.setDefaultConfig({ | ||
parser: 'babel-eslint', | ||
parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } }, | ||
parserOptions: {ecmaVersion: 6, ecmaFeatures: {jsx: true}} | ||
}); | ||
@@ -20,4 +20,4 @@ | ||
options: ruleOptions, | ||
code: validExample, | ||
}, | ||
code: validExample | ||
} | ||
], | ||
@@ -30,6 +30,6 @@ invalid: [ | ||
errors: [ | ||
{ message: `Do not import directly from 'some-module'. Please use 'another-module' (autofix available).` }, | ||
], | ||
}, | ||
], | ||
{message: `Do not import directly from 'some-module'. Please use 'another-module' (autofix available).`} | ||
] | ||
} | ||
] | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89194
2542