Skip to content

Commit f5ead5f

Browse files
Merge branch 'stdlib-js:develop' into Quantile
2 parents 614c8f6 + 4d14525 commit f5ead5f

File tree

1,238 files changed

+57096
-4819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,238 files changed

+57096
-4819
lines changed

.github/workflows/lint_changed_files.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,21 @@ jobs:
7272
node-version: '20' # 'lts/*'
7373
timeout-minutes: 5
7474

75+
# Cache dependencies:
76+
- name: 'Cache dependencies'
77+
# Pin action to full length commit SHA
78+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
79+
id: cache
80+
with:
81+
path: |
82+
${{ github.workspace }}/node_modules
83+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
84+
restore-keys: |
85+
${{ runner.os }}-node-
86+
7587
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
7688
- name: 'Install dependencies'
89+
if: steps.cache.outputs.cache-hit != 'true'
7790
run: |
7891
make install-node-modules || make install-node-modules || make install-node-modules
7992
timeout-minutes: 15
@@ -120,7 +133,7 @@ jobs:
120133
- name: 'Lint against EditorConfig'
121134
if: success() || failure()
122135
run: |
123-
make lint-editorconfig-files FILES="${{ steps.changed-files.outputs.files }}"
136+
make lint-editorconfig-files EDITORCONFIG_FORMAT=github-actions FILES="${{ steps.changed-files.outputs.files }}"
124137
125138
# Lint Markdown files:
126139
- name: 'Lint Markdown files'

.github/workflows/run_affected_benchmarks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,21 @@ jobs:
7878
node-version: '20' # 'lts/*'
7979
timeout-minutes: 5
8080

81+
# Cache dependencies:
82+
- name: 'Cache dependencies'
83+
# Pin action to full length commit SHA
84+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
85+
id: cache
86+
with:
87+
path: |
88+
${{ github.workspace }}/node_modules
89+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
90+
restore-keys: |
91+
${{ runner.os }}-node-
92+
8193
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
8294
- name: 'Install dependencies'
95+
if: steps.cache.outputs.cache-hit != 'true'
8396
run: |
8497
make install-node-modules || make install-node-modules || make install-node-modules
8598
timeout-minutes: 15

.github/workflows/run_affected_examples.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,21 @@ jobs:
7979
node-version: '20' # 'lts/*'
8080
timeout-minutes: 5
8181

82+
# Cache dependencies:
83+
- name: 'Cache dependencies'
84+
# Pin action to full length commit SHA
85+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
86+
id: cache
87+
with:
88+
path: |
89+
${{ github.workspace }}/node_modules
90+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
91+
restore-keys: |
92+
${{ runner.os }}-node-
93+
8294
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
8395
- name: 'Install dependencies'
96+
if: steps.cache.outputs.cache-hit != 'true'
8497
run: |
8598
make install-node-modules || make install-node-modules || make install-node-modules
8699
timeout-minutes: 15

.github/workflows/run_affected_tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,21 @@ jobs:
114114
node-version: '20' # 'lts/*'
115115
timeout-minutes: 5
116116

117+
# Cache dependencies:
118+
- name: 'Cache dependencies'
119+
# Pin action to full length commit SHA
120+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
121+
id: cache
122+
with:
123+
path: |
124+
${{ github.workspace }}/node_modules
125+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
126+
restore-keys: |
127+
${{ runner.os }}-node-
128+
117129
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
118130
- name: 'Install dependencies'
131+
if: steps.cache.outputs.cache-hit != 'true'
119132
run: |
120133
make install-node-modules || make install-node-modules || make install-node-modules
121134
timeout-minutes: 15

.github/workflows/run_tests_coverage.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,21 @@ jobs:
120120
node-version: 20 # 'lts/*'
121121
timeout-minutes: 5
122122

123+
# Cache dependencies:
124+
- name: 'Cache dependencies'
125+
# Pin action to full length commit SHA
126+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
127+
id: cache
128+
with:
129+
path: |
130+
${{ github.workspace }}/node_modules
131+
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
132+
restore-keys: |
133+
${{ runner.os }}-node-
134+
123135
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
124136
- name: 'Install dependencies'
137+
if: steps.cache.outputs.cache-hit != 'true'
125138
run: |
126139
make install-node-modules || make install-node-modules || make install-node-modules
127140
timeout-minutes: 15

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var rule = require( '@stdlib/_tools/eslint/rules/repl-namespace-order' );
3838

3939
#### rule
4040

41-
[ESLint rule][eslint-rules] to enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
41+
[ESLint rule][eslint-rules] to enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
4242

4343
**Bad**:
4444

@@ -117,8 +117,6 @@ var result;
117117
var code;
118118

119119
code = [
120-
'/* eslint-enable stdlib/repl-namespace-order */',
121-
'',
122120
'/* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key). */',
123121
'',
124122
'ns.push({',

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/examples/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ var result;
2626
var code;
2727

2828
code = [
29-
'/* eslint-enable stdlib/repl-namespace-order */',
30-
'',
3129
'/* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key). */',
3230
'',
3331
'ns.push({',

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/lib/main.js

Lines changed: 115 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,43 +37,81 @@ var OPTS_COMPARE = {
3737
* @returns {Object} validators
3838
*/
3939
function main( context ) {
40+
var expressions;
4041
var prevAlias;
4142

42-
return {
43-
'ObjectExpression': validate
44-
};
43+
expressions = [];
4544

4645
/**
47-
* Checks whether packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
46+
* Extracts the alias value from a given node.
4847
*
4948
* @private
50-
* @param {ASTNode} node - node to examine
49+
* @param {ASTNode} node - node containing properties to search
50+
* @returns {string} alias value
5151
*/
52-
function validate( node ) {
53-
var properties;
52+
function getAlias( node ) {
53+
var props;
5454
var alias;
55-
var prop;
5655
var i;
5756

58-
properties = node.properties;
59-
for ( i = 0; i < properties.length; i++ ) {
60-
prop = properties[ i ];
61-
if ( prop.key.value === 'alias' ) {
62-
alias = prop.value.value;
57+
props = node.properties;
58+
for ( i = 0; i < props.length; i++ ) {
59+
if ( props[ i ].key.value === 'alias' ) {
60+
alias = props[ i ].value.value;
6361
if ( alias ) {
64-
if (
65-
prevAlias &&
66-
alias.localeCompare( prevAlias, 'en', OPTS_COMPARE ) < 0 )
67-
{
68-
report( prevAlias, alias, node );
69-
} else {
70-
prevAlias = alias;
71-
}
62+
return alias;
7263
}
7364
}
7465
}
7566
}
7667

68+
/**
69+
* Compares two nodes and determines their order based on the alias property.
70+
*
71+
* @private
72+
* @param {ASTNode} a - first node
73+
* @param {ASTNode} b - second node
74+
* @returns {number} number indicating sort order
75+
*/
76+
function sortExpressions( a, b ) {
77+
var aliasA = getAlias( a.arguments[ 0 ] );
78+
var aliasB = getAlias( b.arguments[ 0 ] );
79+
return aliasA.localeCompare( aliasB, 'en', OPTS_COMPARE );
80+
}
81+
82+
/**
83+
* Fixes the lint error by reordering the packages.
84+
*
85+
* @private
86+
* @param {Function} fixer - ESLint fixer
87+
* @returns {(Object|null)} fix or null
88+
*/
89+
function fix( fixer ) {
90+
var replacingText;
91+
var startRange;
92+
var endRange;
93+
var sorted;
94+
var source;
95+
var txt;
96+
var i;
97+
98+
source = context.getSourceCode();
99+
replacingText = '';
100+
startRange = expressions[0].range[ 0 ];
101+
endRange = expressions[ expressions.length - 1 ].range[ 1 ];
102+
103+
sorted = expressions.slice().sort( sortExpressions );
104+
105+
for ( i = 0; i < sorted.length; i++ ) {
106+
txt = source.getText( sorted[ i ] );
107+
replacingText += txt;
108+
if ( i < sorted.length - 1 ) {
109+
replacingText += ';\n\n';
110+
}
111+
}
112+
return fixer.replaceTextRange( [ startRange, endRange ], replacingText ); // eslint-disable-line max-len
113+
}
114+
77115
/**
78116
* Reports the error message.
79117
*
@@ -85,19 +123,74 @@ function main( context ) {
85123
function report( last, current, node ) {
86124
context.report({
87125
'node': node,
88-
'message': '"'+current+'" should come before "'+last+'"'
126+
'message': '"'+current+'" should come before "'+last+'"',
127+
'fix': fix
89128
});
90129
}
130+
131+
/**
132+
* Checks whether the packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
133+
*
134+
* @private
135+
*/
136+
function validate() {
137+
var alias;
138+
var i;
139+
140+
for ( i = 0; i < expressions.length; i++ ) {
141+
alias = getAlias( expressions[ i ].arguments[ 0 ] );
142+
if (
143+
prevAlias &&
144+
alias.localeCompare( prevAlias, 'en', OPTS_COMPARE ) < 0
145+
) {
146+
report( prevAlias, alias, expressions[ i ].arguments[ 0 ] );
147+
} else {
148+
prevAlias = alias;
149+
}
150+
}
151+
}
152+
153+
/**
154+
* Collects all expressions which add a package to a REPL namespace.
155+
*
156+
* @private
157+
* @param {ASTNode} node - node to examine
158+
*/
159+
function collectExpressions( node ) {
160+
var object;
161+
var alias;
162+
163+
if (
164+
node.callee.type === 'MemberExpression' &&
165+
node.callee.object.name === 'ns' &&
166+
node.callee.property.name === 'push'
167+
) {
168+
object = node.arguments[ 0 ];
169+
if ( object.type === 'ObjectExpression' ) {
170+
alias = getAlias( object );
171+
if ( alias ) {
172+
expressions.push( node );
173+
}
174+
}
175+
}
176+
}
177+
178+
return {
179+
'CallExpression': collectExpressions,
180+
'Program:exit': validate
181+
};
91182
}
92183

93184

94185
// MAIN //
95186

96187
rule = {
97188
'meta': {
189+
'type': 'suggestion',
98190
'docs': {
99191
'description': 'enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key)'
100192
},
193+
'fixable': 'code',
101194
'schema': []
102195
},
103196
'create': main

0 commit comments

Comments
 (0)