Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylelint-vnmf-rn

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylelint-vnmf-rn - npm Package Compare versions

Comparing version 1.0.2 to 3.5.6

5

dist/index.js

@@ -7,6 +7,11 @@ "use strict";

exports.default = void 0;
var _stylelint = require("stylelint");
var _rules = _interopRequireDefault(require("./rules"));
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const rulesPlugins = Object.keys(_rules.default).map(ruleName => {

@@ -13,0 +18,0 @@ return (0, _stylelint.createPlugin)((0, _utils.namespace)(ruleName), _rules.default[ruleName]);

@@ -8,12 +8,20 @@ "use strict";

exports.ruleName = exports.messages = void 0;
var _reactNativeKnownStylingProperties = require("react-native-known-styling-properties");
var _stylelint = require("stylelint");
var _utils = require("../../utils");
const ruleName = (0, _utils.namespace)('css-property-no-unknown');
exports.ruleName = ruleName;
const messages = _stylelint.utils.ruleMessages(ruleName, {
rejected: property => `无效的 React Native 样式属性 "${property}"`
});
exports.messages = messages;
const props = _reactNativeKnownStylingProperties.allCSS2RNProps.map(_utils.kebabCase);
function _default(actual, options) {

@@ -30,25 +38,34 @@ return function (root, result) {

});
if (!validOptions) {
return;
}
root.walkDecls(decl => {
const prop = decl.prop;
if (!(0, _utils.isStandardSyntaxProperty)(prop)) {
return;
}
if (!(0, _utils.isStandardSyntaxDeclaration)(decl)) {
return;
}
if ((0, _utils.isCustomProperty)(prop)) {
return;
}
if ((0, _utils.isExportBlock)(decl.parent)) {
return;
}
if ((0, _utils.optionsMatches)(options, 'ignoreProperties', prop)) {
return;
}
if (props.indexOf(prop.toLowerCase()) !== -1) {
return;
}
_stylelint.utils.report({

@@ -55,0 +72,0 @@ message: messages.rejected(prop),

@@ -8,12 +8,19 @@ "use strict";

exports.ruleName = exports.messages = void 0;
var _stylelint = require("stylelint");
var _utils = require("../../utils");
const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex');
const ruleName = (0, _utils.namespace)('font-weight-no-ignored-values');
exports.ruleName = ruleName;
const messages = _stylelint.utils.ruleMessages(ruleName, {
rejected: weight => `Unexpected font-weight "${weight}"`
});
exports.messages = messages;
const acceptedWeights = ['400', '700', 'normal', 'bold'];
function _default(actual) {

@@ -24,5 +31,7 @@ return function (root, result) {

});
if (!validOptions) {
return;
}
root.walkDecls(/^font-weight$/i, decl => {

@@ -32,4 +41,6 @@ if (acceptedWeights.indexOf(decl.value) > -1) {

}
const weightValueOffset = decl.value.indexOf(decl.value);
const index = declarationValueIndex(decl) + weightValueOffset;
_stylelint.utils.report({

@@ -36,0 +47,0 @@ message: messages.rejected(decl.value),

@@ -7,7 +7,13 @@ "use strict";

exports.default = void 0;
var _cssPropertyNoUnknown = _interopRequireDefault(require("./css-property-no-unknown"));
var _fontWeightNoIgnoredValues = _interopRequireDefault(require("./font-weight-no-ignored-values"));
var _lineHeightNoValueWithoutUnit = _interopRequireDefault(require("./line-height-no-value-without-unit"));
var _stylePropertyNoUnknown = _interopRequireDefault(require("./style-property-no-unknown"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {

@@ -14,0 +20,0 @@ 'font-weight-no-ignored-values': _fontWeightNoIgnoredValues.default,

@@ -8,13 +8,20 @@ "use strict";

exports.ruleName = exports.messages = void 0;
var _stylelint = require("stylelint");
var _utils = require("../../utils");
const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex');
const ruleName = (0, _utils.namespace)('line-height-no-value-without-unit');
exports.ruleName = ruleName;
const messages = _stylelint.utils.ruleMessages(ruleName, {
rejected: height => `Unexpected line-height "${height}", expect a value with units`
});
exports.messages = messages;
const lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px|PX|rem$))/;
const viewportUnitRe = /^([+-]?[0-9.]+)(vh|vw|vmin|vmax)$/;
function _default(actual) {

@@ -25,5 +32,7 @@ return function (root, result) {

});
if (!validOptions) {
return;
}
root.walkDecls(/^line-height$/i, decl => {

@@ -33,4 +42,6 @@ if (lengthRe.test(decl.value) || viewportUnitRe.test(decl.value)) {

}
const valueOffset = decl.value.indexOf(decl.value);
const index = declarationValueIndex(decl) + valueOffset;
_stylelint.utils.report({

@@ -37,0 +48,0 @@ message: messages.rejected(decl.value),

@@ -8,12 +8,20 @@ "use strict";

exports.ruleName = exports.messages = void 0;
var _reactNativeKnownStylingProperties = require("react-native-known-styling-properties");
var _stylelint = require("stylelint");
var _utils = require("../../utils");
const ruleName = (0, _utils.namespace)('style-property-no-unknown');
exports.ruleName = ruleName;
const messages = _stylelint.utils.ruleMessages(ruleName, {
rejected: property => `无效的 React Native 样式属性 "${property}"`
});
exports.messages = messages;
const props = _reactNativeKnownStylingProperties.allProps.map(_utils.kebabCase);
function _default(actual, options) {

@@ -30,22 +38,30 @@ return function (root, result) {

});
if (!validOptions) {
return;
}
root.walkDecls(decl => {
const prop = decl.prop;
if (!(0, _utils.isStandardSyntaxProperty)(prop)) {
return;
}
if (!(0, _utils.isStandardSyntaxDeclaration)(decl)) {
return;
}
if ((0, _utils.isCustomProperty)(prop)) {
return;
}
if ((0, _utils.optionsMatches)(options, 'ignoreProperties', prop)) {
return;
}
if (props.indexOf(prop.toLowerCase()) !== -1) {
return;
}
_stylelint.utils.report({

@@ -52,0 +68,0 @@ message: messages.rejected(prop),

2

dist/utils/endsWith.js

@@ -7,3 +7,5 @@ "use strict";

exports.endsWith = void 0;
const endsWith = (str, suffix) => str.indexOf(suffix, str.length - suffix.length) !== -1;
exports.endsWith = endsWith;

17

dist/utils/hasInterpolation.js
"use strict";
const hasLessInterpolation = require('./hasLessInterpolation');
const hasPsvInterpolation = require('./hasPsvInterpolation');
const hasScssInterpolation = require('./hasScssInterpolation');
const hasLessInterpolation = require('../utils/hasLessInterpolation');
const hasPsvInterpolation = require('../utils/hasPsvInterpolation');
const hasScssInterpolation = require('../utils/hasScssInterpolation');
/**

@@ -12,3 +14,9 @@ * Check whether a string has interpolation

*/
module.exports = function (string /*: string */) /*: boolean */{
module.exports = function (string
/*: string */
)
/*: boolean */
{
// SCSS or Less interpolation

@@ -18,3 +26,4 @@ if (hasLessInterpolation(string) || hasScssInterpolation(string) || hasPsvInterpolation(string)) {

}
return false;
};

@@ -9,7 +9,12 @@ "use strict";

*/
module.exports = function (string /*: string */) /*: boolean */{
module.exports = function (string
/*: string */
)
/*: boolean */
{
if (/@{.+?}/.test(string)) {
return true;
}
return false;
};

@@ -6,7 +6,12 @@ "use strict";

*/
module.exports = function (string /*: string */) /*: boolean */{
module.exports = function (string
/*: string */
)
/*: boolean */
{
if (/\$\(.+?\)/.test(string)) {
return true;
}
return false;
};

@@ -6,7 +6,12 @@ "use strict";

*/
module.exports = function (string /*: string */) /*: boolean */{
module.exports = function (string
/*: string */
)
/*: boolean */
{
if (/#{.+?}/.test(string)) {
return true;
}
return false;
};

@@ -60,10 +60,19 @@ "use strict";

});
var _endsWith = require("./endsWith");
var _isCustomProperty = require("./isCustomProperty");
var _isExportBlock = require("./isExportBlock");
var _isStandardSyntaxDeclaration = require("./isStandardSyntaxDeclaration");
var _isStandardSyntaxProperty = require("./isStandardSyntaxProperty");
var _isString = require("./isString");
var _kebabCase = require("./kebabCase");
var _namespace = require("./namespace");
var _optionsMatches = require("./optionsMatches");

@@ -7,7 +7,12 @@ "use strict";

exports.isCustomProperty = isCustomProperty;
/**
* Check whether a property is a custom one
*/
function isCustomProperty(property /*: string */) /*: boolean */{
function isCustomProperty(property
/*: string */
)
/*: boolean */
{
return property.slice(0, 2) === '--';
}

@@ -7,10 +7,16 @@ "use strict";

exports.isExportBlock = isExportBlock;
/**
* Check whether a node is an :export block
*/
function isExportBlock(node /*: Object */) /*: boolean */{
function isExportBlock(node
/*: Object */
)
/*: boolean */
{
if (node.type === 'rule' && node.selector && node.selector === ':export') {
return true;
}
return false;
}

@@ -7,30 +7,34 @@ "use strict";

exports.isStandardSyntaxDeclaration = isStandardSyntaxDeclaration;
/**
* Check whether a declaration is standard
*/
function isStandardSyntaxDeclaration(decl /*: Object */) /*: boolean */{
function isStandardSyntaxDeclaration(decl
/*: Object */
)
/*: boolean */
{
const prop = decl.prop;
const parent = decl.parent;
const parent = decl.parent; // Declarations belong in a declaration block
// Declarations belong in a declaration block
if (parent.type === 'root') {
return false;
}
} // Sass var (e.g. $var: x), nested list (e.g. $list: (x)) or nested map (e.g. $map: (key:value))
// Sass var (e.g. $var: x), nested list (e.g. $list: (x)) or nested map (e.g. $map: (key:value))
if (prop[0] === '$') {
return false;
}
} // Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
// Less var (e.g. @var: x), but exclude variable interpolation (e.g. @{var})
if (prop[0] === '@' && prop[1] !== '{') {
return false;
}
} // Sass nested properties (e.g. border: { style: solid; color: red; })
// Sass nested properties (e.g. border: { style: solid; color: red; })
if (parent.selector && parent.selector[parent.selector.length - 1] === ':' && parent.selector.substring(0, 2) !== '--') {
return false;
}
return true;
}

@@ -7,29 +7,37 @@ "use strict";

exports.isStandardSyntaxProperty = isStandardSyntaxProperty;
var _endsWith = require("./endsWith");
const hasInterpolation = require('./hasInterpolation');
const hasInterpolation = require('../utils/hasInterpolation');
/**
* Check whether a property is standard
*/
function isStandardSyntaxProperty(property /*: string */) /*: boolean */{
function isStandardSyntaxProperty(property
/*: string */
)
/*: boolean */
{
// SCSS var (e.g. $var: x), list (e.g. $list: (x)) or map (e.g. $map: (key:value))
if (property[0] === '$') {
return false;
}
} // Less var (e.g. @var: x)
// Less var (e.g. @var: x)
if (property[0] === '@') {
return false;
}
} // Less append property value with space (e.g. transform+_: scale(2))
// Less append property value with space (e.g. transform+_: scale(2))
if ((0, _endsWith.endsWith)(property, '+') || (0, _endsWith.endsWith)(property, '+_')) {
return false;
}
} // SCSS or Less interpolation
// SCSS or Less interpolation
if (hasInterpolation(property)) {
return false;
}
return true;
}

@@ -7,3 +7,5 @@ "use strict";

exports.isString = void 0;
const isString = string => typeof string === 'string';
exports.isString = isString;

@@ -7,3 +7,5 @@ "use strict";

exports.kebabCase = void 0;
const kebabCase = string => string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
exports.kebabCase = kebabCase;

@@ -7,2 +7,3 @@ "use strict";

exports.matchesStringOrRegExp = matchesStringOrRegExp;
/**

@@ -16,8 +17,16 @@ * Compares a string to a second value that, if it fits a certain convention,

*/
function matchesStringOrRegExp(input /*: string | Array<string> */, comparison /*: string | Array<string> */) /*: false | { match: string, pattern: string } */{
function matchesStringOrRegExp(input
/*: string | Array<string> */
, comparison
/*: string | Array<string> */
)
/*: false | { match: string, pattern: string } */
{
if (!Array.isArray(input)) {
return testAgainstStringOrRegExpOrArray(input, comparison);
}
for (const inputItem of input) {
const testResult = testAgainstStringOrRegExpOrArray(inputItem, comparison);
if (testResult) {

@@ -27,4 +36,6 @@ return testResult;

}
return false;
}
function testAgainstStringOrRegExpOrArray(value, comparison) {

@@ -34,4 +45,6 @@ if (!Array.isArray(comparison)) {

}
for (const comparisonItem of comparison) {
const testResult = testAgainstStringOrRegExp(value, comparisonItem);
if (testResult) {

@@ -41,4 +54,6 @@ return testResult;

}
return false;
}
function testAgainstStringOrRegExp(value, comparison) {

@@ -51,5 +66,5 @@ // If it's a RegExp, test directly

} : false;
}
} // Check if it's RegExp in a string
// Check if it's RegExp in a string
const firstComparisonChar = comparison[0];

@@ -59,5 +74,4 @@ const lastComparisonChar = comparison[comparison.length - 1];

const comparisonIsRegex = firstComparisonChar === '/' && (lastComparisonChar === '/' || secondToLastComparisonChar === '/' && lastComparisonChar === 'i');
const hasCaseInsensitiveFlag = comparisonIsRegex && lastComparisonChar === 'i';
const hasCaseInsensitiveFlag = comparisonIsRegex && lastComparisonChar === 'i'; // If so, create a new RegExp from it
// If so, create a new RegExp from it
if (comparisonIsRegex) {

@@ -69,5 +83,5 @@ const valueMatches = hasCaseInsensitiveFlag ? new RegExp(comparison.slice(1, -2), 'i').test(value) : new RegExp(comparison.slice(1, -1)).test(value);

} : false;
}
} // Otherwise, it's a string. Do a strict comparison
// Otherwise, it's a string. Do a strict comparison
return value === comparison ? {

@@ -74,0 +88,0 @@ match: value,

@@ -8,4 +8,5 @@ "use strict";

const prefix = 'vnmf-rn';
function namespace(ruleName) {
return `${prefix}/${ruleName}`;
}

@@ -7,3 +7,5 @@ "use strict";

exports.optionsMatches = optionsMatches;
var _matchesStringOrRegExp = require("./matchesStringOrRegExp");
/**

@@ -13,4 +15,12 @@ * Check if an options object's propertyName contains a user-defined string or

*/
function optionsMatches(options /*: Object */, propertyName /*: string */, input /*: string */) /*: boolean */{
function optionsMatches(options
/*: Object */
, propertyName
/*: string */
, input
/*: string */
)
/*: boolean */
{
return !!(options && options[propertyName] && typeof input === 'string' && (0, _matchesStringOrRegExp.matchesStringOrRegExp)(input, options[propertyName]));
}
{
"name": "stylelint-vnmf-rn",
"description": "A collection of React Native specific rules for stylelint",
"version": "1.0.2",
"version": "3.5.6",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "files": [

@@ -1,4 +0,4 @@

const hasLessInterpolation = require('./hasLessInterpolation')
const hasPsvInterpolation = require('./hasPsvInterpolation')
const hasScssInterpolation = require('./hasScssInterpolation')
const hasLessInterpolation = require('../utils/hasLessInterpolation')
const hasPsvInterpolation = require('../utils/hasPsvInterpolation')
const hasScssInterpolation = require('../utils/hasScssInterpolation')
/**

@@ -5,0 +5,0 @@ * Check whether a string has interpolation

import { endsWith } from './endsWith'
const hasInterpolation = require('./hasInterpolation')
const hasInterpolation = require('../utils/hasInterpolation')

@@ -5,0 +5,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc