Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Jan 11, 2024
1 parent 26a3823 commit 50e6b6b
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 26 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 👔 Format

on:
workflow_dispatch: null

permissions:
contents: write

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
- name: Install deps
run: pnpm install -f
- name: Format
run: pnpm run lint-fix
- name: Commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
if [ -z "$(git status --porcelain)" ]; then
echo "no formatting changed"
exit 0
fi
git commit -m "chore: format"
git push
echo "pushed formatting changes https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"
2 changes: 1 addition & 1 deletion docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
? async () => {
tsParser = await loadTsParser();
return loadLinter;
}
}
: () => loadLinter
);
let showDiff = fix;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@
"nyc": "^15.1.0",
"pako": "^2.0.3",
"postcss-nested": "^6.0.0",
"prettier": "^3.0.0",
"prettier": "^3.1.1",
"prettier-plugin-pkg": "^0.18.0",
"prettier-plugin-svelte": "^3.0.0",
"prettier-plugin-svelte": "^3.1.2",
"prism-svelte": "^0.5.0",
"prismjs": "^1.25.0",
"rimraf": "^5.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/rules/html-closing-bracket-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export default createRule('html-closing-bracket-spacing', {
node.type === 'SvelteEndTag'
? 'endTag'
: node.selfClosing
? 'selfClosingTag'
: 'startTag';
? 'selfClosingTag'
: 'startTag';

if (options[tagType] === 'ignore') return;

Expand Down
8 changes: 4 additions & 4 deletions src/rules/indent-helpers/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ export function defineVisitor(context: IndentContext): NodeListener {
? sourceCode.getTokenBefore(node.source, {
filter: isClosingBraceToken,
includeComments: false
})!
})!
: sourceCode.getLastToken(node, {
filter: isClosingBraceToken,
includeComments: false
})!;
})!;
offsets.setOffsetToken(leftBraceTokens, 0, exportToken);
offsets.setOffsetElementList(
node.specifiers,
Expand Down Expand Up @@ -535,12 +535,12 @@ export function defineVisitor(context: IndentContext): NodeListener {
fromToken: tokens[fromIndex],
beforeTokens: tokens.slice(0, fromIndex),
afterTokens: [...tokens.slice(fromIndex + 1), sourceCode.getFirstToken(node.source)]
}
}
: {
fromToken: null,
beforeTokens: [...tokens, sourceCode.getFirstToken(node.source)],
afterTokens: []
};
};

const namedSpecifiers: TSESTree.ImportSpecifier[] = [];
for (const specifier of node.specifiers) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/indent-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export function defineVisitor(
actualUnit: mismatchCharIndexes.length
? 'whitespace'
: options.indentChar === '\t'
? 'tab'
: 'space',
? 'tab'
: 'space',
expectedIndentPlural: expectedIndent === 1 ? '' : 's',
actualIndentPlural: actualIndent === 1 ? '' : 's'
},
Expand Down
4 changes: 2 additions & 2 deletions src/rules/mustache-spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default createRule('mustache-spacing', {
? sourceCode.getTokenAfter(openBlockLast, {
includeComments: false,
filter: isClosingBraceToken
})
})
: null;
verifyBraces(
openBlockOpeningToken,
Expand All @@ -384,7 +384,7 @@ export default createRule('mustache-spacing', {
? sourceCode.getTokenAfter(openBlockLast, {
includeComments: false,
filter: isClosingBraceToken
})
})
: null;
verifyBraces(
openBlockOpeningToken,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-trailing-spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default createRule('no-trailing-spaces', {
...(ignoreComments
? {
SvelteHTMLComment: collectIgnoreLineNumbers
}
}
: {}),
'Program:exit'() {
const lines = sourceCode.lines;
Expand Down
4 changes: 2 additions & 2 deletions src/rules/shorthand-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default createRule('shorthand-attribute', {
});
}
}
}
}
: {
SvelteShorthandAttribute(node) {
context.report({
Expand All @@ -70,6 +70,6 @@ export default createRule('shorthand-attribute', {
}
});
}
};
};
}
});
8 changes: 4 additions & 4 deletions src/shared/svelte-compile-warns/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ function* transformScripts(context: RuleContext, text: string) {
? transformWithTypescript
: transformWithBabel
: isUseBabel(context)
? transformWithBabel
: null;
? transformWithBabel
: null;

const sourceCode = getSourceCode(context);
if (transform) {
Expand Down Expand Up @@ -431,8 +431,8 @@ function getWarningsFromCode(
...(semver.satisfies(compiler.VERSION, '>=4.0.0-0')
? { customElement: true }
: hasTagOption(getSourceCode(context).ast)
? { customElement: true }
: {})
? { customElement: true }
: {})
});

return { warnings: result.warnings as Warning[], kind: 'warn' };
Expand Down
12 changes: 6 additions & 6 deletions tests/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function loadTestCases(
pkgName === 'node'
? { version: process.version }
: // eslint-disable-next-line @typescript-eslint/no-require-imports -- test
require(`${pkgName}/package.json`);
require(`${pkgName}/package.json`);
return !semver.satisfies(pkg.version, pkgVersion);
})
) {
Expand Down Expand Up @@ -206,8 +206,8 @@ function writeFixtures(ruleName: string, inputFile: string, { force }: { force?:
path.extname(inputFile) === '.svelte'
? 'svelte-eslint-parser'
: path.extname(inputFile) === '.ts'
? '@typescript-eslint/parser'
: undefined;
? '@typescript-eslint/parser'
: undefined;
const { code, filename, options, ...verifyConfig } = config;
const result = linter.verify(
code,
Expand Down Expand Up @@ -244,7 +244,7 @@ function writeFixtures(ruleName: string, inputFile: string, { force }: { force?:
messageId: s.messageId,
// Need to have this be the *fixed* output, not just the fix content or anything
output: applySuggestion(config.code, s)
}))
}))
: null
}))
)}`
Expand Down Expand Up @@ -286,8 +286,8 @@ function getConfig(ruleName: string, inputFile: string) {
path.extname(filename) === '.svelte'
? require.resolve('svelte-eslint-parser')
: path.extname(inputFile) === '.ts'
? require.resolve('@typescript-eslint/parser')
: undefined;
? require.resolve('@typescript-eslint/parser')
: undefined;

return Object.assign(
{
Expand Down

0 comments on commit 50e6b6b

Please sign in to comment.