Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
12 changes: 9 additions & 3 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
env:
project_root_path: ./packages/eslint-plugin-svelte

defaults:
run:
# Setting every runner to bash simplifies command calls;
# plus, every platform supports it
shell: bash

jobs:
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -51,7 +57,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
eslint: [8, 9]
node: [18.x, 20.x, 22.x, latest]
steps:
Expand Down Expand Up @@ -84,7 +90,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
eslint: [9]
node: [18, 20, 22]
steps:
Expand Down Expand Up @@ -115,7 +121,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
node: [18]
steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"typescript.tsdk": "node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"files.eol": "\n"
}
4 changes: 3 additions & 1 deletion packages/eslint-plugin-svelte/src/rules/no-unused-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type ts from 'typescript';
import { findVariable } from '../utils/ast-utils.js';
import { toRegExp } from '../utils/regexp.js';
import { normalize } from 'path';

type PropertyPathArray = string[];
type DeclaredPropertyNames = Set<{ originalName: string; aliasName: string }>;
Expand Down Expand Up @@ -75,11 +76,11 @@

const options = context.options[0] ?? {};

// TODO: Remove in v4

Check warning on line 79 in packages/eslint-plugin-svelte/src/rules/no-unused-props.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected 'todo' comment: 'TODO: Remove in v4'
// MEMO: `ignorePatterns` was a property that only existed from v3.2.0 to v3.2.2.
// From v3.3.0, it was replaced with `ignorePropertyPatterns` and `ignoreTypePatterns`.
if (options.ignorePatterns != null && !isRemovedWarningShown) {
console.warn(

Check warning on line 83 in packages/eslint-plugin-svelte/src/rules/no-unused-props.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
'eslint-plugin-svelte: The `ignorePatterns` option in the `no-unused-props` rule has been removed. Please use `ignorePropertyPatterns` or/and `ignoreTypePatterns` instead.'
);
isRemovedWarningShown = true;
Expand Down Expand Up @@ -122,7 +123,8 @@
const declarations = symbol.getDeclarations();
if (!declarations || declarations.length === 0) return false;

return declarations.every((decl) => decl.getSourceFile().fileName === fileName);
// TypeScript declaration file name is normalized to support Windows style paths
return declarations.every((decl) => normalize(decl.getSourceFile().fileName) === fileName);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions packages/eslint-plugin-svelte/src/rules/valid-style-parse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRule } from '../utils/index.js';
import path from 'path';

export default createRule('valid-style-parse', {
meta: {
Expand All @@ -16,15 +17,20 @@ export default createRule('valid-style-parse', {
if (!sourceCode.parserServices.isSvelte) {
return {};
}
const cwd = `${context.cwd ?? process.cwd()}/`;
const cwd = `${context.cwd ?? process.cwd()}${path.sep}`;

return {
SvelteStyleElement(node) {
const styleContext = sourceCode.parserServices.getStyleContext!();
if (styleContext.status === 'parse-error') {
// This will replace backslashes to forward slashes only
// if Node.js reports Windows style path separators
let message = styleContext.error.message.replace(cwd, '');
if (path.sep === '\\') message = message.replace(/\\/g, '/');

context.report({
loc: node.loc,
message: `Error parsing style element. Error message: "${styleContext.error.message.replace(cwd, '')}"`
message: `Error parsing style element. Error message: "${message}"`
});
}
if (styleContext.status === 'unknown-lang') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
// https://github.com/typescript-eslint/typescript-eslint/blob/78467fc1bde9bd2db1e08b3d19f151f4adaff8a9/packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts
/* eslint func-style: off, eslint-plugin/consistent-output: off -- respect original */
import * as path from 'path';
import { fileURLToPath } from 'url';
import { RuleTester } from '../../../../utils/eslint-compat.js';
import type * as eslint from 'eslint';
import * as typescriptParser from '@typescript-eslint/parser';

import rule from '../../../../../src/rules/@typescript-eslint/no-unnecessary-condition.js';

const __dirname = path.dirname(new URL(import.meta.url).pathname);
const url = new URL(import.meta.url);
const __dirname = path.dirname(fileURLToPath(url));

function getFixturesRootDir(): string {
return path.join(__dirname, 'fixtures');
Expand Down
6 changes: 4 additions & 2 deletions packages/eslint-plugin-svelte/tests/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import * as svelteParser from 'svelte-eslint-parser';
import * as typescriptParser from '@typescript-eslint/parser';
import Module from 'module';
import globals from 'globals';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(new URL(import.meta.url).pathname);
const __dirname = path.dirname(fileURLToPath(new URL(import.meta.url)));
const require = Module.createRequire(import.meta.url);

/**
Expand Down Expand Up @@ -304,7 +305,8 @@ function writeFixtures(
}

function getConfig(ruleName: string, inputFile: string) {
const filename = inputFile.slice(inputFile.indexOf(ruleName));
// ruleName is normalized to support Windows style paths
const filename = inputFile.slice(inputFile.indexOf(path.normalize(ruleName)));
const code = fs.readFileSync(inputFile, 'utf8');
let config;
let configFile = [
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin-svelte/tools/update-meta.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from 'path';
import { fileURLToPath } from 'url';
import { name, version } from '../package.json';
import { getNewVersion } from './lib/changesets-util.js';
import { writeAndFormat } from './lib/write.js';

const __dirname = path.dirname(new URL(import.meta.url).pathname);
const META_PATH = path.join(__dirname, '../src/meta.ts');
const fileURL = new URL('../src/meta.ts', import.meta.url);
const META_PATH = fileURLToPath(fileURL);

void main();

Expand Down
1 change: 1 addition & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

module.exports = {
endOfLine: 'lf',
useTabs: true,
singleQuote: true,
trailingComma: 'none',
Expand Down
Loading