@trenskow/caseit 1.3.14 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.js +45 -0
- package/index.js +6 -6
- package/package.json +6 -2
- package/.eslintrc.js +0 -48
package/eslint.config.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import js from "@eslint/js";
|
|
5
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [...compat.extends("eslint:recommended"), {
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: {
|
|
18
|
+
...globals.node,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
ecmaVersion: 2017,
|
|
22
|
+
sourceType: "module",
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
rules: {
|
|
26
|
+
indent: ["error", "tab"],
|
|
27
|
+
"linebreak-style": ["error", "unix"],
|
|
28
|
+
quotes: ["error", "single"],
|
|
29
|
+
semi: ["error", "always"],
|
|
30
|
+
|
|
31
|
+
"no-console": ["error", {
|
|
32
|
+
allow: ["warn", "error", "info"],
|
|
33
|
+
}],
|
|
34
|
+
|
|
35
|
+
"no-unused-vars": ["error", {
|
|
36
|
+
argsIgnorePattern: "^_",
|
|
37
|
+
}],
|
|
38
|
+
|
|
39
|
+
"no-empty": ["error", {
|
|
40
|
+
allowEmptyCatch: true,
|
|
41
|
+
}],
|
|
42
|
+
|
|
43
|
+
"require-atomic-updates": "off",
|
|
44
|
+
},
|
|
45
|
+
}];
|
package/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const separators = {
|
|
4
2
|
'camel': '',
|
|
5
3
|
'pascal': '',
|
|
@@ -12,7 +10,7 @@ const separators = {
|
|
|
12
10
|
|
|
13
11
|
const supported = Object.keys(separators).sort();
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
const caseit = function(input, type = 'camel') {
|
|
16
14
|
|
|
17
15
|
if (!supported.includes(type)) {
|
|
18
16
|
throw new TypeError(`Type must either be ${supported.slice(0, -1).join(', ')} or ${supported.slice(-1)[0]}.`);
|
|
@@ -43,15 +41,17 @@ module.exports = exports = function(input, type = 'camel') {
|
|
|
43
41
|
|
|
44
42
|
};
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
caseit.words = function(input) {
|
|
47
45
|
return input.split(/(?=[A-Z])|_|-| |\./)
|
|
48
46
|
.filter((key) => key.length)
|
|
49
47
|
.map((word) => word.toLowerCase());
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
caseit.detect = function(input) {
|
|
53
51
|
return supported
|
|
54
52
|
.filter((type) => exports(input, type) === input);
|
|
55
53
|
};
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
caseit.supported = supported;
|
|
56
|
+
|
|
57
|
+
export default caseit;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trenskow/caseit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Small library for converting between different casing.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
9
|
},
|
|
@@ -22,6 +23,9 @@
|
|
|
22
23
|
},
|
|
23
24
|
"homepage": "https://github.com/trenskow/caseit#readme",
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"eslint": "^
|
|
26
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
27
|
+
"@eslint/js": "^9.13.0",
|
|
28
|
+
"eslint": "^9.13.0",
|
|
29
|
+
"globals": "^15.11.0"
|
|
26
30
|
}
|
|
27
31
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
'env': {
|
|
3
|
-
'es6': true,
|
|
4
|
-
'node': true
|
|
5
|
-
},
|
|
6
|
-
'parserOptions': {
|
|
7
|
-
'ecmaVersion': 2017
|
|
8
|
-
},
|
|
9
|
-
'extends': 'eslint:recommended',
|
|
10
|
-
'rules': {
|
|
11
|
-
'indent': [
|
|
12
|
-
'error',
|
|
13
|
-
'tab'
|
|
14
|
-
],
|
|
15
|
-
'linebreak-style': [
|
|
16
|
-
'error',
|
|
17
|
-
'unix'
|
|
18
|
-
],
|
|
19
|
-
'quotes': [
|
|
20
|
-
'error',
|
|
21
|
-
'single'
|
|
22
|
-
],
|
|
23
|
-
'semi': [
|
|
24
|
-
'error',
|
|
25
|
-
'always'
|
|
26
|
-
],
|
|
27
|
-
'no-console': [
|
|
28
|
-
'error', {
|
|
29
|
-
'allow': [
|
|
30
|
-
'warn',
|
|
31
|
-
'error',
|
|
32
|
-
'info'
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
'no-unused-vars': [
|
|
37
|
-
'error', {
|
|
38
|
-
'argsIgnorePattern': '^_'
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
'no-empty': [
|
|
42
|
-
'error', {
|
|
43
|
-
'allowEmptyCatch': true
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
'require-atomic-updates': 'off'
|
|
47
|
-
}
|
|
48
|
-
};
|