@awesomeness-js/utils 1.2.5 → 1.2.7

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 CHANGED
@@ -1,22 +1,33 @@
1
1
  export default [
2
- // Here is where we fix "padding-line-between-statements"
3
2
  {
4
3
  rules: {
4
+ // Ignore ALL line-break rules around import statements ONLY
5
5
  'padding-line-between-statements': [
6
6
  'error',
7
- // Insert a blank line **before** any block-like statement
7
+
8
+ // imports are exempt
9
+ {
10
+ blankLine: 'any',
11
+ prev: 'import',
12
+ next: '*'
13
+ },
14
+ {
15
+ blankLine: 'any',
16
+ prev: '*',
17
+ next: 'import'
18
+ },
19
+
20
+ // everything else still padded like before
8
21
  {
9
22
  blankLine: 'always',
10
23
  prev: '*',
11
24
  next: 'block-like'
12
25
  },
13
- // Insert a blank line **after** any block-like statement
14
26
  {
15
27
  blankLine: 'always',
16
28
  prev: 'block-like',
17
29
  next: '*'
18
30
  },
19
- // Keep the rest of your rules here as needed...
20
31
  {
21
32
  blankLine: 'always',
22
33
  prev: '*',
@@ -33,6 +44,9 @@ export default [
33
44
  next: 'throw'
34
45
  }
35
46
  ],
47
+
48
+ // ✅ This enforces ONE blank line at top + bottom of function bodies
49
+ // (and other normal blocks), matching your "inside curly braces" requirement.
36
50
  'padded-blocks': [
37
51
  'error',
38
52
  {
@@ -42,24 +56,28 @@ export default [
42
56
  }
43
57
  ],
44
58
 
45
- "object-curly-newline": [
46
- "error",
59
+ // Keep brace-newline rules, BUT disable them for imports only
60
+ 'object-curly-newline': [
61
+ 'error',
47
62
  {
48
63
  ObjectExpression: {
49
- minProperties: 2, // If object has 2+ props, break into multiple lines
64
+ minProperties: 2,
50
65
  multiline: true,
51
66
  consistent: true
52
67
  },
53
- // You can also configure ImportDeclaration, ExportDeclaration, etc.
54
68
  ObjectPattern: {
55
- multiline: true,
56
69
  minProperties: 2,
70
+ multiline: true,
57
71
  consistent: true
58
72
  },
73
+
74
+ // imports ignore curly newline formatting
59
75
  ImportDeclaration: {
60
- multiline: true,
61
- minProperties: 2
76
+ multiline: false,
77
+ minProperties: 99999,
78
+ consistent: false
62
79
  },
80
+
63
81
  ExportDeclaration: {
64
82
  multiline: true,
65
83
  minProperties: 2
@@ -67,19 +85,12 @@ export default [
67
85
  }
68
86
  ],
69
87
 
70
- // 2) If the object is multiline, put each property on its own line
71
- "object-property-newline": [
72
- "error",
73
- {
74
- allowAllPropertiesOnSameLine: false
75
- }
76
- ],
77
-
78
- indent: [ "error", "tab", { "SwitchCase": 1 } ],
79
- semi: [ "error", "always" ],
80
- "arrow-parens": [ "error", "always" ],
81
- "object-curly-spacing": [ "error", "always" ],
82
- "array-bracket-spacing": [ "error", "always" ],
88
+ 'object-property-newline': [ 'error', { allowAllPropertiesOnSameLine: false } ],
89
+ indent: [ 'error', 'tab', { SwitchCase: 1 } ],
90
+ semi: [ 'error', 'always' ],
91
+ 'arrow-parens': [ 'error', 'always' ],
92
+ 'object-curly-spacing': [ 'error', 'always' ],
93
+ 'array-bracket-spacing': [ 'error', 'always' ],
83
94
  'lines-between-class-members': [ 'error', 'always' ],
84
95
  'newline-after-var': [ 'error', 'always' ],
85
96
  'newline-before-return': 'error',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomeness-js/utils",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Awesomeness - Utils",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,56 +1,58 @@
1
- import {
2
- readdirSync, statSync
3
- } from 'fs';
4
- import { join } from 'path';
5
- import shouldIgnore from './shouldIgnore.js';
1
+ import { readdirSync, statSync } from "fs";
2
+ import path from "path";
3
+ import shouldIgnore from "./shouldIgnore.js";
6
4
 
7
5
  export default function getAllFiles(base, {
8
- dir = '.',
9
- files = [],
6
+ dir = ".",
7
+ files = [],
10
8
  ignore = [],
11
- fileTypes = []
9
+ fileTypes = [],
10
+ root,
12
11
  } = {}) {
13
12
 
14
- const directory = join(base, dir);
13
+ const isAbsDir = path.isAbsolute(dir);
14
+
15
+ // If scanning absolute paths, keep a stable root for relative paths
16
+ const scanRoot = root ?? (isAbsDir ? dir : path.join(base, dir));
17
+
18
+ // Resolve the directory we are currently reading
19
+ const directory = isAbsDir ? dir : path.join(base, dir);
15
20
 
16
21
  const sortedFiles = readdirSync(directory).sort();
17
22
 
18
23
  sortedFiles.forEach((file) => {
19
24
 
20
- const fullPath = join(directory, file);
21
- // 1) Generate the original "relative path"
22
- const relativePath = join(dir, file).replace(/\\/g, '/');
25
+ const fullPath = path.join(directory, file);
23
26
 
24
- // 2) Prepend a slash so patterns like "/css/*.js" will match "/css/some.js"
25
- const pathForIgnore = '/' + relativePath.replace(/^\/*/, '');
27
+ // Always store relative to scanRoot when working with absolute paths
28
+ const relativePath = (
29
+ isAbsDir
30
+ ? path.relative(scanRoot, fullPath)
31
+ : path.join(dir, file)
32
+ ).replace(/\\/g, "/");
26
33
 
27
- // 3) Check with the leading slash path
28
- if (shouldIgnore(pathForIgnore, ignore)) {
34
+ const pathForIgnore = "/" + relativePath.replace(/^\/*/, "");
29
35
 
30
- return;
31
-
32
- }
36
+ if (shouldIgnore(pathForIgnore, ignore)) return;
33
37
 
34
- // Recurse if it's a directory
35
38
  if (statSync(fullPath).isDirectory()) {
36
39
 
37
40
  getAllFiles(base, {
38
- dir: join(dir, file),
41
+ dir: isAbsDir ? fullPath : path.join(dir, file),
39
42
  files,
40
43
  ignore,
41
- fileTypes
44
+ fileTypes,
45
+ root: scanRoot, // PASS ROOT DOWN
42
46
  });
43
47
 
44
48
  } else {
45
49
 
46
- // Filter by file types if specified
47
50
  if (fileTypes.length > 0 && !fileTypes.some((ext) => file.endsWith(ext))) {
48
51
 
49
52
  return;
50
53
 
51
54
  }
52
55
 
53
- // 4) Store the original relative path (without leading slash) in `files` if you prefer
54
56
  files.push(relativePath);
55
57
 
56
58
  }