Skip to content

Commit c9145c1

Browse files
committed
[Release] v1.1.0
1 parent a0e0070 commit c9145c1

9 files changed

Lines changed: 87 additions & 713 deletions

File tree

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
"no-constant-condition": [
4242
"warn"
4343
],
44-
"snakecasejs/snakecasejs": "warn"
44+
"curly": ["error", "all"],
45+
"brace-style": ["error", "1tbs",
46+
{
47+
"allowSingleLine": false
48+
}],
49+
"snakecasejs/snakecasejs": "warn",
50+
"snakecasejs/whitelist": []
4551
}
4652
}

AUTHORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# David Buchan-Swanson david.buchanswanson@gmail.com
1111
[![https://github.com/deecewan](https://avatars0.githubusercontent.com/u/4755785?s=150&v=4)](https://github.com/deecewan)
1212

13-
`Developer - Jan 12, 2017`
13+
`Original Developer - Jan 12, 2017`
1414
* GitHub: [https://github.com/deecewan](https://github.com/deecewan)

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.1.0 (October 01, 2018)
2+
3+
* Feature: whitelist array on `eslintrc.json`
4+
* License: now is MIT
5+
6+
17
# v1.0.1 (June 02, 2018)
28

39
* New: logo from [freepik](https://it.freepik.com/) (premium account)

INSTALL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"eslint": "^4.19.1",
66
},
77
"devDependencies": {
8-
"eslint-plugin-snakecasejs": "^1.0.0",
8+
"eslint-plugin-snakecasejs": "^1.1.0",
99
}
1010
```
1111
2. Create `.eslintrc.json` file with:
@@ -16,7 +16,8 @@
1616
],
1717
"rules":
1818
{
19-
"snakecasejs/snakecasejs": "error"
19+
"snakecasejs/snakecasejs": "error",
20+
"snakecasejs/whitelist": []
2021
}
2122
}
2223
```

LICENSE

Lines changed: 21 additions & 674 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
<p align="center"><a href="https://www.npmjs.com/package/eslint-plugin-snakecasejs" alt="Logo"><img src="https://ptkdev.it/img/github/eslintplugin_snakecasejs.png"></a></p>
1+
[![](https://ptkdev.it/img/github/eslintplugin_snakecasejs.png)](https://www.npmjs.com/package/eslint-plugin-snakecasejs)
22

3-
<p align="center"><h1 align="center">ESLint Plugin snake_case.js</h1></p>
3+
# ESLint Plugin snakecasejs
44

5-
<p align="center"><a href="#" alt="License"><img src="https://img.shields.io/badge/license-GLPv3-brightgreen.svg"></a>
6-
<a href="https://www.npmjs.com/package/eslint" alt="powered by eslint"><img src="https://img.shields.io/badge/powered%20by-eslint-46aef7.svg"></a>
7-
<a href="https://github.com/ptkdev/eslint-plugin-snakecasejs/releases" alt="Version"><img src="https://img.shields.io/badge/version-v1.0.1-lightgrey.svg"></a>
8-
<a href="https://slack.ptkdev.io" alt="Slack Chat"><img src="https://img.shields.io/badge/chat%20on-slack-orange.svg"></a>
9-
<a href="http://blog.ptkdev.io" alt="Blog"><img src="https://img.shields.io/badge/blog-medium-2AE176.svg"></a>
10-
<a href="https://twitter.com/ptkdevio" alt="Twitter"><img src="https://img.shields.io/badge/twitter-ptkdevio-2AA3EF.svg"></a>
11-
<a href="mailto:support@ptkdev.io" alt="Support: support@ptkdev.io"><img src="https://img.shields.io/badge/help-support@ptkdev.io-fbbc05.svg"></a></p>
12-
<p align="center"><a href="http://patreon.ptkdev.io" alt="Patreon Backer"><img src="https://img.shields.io/badge/donate-patreon-F87668.svg"></a> <a href="http://paypal.ptkdev.io" alt="Paypale Donate"><img src="https://img.shields.io/badge/donate-paypal-46AFE0.svg"></a></p>
5+
[![](https://img.shields.io/badge/license-MIT-brightgreen.svg)](#) [![](https://img.shields.io/badge/powered%20by-eslint-46aef7.svg)](https://www.npmjs.com/package/eslint) [![](https://img.shields.io/badge/version-v1.1.0-lightgrey.svg)](https://github.com/social-manager-tools/instagram-bot.js/archive/master.zip) [![](https://img.shields.io/badge/chat%20on-slack-orange.svg)](http://slack.ptkdev.io) [![](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](http://discord.ptkdev.io) [![](https://img.shields.io/badge/blog-medium-2AE176.svg)](http://blog.ptkdev.io) [![](https://img.shields.io/badge/twitter-ptkdevio-2AA3EF.svg)](https://twitter.com/ptkdevio)
6+
7+
[![](https://img.shields.io/badge/donate-patreon-F87668.svg)](http://patreon.ptkdev.io) [![](https://img.shields.io/badge/donate-paypal-46AFE0.svg)](http://paypal.ptkdev.io) [![](https://img.shields.io/badge/buy%20me-coffee-4B788C.svg)](http://coffee.ptkdev.io) [![](https://img.shields.io/badge/help-support@ptkdev.io-fbbc05.svg)](mailto:support@ptkdev.io)
138

149
## What does it do
1510
This is to enforce a style of snake_case in your project, rather than just disabling camelcase.
1611

1712
## Features
1813
* [] Easy to use
14+
* [] MIT License
1915
* [] Compatible with last version of ESLint
2016
* [] Compatible with CamelCase (Class name or similar)
17+
* [] Whitelist array for methods or variables with camelCase syntax from other libraries/npm package.
2118

2219
## Fast setup
2320
1. Add dependencies on `package.json`
@@ -26,7 +23,7 @@ This is to enforce a style of snake_case in your project, rather than just disab
2623
"eslint": "^4.19.1",
2724
},
2825
"devDependencies": {
29-
"eslint-plugin-snakecasejs": "^1.0.0",
26+
"eslint-plugin-snakecasejs": "^1.1.0",
3027
}
3128
```
3229
2. Create `.eslintrc.json` file with:
@@ -37,19 +34,25 @@ This is to enforce a style of snake_case in your project, rather than just disab
3734
],
3835
"rules":
3936
{
40-
"snakecasejs/snakecasejs": "error"
37+
"snakecasejs/snakecasejs": "error",
38+
"snakecasejs/whitelist": []
4139
}
4240
}
4341
```
44-
3. If work add star :star: at this project :heart:
45-
4. If you want help me: <b><a href="http://paypal.ptkdev.io"></b>donate on paypal</a> or become a <b><a href="http://patreon.ptkdev.io">backer on patreon</a></b>.
42+
3. If it works add a star :star: at this project :heart:
43+
4. If you want to help me: **[donate on paypal](http://paypal.ptkdev.io)** or become a **[backer on patreon](http://patreon.ptkdev.io)**.
4644

4745
NOTE: switch `error` to `warn` if you don't need snake_case as mandatory rules.
4846

4947
For advanced configuration see [INSTALL.md](https://github.com/ptkdev/eslint-plugin-snakecasejs/blob/master/INSTALL.md).
5048

51-
<h1>License</h1>
49+
## Ignore words, variables, methods, class name (whitelist)
50+
Add rules: `"snakecasejs/whitelist": []` with array of variables or method with camelCase syntax.
51+
52+
Plugin ignore check on this words. Example: `"snakecasejs/whitelist": ["externalPath","setNumber"]`
53+
54+
# License
5255

53-
GNU GENERAL PUBLIC LICENSE
56+
MIT LICENSE
5457

5558
Copyright (c) 2018 Patryk Rzucidło (PTKDev)

index.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
*
66
* @author: Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)
77
* @original: David Buchan-Swanson <david.buchanswanson@gmail.com>
8-
* @license: This code and contributions have 'GNU General Public License v3'
9-
* @version: 0.1
10-
* @changelog: 0.1 initial release
8+
* @license: This code and contributions have 'MIT License'
9+
* @version: 1.1.0
10+
* @changelog: 1.0.0 initial release
11+
* 1.1.0 add whitelist
1112
*
1213
*/
13-
function is_class_usage(node) {
14-
return ["FunctionDeclaration", "NewExpression", "MemberExpression"].indexOf(node.parent.type) > -1;
14+
let eslintrc = null;
15+
try {
16+
eslintrc = require("./../../.eslintrc");
17+
} catch (err) {
18+
eslintrc = [];
1519
}
1620

17-
function contains(a, obj) {
18-
for (var i = 0; i < a.length; i++) {
19-
if (a[i] === obj) {
20-
return true;
21-
}
22-
}
23-
return false;
21+
function is_class_usage(node) {
22+
return ["FunctionDeclaration", "NewExpression", "MemberExpression"].indexOf(node.parent.type) > -1;
2423
}
2524

2625
module.exports = {
@@ -33,10 +32,10 @@ module.exports = {
3332
return {
3433
Identifier(node) {
3534
var name = node.name;
36-
var array_system_var = ["parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "indexOf", "forEach", "charAt", "charCodeAt", "endsWith", "lastIndexOf", "startsWith", "toLowerCase", "toLocaleLowerCase", "toUpperCase", "toLocaleUpperCase", "toFixed", "toPrecision", "setInterval", "clearInterval", "setTimeout", "toDateString", "toTimeString", "getTime", "getFullYear", "getUTCFullYear", "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay", "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds", "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "getTimeZoneOffset", "setTime", "setMilliseconds", "setUTCMilliseconds", "setSeconds", "setUTCSeconds", "setMinutes", "setUTCMinutes", "setHours", "setUTCHours", "setDate", "setUTCDate", "setMonth", "setUTCMonth", "setFullYear", "setUTCFullYear", "toUTCString", "toISOString", "toJSON", "executablePath"];
35+
var array_system_var = ["parseInt", "parseFloat", "isNaN", "isFinite", "decodeURI", "decodeURIComponent", "encodeURI", "toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "indexOf", "forEach", "charAt", "charCodeAt", "endsWith", "lastIndexOf", "startsWith", "toLowerCase", "toLocaleLowerCase", "toUpperCase", "toLocaleUpperCase", "toFixed", "toPrecision", "setInterval", "clearInterval", "setTimeout", "toDateString", "toTimeString", "getTime", "getFullYear", "getUTCFullYear", "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay", "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds", "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "getTimeZoneOffset", "setTime", "setMilliseconds", "setUTCMilliseconds", "setSeconds", "setUTCSeconds", "setMinutes", "setUTCMinutes", "setHours", "setUTCHours", "setDate", "setUTCDate", "setMonth", "setUTCMonth", "setFullYear", "setUTCFullYear", "toUTCString", "toISOString", "toJSON"];
3736
var split = name.split(/(?=[A-Z])/);
3837
var split_az = name.split(/(?=[a-z])/);
39-
if ((split.length > 1 && split_az.length > 1) && !contains(array_system_var, name)) {
38+
if ((split.length > 1 && split_az.length > 1) && !array_system_var.includes(name) && !eslintrc.rules["snakecasejs/whitelist"].includes(name)) {
4039
if (is_class_usage(node)) {
4140
return true;
4241
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-snakecasejs",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"main": "index.js",
55
"author": "Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)",
66
"author_original": "David Buchan-Swanson <david.buchanswanson@gmail.com>",
@@ -43,8 +43,8 @@
4343
"eslint-plugin-import": "^2.11.0",
4444
"eslint-plugin-node": "^6.0.1",
4545
"eslint-plugin-promise": "^3.7.0",
46-
"eslint-plugin-snakecasejs": "^1.0.0",
46+
"eslint-plugin-snakecasejs": "^1.1.0",
4747
"eslint-plugin-standard": "^3.1.0",
4848
"pre-commit": "^1.2.2"
4949
}
50-
}
50+
}

test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
/**
2+
* snakecasejs
3+
* =====================
4+
* This is to enforce a style of snake_case in your project, rather than just disabling camelcase.
5+
*
6+
* @author: Patryk Rzucidlo [@ptkdev] <support@ptkdev.io> (https://ptkdev.it)
7+
* @original: David Buchan-Swanson <david.buchanswanson@gmail.com>
8+
* @license: This code and contributions have 'MIT License'
9+
* @version: 1.0.0
10+
* @changelog: 1.0.0 initial release
11+
*
12+
*/
113
var rule_tester = require("eslint").RuleTester;
2-
var rule = require("./").rules.snakecase;
14+
var rule = require("./index");
315

416
var rule_tester_run = new rule_tester();
5-
rule_tester_run.run("snake_case", rule, {
17+
rule_tester_run.run("snakecasejs", rule, {
618
valid: [
719
"var snake_case = true;",
820
"function another_snake_case(){}",

0 commit comments

Comments
 (0)