Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-svelte

Package Overview
Dependencies
Maintainers
0
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-svelte - npm Package Compare versions

Comparing version 2.39.5 to 2.40.0

2

lib/meta.d.ts
export declare const name = "eslint-plugin-svelte";
export declare const version = "2.39.5";
export declare const version = "2.40.0";

@@ -8,2 +8,2 @@ "use strict";

exports.name = 'eslint-plugin-svelte';
exports.version = '2.39.5';
exports.version = '2.40.0';

@@ -52,6 +52,6 @@ "use strict";

const styleContext = sourceCode.parserServices.getStyleContext();
if (['parse-error', 'unknown-lang'].includes(styleContext.status)) {
if (styleContext.status === 'parse-error' || styleContext.status === 'unknown-lang') {
return;
}
const classesUsedInStyle = styleContext.sourceAst != null ? findClassesInPostCSSNode(styleContext.sourceAst) : [];
const classesUsedInStyle = styleContext.status === 'success' ? findClassesInPostCSSNode(styleContext.sourceAst) : [];
for (const className in classesUsedInTemplate) {

@@ -58,0 +58,0 @@ if (!allowedClassNames.includes(className) && !classesUsedInStyle.includes(className)) {

@@ -26,5 +26,16 @@ "use strict";

create(context) {
if (!(0, compat_1.getSourceCode)(context).parserServices.isSvelte) {
const sourceCode = (0, compat_1.getSourceCode)(context);
if (!sourceCode.parserServices.isSvelte) {
return {};
}
const onwarn = sourceCode.parserServices.svelteParseContext?.svelteConfig?.onwarn;
const transform = onwarn
? (warning) => {
if (!warning.code)
return warning;
let result = null;
onwarn(warning, (reportWarn) => (result = reportWarn));
return result;
}
: (warning) => warning;
const ignoreWarnings = Boolean(context.options[0]?.ignoreWarnings);

@@ -41,3 +52,3 @@ const ignores = [

*/
function report(warnings) {
function report({ warnings, kind }) {
for (const warn of warnings) {

@@ -47,8 +58,12 @@ if (warn.code && ignores.includes(warn.code)) {

}
const reportWarn = kind === 'warn' ? transform(warn) : warn;
if (!reportWarn) {
continue;
}
context.report({
loc: {
start: warn.start || warn.end || { line: 1, column: 0 },
end: warn.end || warn.start || { line: 1, column: 0 }
start: reportWarn.start || reportWarn.end || { line: 1, column: 0 },
end: reportWarn.end || reportWarn.start || { line: 1, column: 0 }
},
message: `${warn.message}${warn.code ? `(${warn.code})` : ''}`
message: `${reportWarn.message}${reportWarn.code ? `(${reportWarn.code})` : ''}`
});

@@ -63,3 +78,3 @@ }

}
report(result.warnings);
report(result);
}

@@ -66,0 +81,0 @@ };

@@ -14,2 +14,3 @@ import type { AST } from 'svelte-eslint-parser';

column: number;
character: number;
};

@@ -19,8 +20,12 @@ end?: {

column: number;
character: number;
};
};
export type Warning = {
code?: string;
export type Warning = ({
code: string;
message: string;
} & Loc;
} | {
code?: undefined;
message: string;
}) & Loc;
/**

@@ -27,0 +32,0 @@ * Get svelte compile warnings

@@ -195,3 +195,3 @@ "use strict";

if (remapped) {
start = sourceCode.getLocFromIndex(remapped);
start = { ...sourceCode.getLocFromIndex(remapped), character: remapped };
}

@@ -203,3 +203,4 @@ }

if (remapped) {
end = sourceCode.getLocFromIndex(remapped + 1 /* restore */);
const character = remapped + 1; /* restore */
end = { ...sourceCode.getLocFromIndex(character), character };
}

@@ -206,0 +207,0 @@ }

@@ -31,2 +31,3 @@ "use strict";

preserveValueImports: true,
verbatimModuleSyntax: true,
sourceMap: true

@@ -33,0 +34,0 @@ }

import type { JSONSchema4 } from 'json-schema';
import type { Linter, Rule, SourceCode as ESLintSourceCode } from 'eslint';
import type { AST } from 'svelte-eslint-parser';
import type { AST, StyleContext, SvelteConfig } from 'svelte-eslint-parser';
import type { TSESTree } from '@typescript-eslint/types';
import type { ScopeManager, Scope, Variable } from '@typescript-eslint/scope-manager';
import type { ASTNode, ASTNodeWithParent, ASTNodeListener } from './types-for-node';
import type * as TS from 'typescript';
export type { ASTNode, ASTNodeWithParent, ASTNodeListener };

@@ -164,3 +165,25 @@ export interface RuleListener extends ASTNodeListener {

hasBOM: boolean;
parserServices: ESLintSourceCode.ParserServices;
parserServices: {
isSvelte?: boolean;
isSvelteScript?: boolean;
getSvelteHtmlAst?: () => unknown;
getStyleContext?: () => StyleContext;
svelteParseContext?: {
/**
* Whether to use Runes mode.
* May be `true` if the user is using Svelte v5.
* Resolved from `svelte.config.js` or `parserOptions`, but may be overridden by `<svelte:options>`.
*/
runes?: boolean;
/** The version of "svelte/compiler". */
compilerVersion?: string;
/** The result of static analysis of `svelte.config.js`. */
svelteConfig?: SvelteConfig | null;
};
program?: TS.Program;
esTreeNodeToTSNodeMap?: ReadonlyMap<unknown, TS.Node>;
tsNodeToESTreeNodeMap?: ReadonlyMap<TS.Node, ASTNode>;
hasFullTypeInformation?: boolean;
[key: string]: unknown;
};
scopeManager: ScopeManager;

@@ -167,0 +190,0 @@ visitorKeys: ESLintSourceCode.VisitorKeys;

@@ -26,3 +26,4 @@ "use strict";

return false;
const routes = context.settings?.svelte?.kit?.files?.routes?.replace(/^\//, '') ?? 'src/routes';
const routes = (context.settings?.svelte?.kit?.files?.routes ??
(0, compat_1.getSourceCode)(context).parserServices.svelteParseContext?.svelteConfig?.kit?.files?.routes)?.replace(/^\//, '') ?? 'src/routes';
const filePath = (0, compat_1.getFilename)(context);

@@ -29,0 +30,0 @@ const projectRootDir = getProjectRootDir((0, compat_1.getFilename)(context)) ?? '';

{
"name": "eslint-plugin-svelte",
"version": "2.39.5",
"version": "2.40.0",
"description": "ESLint plugin for Svelte using AST",

@@ -69,3 +69,3 @@ "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git",

"semver": "^7.6.2",
"svelte-eslint-parser": "^0.38.0"
"svelte-eslint-parser": "^0.39.1"
},

@@ -72,0 +72,0 @@ "devDependencies": {

@@ -232,2 +232,32 @@ # Introduction

#### Specify `svelte.config.js`
If you are using `eslint.config.js`, we recommend that you import and specify `svelte.config.js`.
By specifying it, some rules of `eslint-plugin-svelte` will read it and try to behave well for you by default.
Some Svelte configurations will be statically loaded from `svelte.config.js` even if you don't specify it, but you need to specify it to make it work better.
Example **eslint.config.js**:
```js
import eslintPluginSvelte from 'eslint-plugin-svelte';
import svelteConfig from './svelte.config.js';
export default [
...eslintPluginSvelte.configs['flat/recommended'],
{
files: [
'**/*.svelte',
'*.svelte'
// Add more files if you need.
// '**/*.svelte.ts', '*.svelte.ts', '**/*.svelte.js', '*.svelte.js',
],
languageOptions: {
parserOptions: {
// Specify the `svelte.config.js`.
svelteConfig
}
}
}
];
```
#### settings.svelte

@@ -278,2 +308,8 @@

::: warning
Even if you don't specify `settings.svelte.kit`, the rules will try to load information from `svelte.config.js`, so specify `settings.svelte.kit` if the default doesn't work.
:::
If you use SvelteKit with not default configuration, you need to set below configurations.

@@ -280,0 +316,0 @@ The schema is subset of SvelteKit's configuration.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc