Skip to content

Commit c55dafd

Browse files
committed
fix: change camel-case declarations to snake-case
1 parent 767e0b7 commit c55dafd

File tree

9 files changed

+61
-52
lines changed

9 files changed

+61
-52
lines changed

packages/svelte/scripts/compile-test.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
// Compile all Svelte files in a directory to JS and CSS files
22
// Usage: node scripts/compile-test.js <directory>
33

4-
import { mkdirSync, readFileSync, writeFileSync } from 'fs';
5-
import path from 'path';
6-
import glob from 'tiny-glob/sync.js';
4+
import {
5+
mkdirSync as mkdir_sync,
6+
readFileSync as read_file_sync,
7+
writeFileSync as write_file_sync
8+
} from 'fs';
9+
710
import { compile } from '../src/compiler/index.js';
11+
import glob from 'tiny-glob/sync.js';
12+
import path from 'path';
813

914
const cwd = path.resolve(process.argv[2]);
1015

@@ -14,7 +19,7 @@ const options = [
1419
['ssr', { generate: 'ssr' }]
1520
];
1621
for (const file of glob('**/*.svelte', { cwd })) {
17-
const contents = readFileSync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, '');
22+
const contents = read_file_sync(`${cwd}/${file}`, 'utf-8').replace(/\r/g, '');
1823
let w;
1924
for (const [name, opts] of options) {
2025
const dir = `${cwd}/_output/${name}`;
@@ -28,9 +33,9 @@ for (const file of glob('**/*.svelte', { cwd })) {
2833
w = warnings;
2934
}
3035

31-
mkdirSync(dir, { recursive: true });
32-
js.code && writeFileSync(`${dir}/${file.replace(/\.svelte$/, '.js')}`, js.code);
33-
css.code && writeFileSync(`${dir}/${file.replace(/\.svelte$/, '.css')}`, css.code);
36+
mkdir_sync(dir, { recursive: true });
37+
js.code && write_file_sync(`${dir}/${file.replace(/\.svelte$/, '.js')}`, js.code);
38+
css.code && write_file_sync(`${dir}/${file.replace(/\.svelte$/, '.css')}`, css.code);
3439
}
3540

3641
if (w) {

packages/svelte/scripts/generate-dts.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from 'fs';
2-
import { createBundle } from 'dts-buddy';
2+
3+
import { createBundle as create_bundle } from 'dts-buddy';
34

45
// It may look weird, but the imports MUST be ending with index.js to be properly resolved in all TS modes
56
for (const name of ['action', 'animate', 'easing', 'motion', 'store', 'transition']) {
@@ -14,7 +15,7 @@ fs.mkdirSync('./types/compiler', { recursive: true });
1415
fs.writeFileSync('./types/compiler/preprocess.d.ts', `import '../index.js';`);
1516
fs.writeFileSync('./types/compiler/interfaces.d.ts', `import '../index.js';`);
1617

17-
await createBundle({
18+
await create_bundle({
1819
output: 'types/index.d.ts',
1920
compilerOptions: {
2021
strict: true

packages/svelte/src/compiler/compile/render_dom/wrappers/Window.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import Wrapper from './shared/Wrapper.js';
21
import { b, x } from 'code-red';
3-
import add_event_handlers from './shared/add_event_handlers.js';
4-
import add_actions from './shared/add_actions.js';
2+
53
import EventHandler from './Element/EventHandler.js';
4+
import Wrapper from './shared/Wrapper.js';
5+
import add_actions from './shared/add_actions.js';
6+
import add_event_handlers from './shared/add_event_handlers.js';
67

78
const associated_events = {
89
innerWidth: 'resize',
@@ -94,14 +95,14 @@ export default class WindowWrapper extends Wrapper {
9495
bindings.scrollX && bindings.scrollY
9596
? x`"${bindings.scrollX}" in this._state || "${bindings.scrollY}" in this._state`
9697
: x`"${bindings.scrollX || bindings.scrollY}" in this._state`;
97-
const scrollX = bindings.scrollX && x`this._state.${bindings.scrollX}`;
98-
const scrollY = bindings.scrollY && x`this._state.${bindings.scrollY}`;
98+
const scroll_x = bindings.scrollX && x`this._state.${bindings.scrollX}`;
99+
const scroll_y = bindings.scrollY && x`this._state.${bindings.scrollY}`;
99100
renderer.meta_bindings.push(b`
100101
if (${condition}) {
101-
@_scrollTo(${scrollX || '@_window.pageXOffset'}, ${scrollY || '@_window.pageYOffset'});
102+
@_scrollTo(${scroll_x || '@_window.pageXOffset'}, ${scroll_y || '@_window.pageYOffset'});
102103
}
103-
${scrollX && `${scrollX} = @_window.pageXOffset;`}
104-
${scrollY && `${scrollY} = @_window.pageYOffset;`}
104+
${scroll_x && `${scroll_x} = @_window.pageXOffset;`}
105+
${scroll_y && `${scroll_y} = @_window.pageYOffset;`}
105106
`);
106107
block.event_listeners.push(x`
107108
@listen(@_window, "${event}", () => {
@@ -132,17 +133,17 @@ export default class WindowWrapper extends Wrapper {
132133
// special case... might need to abstract this out if we add more special cases
133134
if (bindings.scrollX || bindings.scrollY) {
134135
const condition = renderer.dirty([bindings.scrollX, bindings.scrollY].filter(Boolean));
135-
const scrollX = bindings.scrollX
136+
const scroll_x = bindings.scrollX
136137
? renderer.reference(bindings.scrollX)
137138
: x`@_window.pageXOffset`;
138-
const scrollY = bindings.scrollY
139+
const scroll_y = bindings.scrollY
139140
? renderer.reference(bindings.scrollY)
140141
: x`@_window.pageYOffset`;
141142
block.chunks.update.push(b`
142143
if (${condition} && !${scrolling}) {
143144
${scrolling} = true;
144145
@_clearTimeout(${scrolling_timeout});
145-
@_scrollTo(${scrollX}, ${scrollY});
146+
@_scrollTo(${scroll_x}, ${scroll_y});
146147
${scrolling_timeout} = @_setTimeout(${clear_scrolling}, 100);
147148
}
148149
`);
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export {
22
SvelteComponentDev as SvelteComponent,
3-
onMount,
4-
onDestroy,
5-
beforeUpdate,
6-
afterUpdate,
7-
setContext,
8-
getContext,
9-
getAllContexts,
10-
hasContext,
3+
on_mount as onMount,
4+
on_destroy as onDestroy,
5+
before_update as beforeUpdate,
6+
after_update as afterUpdate,
7+
set_context as setContext,
8+
get_context as getContext,
9+
get_all_contexts as getAllContexts,
10+
has_context as hasContext,
1111
tick,
12-
createEventDispatcher,
12+
create_event_dispatcher as createEventDispatcher,
1313
SvelteComponentTyped
1414
} from './internal/index.js';

packages/svelte/src/runtime/internal/lifecycle.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function get_current_component() {
2121
* @param {() => any} fn
2222
* @returns {void}
2323
*/
24-
export function beforeUpdate(fn) {
24+
export function before_update(fn) {
2525
get_current_component().$$.before_update.push(fn);
2626
}
2727

@@ -39,7 +39,7 @@ export function beforeUpdate(fn) {
3939
* @param {() => import('./private.js').NotFunction<T> | Promise<import('./private.js').NotFunction<T>> | (() => any)} fn
4040
* @returns {void}
4141
*/
42-
export function onMount(fn) {
42+
export function on_mount(fn) {
4343
get_current_component().$$.on_mount.push(fn);
4444
}
4545

@@ -52,7 +52,7 @@ export function onMount(fn) {
5252
* @param {() => any} fn
5353
* @returns {void}
5454
*/
55-
export function afterUpdate(fn) {
55+
export function after_update(fn) {
5656
get_current_component().$$.after_update.push(fn);
5757
}
5858

@@ -66,7 +66,7 @@ export function afterUpdate(fn) {
6666
* @param {() => any} fn
6767
* @returns {void}
6868
*/
69-
export function onDestroy(fn) {
69+
export function on_destroy(fn) {
7070
get_current_component().$$.on_destroy.push(fn);
7171
}
7272

@@ -93,7 +93,7 @@ export function onDestroy(fn) {
9393
* @template {Record<string, any>} [EventMap=any]
9494
* @returns {import('./public.js').EventDispatcher<EventMap>}
9595
*/
96-
export function createEventDispatcher() {
96+
export function create_event_dispatcher() {
9797
const component = get_current_component();
9898
return (type, detail, { cancelable = false } = {}) => {
9999
const callbacks = component.$$.callbacks[type];
@@ -123,7 +123,7 @@ export function createEventDispatcher() {
123123
* @param {T} context
124124
* @returns {T}
125125
*/
126-
export function setContext(key, context) {
126+
export function set_context(key, context) {
127127
get_current_component().$$.context.set(key, context);
128128
return context;
129129
}
@@ -137,7 +137,7 @@ export function setContext(key, context) {
137137
* @param {any} key
138138
* @returns {T}
139139
*/
140-
export function getContext(key) {
140+
export function get_context(key) {
141141
return get_current_component().$$.context.get(key);
142142
}
143143

@@ -150,7 +150,7 @@ export function getContext(key) {
150150
* @template {Map<any, any>} [T=Map<any, any>]
151151
* @returns {T}
152152
*/
153-
export function getAllContexts() {
153+
export function get_all_contexts() {
154154
return get_current_component().$$.context;
155155
}
156156

@@ -162,7 +162,7 @@ export function getAllContexts() {
162162
* @param {any} key
163163
* @returns {boolean}
164164
*/
165-
export function hasContext(key) {
165+
export function has_context(key) {
166166
return get_current_component().$$.context.has(key);
167167
}
168168

packages/svelte/src/runtime/internal/scheduler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { run_all } from './utils.js';
21
import { current_component, set_current_component } from './lifecycle.js';
32

3+
import { run_all } from './utils.js';
4+
45
export const dirty_components = [];
56
export const intros = { enabled: false };
67
export const binding_callbacks = [];

packages/svelte/src/runtime/internal/ssr.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { set_current_component, current_component } from './lifecycle.js';
2-
import { run_all, blank_object } from './utils.js';
1+
import { blank_object, run_all } from './utils.js';
2+
import { current_component, set_current_component } from './lifecycle.js';
3+
34
import { boolean_attributes } from '../../shared/boolean_attributes.js';
45
import { ensure_array_like } from './each.js';
56
export { is_void } from '../../shared/utils/names.js';

packages/svelte/src/runtime/ssr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export {
1010
SvelteComponentTyped
1111
} from './index.js';
1212

13-
/** @returns {void} */
13+
// eslint-disable-next-line id-match
1414
export function onMount() {}
1515

16-
/** @returns {void} */
16+
// eslint-disable-next-line id-match
1717
export function beforeUpdate() {}
1818

19-
/** @returns {void} */
19+
// eslint-disable-next-line id-match
2020
export function afterUpdate() {}

packages/svelte/src/runtime/transition/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { cubicOut, cubicInOut, linear } from '../easing/index.js';
2-
import { assign, split_css_unit, is_function } from '../internal/index.js';
1+
import { assign, is_function, split_css_unit } from '../internal/index.js';
2+
import { cubicInOut as cubic_in_out, cubicOut as cubic_out, linear } from '../easing/index.js';
33

44
/**
55
* Animates a `blur` filter alongside an element's opacity.
@@ -11,7 +11,7 @@ import { assign, split_css_unit, is_function } from '../internal/index.js';
1111
*/
1212
export function blur(
1313
node,
14-
{ delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}
14+
{ delay = 0, duration = 400, easing = cubic_in_out, amount = 5, opacity = 0 } = {}
1515
) {
1616
const style = getComputedStyle(node);
1717
const target_opacity = +style.opacity;
@@ -54,7 +54,7 @@ export function fade(node, { delay = 0, duration = 400, easing = linear } = {})
5454
*/
5555
export function fly(
5656
node,
57-
{ delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}
57+
{ delay = 0, duration = 400, easing = cubic_out, x = 0, y = 0, opacity = 0 } = {}
5858
) {
5959
const style = getComputedStyle(node);
6060
const target_opacity = +style.opacity;
@@ -80,7 +80,7 @@ export function fly(
8080
* @param {import('./public').SlideParams} [params]
8181
* @returns {import('./public').TransitionConfig}
8282
*/
83-
export function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis = 'y' } = {}) {
83+
export function slide(node, { delay = 0, duration = 400, easing = cubic_out, axis = 'y' } = {}) {
8484
const style = getComputedStyle(node);
8585
const opacity = +style.opacity;
8686
const primary_property = axis === 'y' ? 'height' : 'width';
@@ -126,7 +126,7 @@ export function slide(node, { delay = 0, duration = 400, easing = cubicOut, axis
126126
*/
127127
export function scale(
128128
node,
129-
{ delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}
129+
{ delay = 0, duration = 400, easing = cubic_out, start = 0, opacity = 0 } = {}
130130
) {
131131
const style = getComputedStyle(node);
132132
const target_opacity = +style.opacity;
@@ -152,7 +152,7 @@ export function scale(
152152
* @param {import('./public').DrawParams} [params]
153153
* @returns {import('./public').TransitionConfig}
154154
*/
155-
export function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) {
155+
export function draw(node, { delay = 0, speed, duration, easing = cubic_in_out } = {}) {
156156
let len = node.getTotalLength();
157157
const style = getComputedStyle(node);
158158
if (style.strokeLinecap !== 'butt') {
@@ -202,7 +202,7 @@ export function crossfade({ fallback, ...defaults }) {
202202
const {
203203
delay = 0,
204204
duration = (d) => Math.sqrt(d) * 30,
205-
easing = cubicOut
205+
easing = cubic_out
206206
} = assign(assign({}, defaults), params);
207207
const from = from_node.getBoundingClientRect();
208208
const to = node.getBoundingClientRect();

0 commit comments

Comments
 (0)