8000 fix lint warnings by antony · Pull Request #5263 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content

fix lint warnings #5263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@rollup/plugin-sucrase": "^3.0.0",
"@rollup/plugin-typescript": "^2.0.1",
"@rollup/plugin-virtual": "^2.0.0",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v0.0.1",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.0.0",
"@types/mocha": "^5.2.7",
"@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^3.0.2",
Expand Down
78 changes: 39 additions & 39 deletions src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
create_scopes,
extract_names,
Scope,
extract_identifiers,
extract_identifiers
} from './utils/scope';
import Stylesheet from './css/Stylesheet';
import { test } from '../config';
Expand Down Expand Up @@ -155,7 +155,7 @@ export default class Component {
) || { start: 0, end: 0 };
this.warn(svelteOptions, {
code: 'custom-element-no-tag',
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}/>`,
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}/>`
});
}
this.tag = this.component_options.tag || compile_options.tag;
Expand Down Expand Up @@ -190,15 +190,15 @@ export default class Component {
this.add_var({
name,
injected: true,
referenced: true,
referenced: true
});
} else if (name[0] === '$') {
this.add_var({
name,
injected: true,
referenced: true,
mutated: true,
writable: true,
writable: true
});

const subscribable_name = name.slice(1);
Expand Down Expand Up @@ -289,7 +289,7 @@ export default class Component {
}
const imported_helpers = Array.from(this.helpers, ([name, alias]) => ({
name,
alias,
alias
}));

create_module(
Expand All @@ -305,7 +305,7 @@ export default class Component {
.filter(variable => variable.module && variable.export_name)
.map(variable => ({
name: variable.name,
as: variable.export_name,
as: variable.export_name
}))
);

Expand Down Expand Up @@ -342,9 +342,9 @@ export default class Component {
reassigned: v.reassigned || false,
referenced: v.referenced || false,
writable: v.writable || false,
referenced_from_script: v.referenced_from_script || false,
referenced_from_script: v.referenced_from_script || false
})),
stats: this.stats.render(),
stats: this.stats.render()
};
}

Expand Down Expand Up @@ -409,7 +409,7 @@ export default class Component {
source: this.source,
start: pos.start,
end: pos.end,
filename: this.compile_options.filename,
filename: this.compile_options.filename
});
}

Expand Down Expand Up @@ -441,7 +441,7 @@ export default class Component {
pos: pos.start,
filename: this.compile_options.filename,
toString: () =>
`${warning.message} (${start.line}:${start.column})\n${frame}`,
`${warning.message} (${start.line}:${start.column})\n${frame}`
});
}

Expand All @@ -453,15 +453,15 @@ export default class Component {
if (node.type === 'ExportDefaultDeclaration') {
this.error(node, {
code: `default-export`,
message: `A component cannot have a default export`,
message: `A component cannot have a default export`
});
}

if (node.type === 'ExportNamedDeclaration') {
if (node.source) {
this.error(node, {
code: `not-implemented`,
message: `A component currently cannot have an export ... from`,
message: `A component currently cannot have an export ... from`
});
}
if (node.declaration) {
Expand Down Expand Up @@ -531,10 +531,10 @@ export default class Component {
if (node.type === 'LabeledStatement' && node.label.name === '$') {
component.warn(node as any, {
code: 'module-script-reactive-declaration',
message: '$: has no effect in a module script',
message: '$: has no effect in a module script'
});
}
},
}
});

const { scope, globals } = create_scopes(script.content);
Expand All @@ -544,7 +544,7 @@ export default class Component {
if (name[0] === '$') {
this.error(node as any, {
code: 'illegal-declaration',
message: `The $ prefix is reserved, and cannot be used for variable and import names`,
message: `The $ prefix is reserved, and cannot be used for variable and import names`
});
}

Expand All @@ -562,7 +562,7 @@ export default class Component {
if (name[0] === '$') {
this.error(node as any, {
code: 'illegal-subscription',
message: `Cannot reference store value inside <script context="module">`,
message: `Cannot reference store value inside <script context="module">`
});
} else {
this.add_var({
Expand Down Expand Up @@ -623,7 +623,7 @@ export default class Component {
if (name[0] === '$') {
this.error(node as any, {
code: 'illegal-declaration',
message: `The $ prefix is reserved, and cannot be used for variable and import names`,
message: `The $ prefix is reserved, and cannot be used for variable and import names`
});
}

Expand All @@ -647,12 +647,12 @@ export default class Component {
injected: true,
writable: true,
reassigned: true,
initialised: true,
initialised: true
});
} else if (is_reserved_keyword(name)) {
this.add_var({
name,
injected: true,
injected: true
});
} else if (name[0] === '$') {
if (name === '$' || name[1] === '$') {
Expand All @@ -666,7 +666,7 @@ export default class Component {
name,
injected: true,
mutated: true,
writable: true,
writable: true
});

this.add_reference(name.slice(1));
Expand Down Expand Up @@ -764,7 +764,7 @@ export default class Component {
if (map.has(node)) {
scope = scope.parent;
}
},
}
});

for (const [parent, prop, index] of to_remove) {
Expand Down Expand Up @@ -832,7 +832,7 @@ export default class Component {
if (map.has(node)) {
scope = scope.parent;
}
},
}
});
}

Expand All @@ -844,7 +844,7 @@ export default class Component {
) {
this.warn(node as any, {
code: 'non-top-level-reactive-declaration',
message: '$: has no effect outside of the top-level',
message: '$: has no effect outside of the top-level'
});
}

Expand Down Expand Up @@ -881,7 +881,7 @@ export default class Component {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body],
body: [node.body]
};
}
node.body.body.push(inside[0]);
Expand All @@ -890,8 +890,8 @@ export default class Component {
type: 'BlockStatement',
body: [
before[0],
node,
],
node
]
};
}
return null;
Expand Down Expand Up @@ -927,7 +927,7 @@ export default class Component {
// TODO is this still true post-#3539?
component.error(declarator as any, {
code: 'destructured-prop',
message: `Cannot declare props in destructured declaration`,
message: `Cannot declare props in destructured declaration`
});
}

Expand Down Expand Up @@ -990,7 +990,7 @@ export default class Component {
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
(parent as Program).body[index] = node.declaration;
}
},
}
});
}

Expand All @@ -1004,7 +1004,7 @@ export default class Component {
hoistable_nodes,
var_lookup,
injected_reactive_declaration_vars,
imports,
imports
} = this;

const top_level_function_declarations = new Map();
Expand Down Expand Up @@ -1136,7 +1136,7 @@ export default class Component {
if (map.has(node)) {
scope = scope.parent;
}
},
}
});

checked.add(fn_declaration);
Expand Down Expand Up @@ -1229,7 +1229,7 @@ export default class Component {
if (map.has(node)) {
scope = scope.parent;
}
},
}
});

const { expression } = node.body as ExpressionStatement;
Expand All @@ -1239,7 +1239,7 @@ export default class Component {
assignees,
dependencies,
node,
declaration,
declaration
});
}
});
Expand Down Expand Up @@ -1320,7 +1320,7 @@ export default class Component {

this.warn(node, {
code: 'missing-declaration',
message,
message
});
}

Expand All @@ -1343,7 +1343,7 @@ function process_component_options(component: Component, nodes) {
'accessors' in component.compile_options
? component.compile_options.accessors
: !!component.compile_options.customElement,
preserveWhitespace: !!component.compile_options.preserveWhitespace,
preserveWhitespace: !!component.compile_options.preserveWhitespace
};

const node = nodes.find(node => node.name === 'svelte:options');
Expand Down Expand Up @@ -1384,7 +1384,7 @@ function process_component_options(component: Component, nodes) {
if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
component.error(attribute, {
code: `invalid-tag-property`,
message: `tag name must be two or more words joined by the '-' character`,
message: `tag name must be two or more words joined by the '-' character`
});
}

Expand Down Expand Up @@ -1412,12 +1412,12 @@ function process_component_options(component: Component, nodes) {
if (match) {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`,
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`
});
} else {
component.error(attribute, {
code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}'`,
message: `Invalid namespace '${ns}'`
});
}
}
Expand All @@ -1443,13 +1443,13 @@ function process_component_options(component: Component, nodes) {
default:
component.error(attribute, {
code: `invalid-options-attribute`,
message: `<svelte:options> unknown attribute`,
message: `<svelte:options> unknown attribute`
});
}
} else {
component.error(attribute, {
code: `invalid-options-attribute`,
message: `<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes`,
message: `<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes`
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-lowercase-name`,
message,
filename,
toString: () => message,
toString: () => message
});
}

Expand All @@ -62,7 +62,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-loop-guard-timeout`,
message,
filename,
toString: () => message,
toString: () => message
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/nodes/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class Binding extends Node {

if (info.expression.type === 'Identifier' && !variable.writable) component.error(this.expression.node, {
code: 'invalid-binding',
message: 'Cannot bind to a variable which is not writable',
message: 'Cannot bind to a variable which is not writable'
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export default class Element extends Node {
if (/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/.test(name)) {
component.error(attribute, {
code: `illegal-attribute`,
message: `'${name}' is not a valid attribute name`,
message: `'${name}' is not a valid attribute name`
});
}

Expand All @@ -423,7 +423,7 @@ export default class Element extends Node {
if (!(parent.type === 'InlineComponent' || within_custom_element(parent))) {
component.error(attribute, {
code: `invalid-slotted-content`,
message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`,
message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compile/nodes/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const elements_without_text = new Set([
'dl',
'optgroup',
'select',
'video',
'video'
]);

export default class Text extends Node {
Expand Down
Loading
0