mirror of
https://github.com/bendtherules/eslint-plugin-no-classname-with-stylename.git
synced 2026-08-18 22:03:28 +00:00
Add basic eslint project with working logic
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @fileoverview Disallow string className alongwith styleName in the same JSX tag
|
||||
* @author Abhas Bhattacharya
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var rule = require("../../../lib/rules/no-classname-with-stylename"),
|
||||
|
||||
RuleTester = require("eslint").RuleTester;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Tests
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
}
|
||||
});
|
||||
ruleTester.run("no-classname-with-stylename", rule, {
|
||||
|
||||
valid: [
|
||||
"<span styleName='my-card' />",
|
||||
"<span className='card' />",
|
||||
"<span className={123} styleName='my-card' />",
|
||||
"<span className={'card'} styleName='my-card' />",
|
||||
"<span className={true ? 'card' : 'no-card'} styleName='my-card' />"
|
||||
// give me some code that won't trigger a warning
|
||||
],
|
||||
|
||||
invalid: [
|
||||
{
|
||||
code: "<span className='card' styleName={true ? 'my-card' : 'not-my-card'} />",
|
||||
errors: [{
|
||||
// message: "Disallow string className alongwith styleName in the same JSX tag",
|
||||
}]
|
||||
},
|
||||
{
|
||||
code: "<span className styleName='my-card' />",
|
||||
errors: [{
|
||||
// message: "Disallow string className alongwith styleName in the same JSX tag",
|
||||
}]
|
||||
},
|
||||
{
|
||||
code: "<span className='card' styleName='my-card' />",
|
||||
errors: [{
|
||||
// message: "Disallow string className alongwith styleName in the same JSX tag",
|
||||
}]
|
||||
}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user