Skip to content

Commit 229a16d

Browse files
authored
upgrade ESLint config (#5472)
1 parent c24b313 commit 229a16d

File tree

356 files changed

+993
-993
lines changed

Some content is hidden

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

356 files changed

+993
-993
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"posttest": "agadoo internal/index.mjs",
3838
"prepublishOnly": "npm run lint && PUBLISH=true npm test",
3939
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
40-
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
40+
"lint": "eslint '{src,test}/**/*.{ts,js}'"
4141
},
4242
"repository": {
4343
"type": "git",
@@ -63,7 +63,7 @@
6363
"@rollup/plugin-sucrase": "^3.0.0",
6464
"@rollup/plugin-typescript": "^2.0.1",
6565
"@rollup/plugin-virtual": "^2.0.0",
66-
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.0.0",
66+
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.2.0",
6767
"@types/mocha": "^7.0.0",
6868
"@types/node": "^8.10.53",
6969
"@typescript-eslint/eslint-plugin": "^3.0.2",

src/compiler/compile/Component.ts

+25-25
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export default class Component {
157157
) || { start: 0, end: 0 };
158158
this.warn(svelteOptions, {
159159
code: 'custom-element-no-tag',
160-
message: `No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag="my-thing"/>. To hide this warning, use <svelte:options tag={null}/>`
160+
message: 'No custom element \'tag\' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag="my-thing"/>. To hide this warning, use <svelte:options tag={null}/>'
161161
});
162162
}
163163
this.tag = this.component_options.tag || compile_options.tag;
@@ -241,7 +241,7 @@ export default class Component {
241241
const { compile_options, name } = this;
242242
const { format = 'esm' } = compile_options;
243243

244-
const banner = `${this.file ? `${this.file} ` : ``}generated by Svelte v${'__VERSION__'}`;
244+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'__VERSION__'}`;
245245

246246
const program: any = { type: 'Program', body: result.js };
247247

@@ -458,16 +458,16 @@ export default class Component {
458458
extract_exports(node) {
459459
if (node.type === 'ExportDefaultDeclaration') {
460460
this.error(node, {
461-
code: `default-export`,
462-
message: `A component cannot have a default export`
461+
code: 'default-export',
462+
message: 'A component cannot have a default export'
463463
});
464464
}
465465

466466
if (node.type === 'ExportNamedDeclaration') {
467467
if (node.source) {
468468
this.error(node, {
469-
code: `not-implemented`,
470-
message: `A component currently cannot have an export ... from`
469+
code: 'not-implemented',
470+
message: 'A component currently cannot have an export ... from'
471471
});
472472
}
473473
if (node.declaration) {
@@ -478,7 +478,7 @@ export default class Component {
478478
variable.export_name = name;
479479
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
480480
this.warn(declarator, {
481-
code: `unused-export-let`,
481+
code: 'unused-export-let',
482482
message: `${this.name.name} has unused export property '${name}'. If it is for external reference only, please consider using \`export const ${name}\``
483483
});
484484
}
@@ -501,7 +501,7 @@ export default class Component {
501501

502502
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
503503
this.warn(specifier, {
504-
code: `unused-export-let`,
504+
code: 'unused-export-let',
505505
message: `${this.name.name} has unused export property '${specifier.exported.name}'. If it is for external reference only, please consider using \`export const ${specifier.exported.name}\``
506506
});
507507
}
@@ -550,7 +550,7 @@ export default class Component {
550550
if (name[0] === '$') {
551551
this.error(node as any, {
552552
code: 'illegal-declaration',
553-
message: `The $ prefix is reserved, and cannot be used for variable and import names`
553+
message: 'The $ prefix is reserved, and cannot be used for variable and import names'
554554
});
555555
}
556556

@@ -568,7 +568,7 @@ export default class Component {
568568
if (name[0] === '$') {
569569
this.error(node as any, {
570570
code: 'illegal-subscription',
571-
message: `Cannot reference store value inside <script context="module">`
571+
message: 'Cannot reference store value inside <script context="module">'
572572
});
573573
} else {
574574
this.add_var({
@@ -629,7 +629,7 @@ export default class Component {
629629
if (name[0] === '$') {
630630
this.error(node as any, {
631631
code: 'illegal-declaration',
632-
message: `The $ prefix is reserved, and cannot be used for variable and import names`
632+
message: 'The $ prefix is reserved, and cannot be used for variable and import names'
633633
});
634634
}
635635

@@ -867,8 +867,8 @@ export default class Component {
867867

868868
if (name[1] !== '$' && scope.has(name.slice(1)) && scope.find_owner(name.slice(1)) !== this.instance_scope) {
869869
this.error(node, {
870-
code: `contextual-store`,
871-
message: `Stores must be declared at the top level of the component (this may change in a future version of Svelte)`
870+
code: 'contextual-store',
871+
message: 'Stores must be declared at the top level of the component (this may change in a future version of Svelte)'
872872
});
873873
}
874874
}
@@ -935,7 +935,7 @@ export default class Component {
935935
// TODO is this still true post-#3539?
936936
component.error(declarator as any, {
937937
code: 'destructured-prop',
938-
message: `Cannot declare props in destructured declaration`
938+
message: 'Cannot declare props in destructured declaration'
939939
});
940940
}
941941

@@ -1379,23 +1379,23 @@ function process_component_options(component: Component, nodes) {
13791379
switch (name) {
13801380
case 'tag': {
13811381
const code = 'invalid-tag-attribute';
1382-
const message = `'tag' must be a string literal`;
1382+
const message = "'tag' must be a string literal";
13831383
const tag = get_value(attribute, code, message);
13841384

13851385
if (typeof tag !== 'string' && tag !== null)
13861386
component.error(attribute, { code, message });
13871387

13881388
if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
13891389
component.error(attribute, {
1390-
code: `invalid-tag-property`,
1391-
message: `tag name must be two or more words joined by the '-' character`
1390+
code: 'invalid-tag-property',
1391+
message: "tag name must be two or more words joined by the '-' character"
13921392
});
13931393
}
13941394

13951395
if (tag && !component.compile_options.customElement) {
13961396
component.warn(attribute, {
13971397
code: 'missing-custom-element-compile-options',
1398-
message: `The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?`
1398+
message: "The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?"
13991399
});
14001400
}
14011401

@@ -1405,7 +1405,7 @@ function process_component_options(component: Component, nodes) {
14051405

14061406
case 'namespace': {
14071407
const code = 'invalid-namespace-attribute';
1408-
const message = `The 'namespace' attribute must be a string literal representing a valid namespace`;
1408+
const message = "The 'namespace' attribute must be a string literal representing a valid namespace";
14091409
const ns = get_value(attribute, code, message);
14101410

14111411
if (typeof ns !== 'string')
@@ -1415,12 +1415,12 @@ function process_component_options(component: Component, nodes) {
14151415
const match = fuzzymatch(ns, valid_namespaces);
14161416
if (match) {
14171417
component.error(attribute, {
1418-
code: `invalid-namespace-property`,
1418+
code: 'invalid-namespace-property',
14191419
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`
14201420
});
14211421
} else {
14221422
component.error(attribute, {
1423-
code: `invalid-namespace-property`,
1423+
code: 'invalid-namespace-property',
14241424
message: `Invalid namespace '${ns}'`
14251425
});
14261426
}
@@ -1446,14 +1446,14 @@ function process_component_options(component: Component, nodes) {
14461446

14471447
default:
14481448
component.error(attribute, {
1449-
code: `invalid-options-attribute`,
1450-
message: `<svelte:options> unknown attribute`
1449+
code: 'invalid-options-attribute',
1450+
message: '<svelte:options> unknown attribute'
14511451
});
14521452
}
14531453
} else {
14541454
component.error(attribute, {
1455-
code: `invalid-options-attribute`,
1456-
message: `<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes`
1455+
code: 'invalid-options-attribute',
1456+
message: "<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes"
14571457
});
14581458
}
14591459
});

src/compiler/compile/css/Selector.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export default class Selector {
118118
const selector = block.selectors[i];
119119
if (selector.type === 'PseudoClassSelector' && selector.name === 'global') {
120120
component.error(selector, {
121-
code: `css-invalid-global`,
122-
message: `:global(...) must be the first element in a compound selector`
121+
code: 'css-invalid-global',
122+
message: ':global(...) must be the first element in a compound selector'
123123
});
124124
}
125125
}
@@ -139,8 +139,8 @@ export default class Selector {
139139
for (let i = start; i < end; i += 1) {
140140
if (this.blocks[i].global) {
141141
component.error(this.blocks[i].selectors[0], {
142-
code: `css-invalid-global`,
143-
message: `:global(...) can be at the start or end of a selector sequence, but not in the middle`
142+
code: 'css-invalid-global',
143+
message: ':global(...) can be at the start or end of a selector sequence, but not in the middle'
144144
});
145145
}
146146
}
@@ -286,7 +286,7 @@ function test_attribute(operator, expected_value, case_insensitive, value) {
286286
case '^=': return value.startsWith(expected_value);
287287
case '$=': return value.endsWith(expected_value);
288288
case '*=': return value.includes(expected_value);
289-
default: throw new Error(`this shouldn't happen`);
289+
default: throw new Error("this shouldn't happen");
290290
}
291291
}
292292

src/compiler/compile/css/Stylesheet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Element from '../nodes/Element';
55
import { Ast } from '../../interfaces';
66
import Component from '../Component';
77
import { CssNode } from './interfaces';
8-
import hash from "../utils/hash";
8+
import hash from '../utils/hash';
99

1010
function remove_css_prefix(name: string): string {
1111
return name.replace(/^-((webkit)|(moz)|(o)|(ms))-/, '');
@@ -428,7 +428,7 @@ export default class Stylesheet {
428428
this.children.forEach(child => {
429429
child.warn_on_unused_selector((selector: Selector) => {
430430
component.warn(selector.node, {
431-
code: `css-unused-selector`,
431+
code: 'css-unused-selector',
432432
message: `Unused CSS selector "${this.source.slice(selector.node.start, selector.node.end)}"`
433433
});
434434
});

src/compiler/compile/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
4646
}
4747

4848
if (name && /^[a-z]/.test(name)) {
49-
const message = `options.name should be capitalised`;
49+
const message = 'options.name should be capitalised';
5050
warnings.push({
51-
code: `options-lowercase-name`,
51+
code: 'options-lowercase-name',
5252
message,
5353
filename,
5454
toString: () => message
@@ -58,7 +58,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
5858
if (loopGuardTimeout && !dev) {
5959
const message = 'options.loopGuardTimeout is for options.dev = true only';
6060
warnings.push({
61-
code: `options-loop-guard-timeout`,
61+
code: 'options-loop-guard-timeout',
6262
message,
6363
filename,
6464
toString: () => message

src/compiler/compile/nodes/Animation.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export default class Animation extends Node {
1717

1818
if (parent.animation) {
1919
component.error(this, {
20-
code: `duplicate-animation`,
21-
message: `An element can only have one 'animate' directive`
20+
code: 'duplicate-animation',
21+
message: "An element can only have one 'animate' directive"
2222
});
2323
}
2424

2525
const block = parent.parent;
2626
if (!block || block.type !== 'EachBlock' || !block.key) {
2727
// TODO can we relax the 'immediate child' rule?
2828
component.error(this, {
29-
code: `invalid-animation`,
30-
message: `An element that use the animate directive must be the immediate child of a keyed each block`
29+
code: 'invalid-animation',
30+
message: 'An element that use the animate directive must be the immediate child of a keyed each block'
3131
});
3232
}
3333

src/compiler/compile/nodes/Binding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import get_object from '../utils/get_object';
33
import Expression from './shared/Expression';
44
import Component from '../Component';
55
import TemplateScope from './shared/TemplateScope';
6-
import {dimensions} from "../../utils/patterns";
6+
import {dimensions} from '../../utils/patterns';
77
import { Node as ESTreeNode } from 'estree';
88

99
// TODO this should live in a specific binding

src/compiler/compile/nodes/EachBlock.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export default class EachBlock extends AbstractBlock {
6060
if (this.children.length !== 1) {
6161
const child = this.children.find(child => !!(child as Element).animation);
6262
component.error((child as Element).animation, {
63-
code: `invalid-animation`,
64-
message: `An element that use the animate directive must be the sole child of a keyed each block`
63+
code: 'invalid-animation',
64+
message: 'An element that use the animate directive must be the sole child of a keyed each block'
6565
});
6666
}
6767
}

0 commit comments

Comments
 (0)