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

eslint-plugin-filename-rules

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-filename-rules - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/common/aliases.js

2

lib/index.js
const match = require('./match');
const notMatch = require('./notMatch');

@@ -6,3 +7,4 @@ module.exports = {

match,
'not-match': notMatch,
},
};

35

lib/match.js
const path = require('path');
const { getRegex } = require('./common/getRegex');

@@ -14,27 +15,2 @@ const meta = {

const aliases = {
pascalcase: /^[A-Z]([A-Z0-9]*[a-z]+)+[A-Z0-9]*(?:\..*)?$/,
camelcase: /^[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?(?:\..*)?$/,
snakecase: /^([a-z]+_)*[a-z]+(?:\..*)?$/,
kebabcase: /^([a-z]+-)*[a-z]+(?:\..*)?$/,
};
aliases.PascalCase = aliases.pascalcase;
aliases.camelCase = aliases.camelcase;
aliases.snake_case = aliases.snakecase;
aliases['kebab-case'] = aliases.kebabcase;
const getRegex = (value, filename) => {
if (value instanceof RegExp) return [value, value.toString()];
if (typeof value === 'string') {
const regex = aliases[value];
if (!regex) throw new Error(`Unrecognized option "${value}"`);
return [regex, value];
}
const extension = filename.substr(filename.lastIndexOf('.'));
const valueForExtension = value[extension];
return valueForExtension ? getRegex(valueForExtension) : [];
};
module.exports = {

@@ -45,6 +21,7 @@ meta,

const filename = context.getFilename();
const basename = path.basename(filename);
const [regex, regexStr] = getRegex(context.options[0], basename);
const includePath = !!(context.options[0] || {}).includePath;
const name = includePath ? filename : path.basename(filename);
const [regex, regexStr] = getRegex(context.options[0], name);
if (!regex) return;
if (!regex.test(basename)) {
if (!regex.test(name)) {
context.report({

@@ -54,3 +31,3 @@ node,

data: {
name: basename,
name,
value: regexStr,

@@ -57,0 +34,0 @@ },

{
"name": "eslint-plugin-filename-rules",
"version": "1.2.0",
"version": "1.3.0",
"description": "Enforce filename conventions for linted files",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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