Skip to content

Commit 21dfc90

Browse files
authored
use changesets (#10)
* use changesets * fix * fix * fix * update * update * update * update * fix
1 parent eb92175 commit 21dfc90

22 files changed

+2080
-724
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "@intlify/eslint-plugin-svelte"
7+
}
8+
],
9+
"commit": false,
10+
"linked": [],
11+
"access": "restricted",
12+
"baseBranch": "main",
13+
"updateInternalDependencies": "patch",
14+
"bumpVersionsWithWorkspaceProtocolOnly": true,
15+
"ignore": []
16+
}

.env-cmdrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict'
2+
3+
module.exports = {
4+
'version-ci': {
5+
IN_VERSION_CI_SCRIPT: 'true'
6+
}
7+
}

.github/workflows/NpmPublish.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/Release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
name: Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v4
20+
with:
21+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
22+
fetch-depth: 0
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v2
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
- name: Install Dependencies
30+
run: yarn install
31+
32+
- name: Create Release Pull Request or Publish to npm
33+
id: changesets
34+
uses: changesets/action@v1
35+
with:
36+
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
37+
version: yarn version:ci
38+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
39+
publish: yarn release
40+
commit: 'chore: release @intlify/eslint-plugin-svelte'
41+
title: 'chore: release @intlify/eslint-plugin-svelte'
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Test
22
on:
33
push:
4-
branches-ignore:
5-
- gh-pages
4+
branches: [main]
65
pull_request:
6+
branches: [main]
77
env:
88
CI: true
99

@@ -14,10 +14,8 @@ jobs:
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v2
17-
- name: Setup Node.js 14
17+
- name: Setup Node.js
1818
uses: actions/setup-node@v2
19-
with:
20-
node-version: 14
2119
- name: Install
2220
run: yarn install
2321
- name: Lint
@@ -30,8 +28,8 @@ jobs:
3028
strategy:
3129
matrix:
3230
os: [ubuntu-latest]
33-
node: [12, 14, 16]
34-
eslint: [7, ^8.0.0-0]
31+
node: [18, 20]
32+
eslint: [8]
3533
steps:
3634
- name: Checkout
3735
uses: actions/checkout@v2
@@ -50,3 +48,29 @@ jobs:
5048
run: |
5149
yarn build
5250
yarn test:integrations
51+
test-for-old:
52+
name: 'Test for ESLint ${{ matrix.eslint }} on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
53+
runs-on: ${{ matrix.os }}
54+
strategy:
55+
matrix:
56+
os: [ubuntu-latest]
57+
node: [12, 14, 16]
58+
eslint: [7]
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
- name: Setup Node.js ${{ matrix.node }}
63+
uses: actions/setup-node@v2
64+
with:
65+
node-version: ${{ matrix.node }}
66+
- name: Install
67+
run: yarn install --ignore-engines
68+
- name: Install ESLint ${{ matrix.eslint }}
69+
run: yarn add -D eslint@${{ matrix.eslint }} --ignore-engines
70+
if: matrix.eslint != 7
71+
- name: Test
72+
run: yarn test
73+
- name: Integration Test
74+
run: |
75+
yarn build
76+
yarn test:integrations

docs/.vuepress/components/eslint-code-block.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,12 @@ export default {
130130
this.height = `${Math.max(120, 19 * lines)}px`
131131
132132
// Load linter.
133-
const [
134-
{ default: Linter },
135-
{ default: coreRules },
136-
svelteESLintParser
137-
] = await Promise.all([
138-
import('eslint4b/dist/linter'),
139-
import('eslint4b/dist/core-rules'),
140-
import('espree').then(() => import('svelte-eslint-parser'))
141-
])
133+
const [{ default: Linter }, { default: coreRules }, svelteESLintParser] =
134+
await Promise.all([
135+
import('eslint4b/dist/linter'),
136+
import('eslint4b/dist/core-rules'),
137+
import('espree').then(() => import('svelte-eslint-parser'))
138+
])
142139
143140
const linter = (this.linter = new Linter({ cwd: '/path' }))
144141

lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
*/
55
import configs from './configs'
66
import rules from './rules'
7+
import * as meta from './meta'
78

89
export = {
10+
meta,
911
configs,
1012
rules
1113
}

lib/meta.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* IMPORTANT!
3+
* This file has been automatically generated,
4+
* in order to update its content execute "pnpm run update"
5+
*/
6+
export const name = '@intlify/eslint-plugin-svelte' as const
7+
export const version = '0.2.0' as const

lib/rules/no-raw-text.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { defineRule } from '../utils'
99
type LiteralValue = ESTree.Literal['value']
1010
type StaticTemplateLiteral = ESTree.TemplateLiteral & {
1111
quasis: [ESTree.TemplateElement]
12-
expressions: [/* empty */]
12+
expressions: [
13+
/* empty */
14+
]
1315
}
1416
type TargetAttrs = { name: RegExp; attrs: Set<string> }
1517
type Config = {

lib/types/eslint.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,10 @@ export interface SourceCode extends TokenStore {
137137
getText(node?: NodeWithLoc, beforeCount?: number, afterCount?: number): string
138138
getLines(): string[]
139139
getAllComments(): TokenWithLoc[]
140-
getComments(
141-
node: NodeWithLoc
142-
): { leading: TokenWithLoc[]; trailing: TokenWithLoc[] }
140+
getComments(node: NodeWithLoc): {
141+
leading: TokenWithLoc[]
142+
trailing: TokenWithLoc[]
143+
}
143144
getJSDocComment(node: NodeWithLoc): TokenWithLoc | null
144145
getNodeByRangeIndex(index: number): NodeWithLoc
145146
isSpaceBetweenTokens(first: TokenWithLoc, second: TokenWithLoc): boolean

package.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,29 @@
3737
}
3838
},
3939
"devDependencies": {
40+
"@changesets/changelog-github": "^0.5.0",
41+
"@changesets/cli": "^2.24.2",
42+
"@changesets/get-release-plan": "^4.0.0",
4043
"@types/debug": "^4.1.5",
4144
"@types/eslint": "^7.2.10",
4245
"@types/eslint-scope": "^3.7.0",
4346
"@types/eslint-visitor-keys": "^1.0.0",
44-
"@typescript-eslint/eslint-plugin": "^4.10.0",
45-
"@typescript-eslint/parser": "^4.10.0",
46-
"eslint": "^7.0.0",
47+
"@typescript-eslint/eslint-plugin": "^6.0.0",
48+
"@typescript-eslint/parser": "^6.0.0",
49+
"env-cmd": "^10.1.0",
50+
"eslint": "^8.0.0",
4751
"eslint-config-prettier": "^8.0.0",
4852
"eslint-plugin-markdown": "^2.0.0",
49-
"eslint-plugin-prettier": "^3.1.4",
53+
"eslint-plugin-prettier": "^5.0.0",
5054
"eslint4b": "^7.16.0",
51-
"lerna-changelog": "^1.0.1",
5255
"mocha": "^8.0.0",
5356
"nyc": "^15.0.0",
5457
"opener": "^1.5.1",
55-
"prettier": "^2.0.5",
58+
"prettier": "^3.0.0",
5659
"rimraf": "^3.0.0",
5760
"svelte": "^3.37.0",
5861
"ts-node": "^9.0.0",
59-
"typescript": "^4.0.0",
62+
"typescript": "~5.0.0",
6063
"vue-eslint-editor": "^1.1.0",
6164
"vue-eslint-parser": "^7.6.0",
6265
"vue-github-button": "^1.2.0",
@@ -93,10 +96,14 @@
9396
"generate": "ts-node --transpile-only scripts/update.ts && prettier . --write",
9497
"lint": "eslint . --ext js,ts,vue,md --ignore-pattern \"/tests/fixtures\"",
9598
"lint:docs": "prettier docs --check",
99+
"format": "yarn lint --fix && yarn format:docs",
96100
"format:docs": "prettier docs --write",
97101
"test": "mocha --require ts-node/register \"./tests/**/*.ts\"",
98102
"test:debug": "mocha --require ts-node/register/transpile-only \"./tests/**/*.ts\"",
99103
"test:coverage": "nyc mocha --require ts-node/register \"./tests/**/*.ts\" --timeout 60000",
100-
"test:integrations": "mocha ./tests-integrations/*.js --timeout 60000"
104+
"test:integrations": "mocha ./tests-integrations/*.js --timeout 60000",
105+
"prerelease": "yarn build",
106+
"release": "changeset publish",
107+
"version:ci": "env-cmd -e version-ci yarn generate && changeset version"
101108
}
102109
}

scripts/lib/changesets-util.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import getReleasePlan from '@changesets/get-release-plan'
2+
import path from 'path'
3+
4+
/** Get new version string from changesets */
5+
export async function getNewVersion(): Promise<string> {
6+
const releasePlan = await getReleasePlan(path.resolve(__dirname, '../..'))
7+
8+
return releasePlan.releases.find(
9+
({ name }) => name === '@intlify/eslint-plugin-svelte'
10+
)!.newVersion
11+
}

scripts/lib/write.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import fs from 'fs'
2+
import { ESLint } from 'eslint'
3+
import prettier from 'prettier'
4+
5+
/**
6+
* Write file and format it with ESLint
7+
*/
8+
export function writeAndFormat(
9+
fileName: string,
10+
content: string
11+
): Promise<void> {
12+
fs.writeFileSync(fileName, content, 'utf8')
13+
return prettier
14+
.resolveConfig(fileName)
15+
.then(prettierrc => {
16+
if (!prettierrc) {
17+
return content
18+
}
19+
return prettier.format(content, { filepath: fileName, ...prettierrc })
20+
})
21+
.then(formatted => {
22+
fs.writeFileSync(fileName, formatted, 'utf8')
23+
const eslint = new ESLint({ fix: true })
24+
return eslint.lintText(formatted, { filePath: fileName })
25+
})
26+
.then(([result]) => {
27+
if (result.output) {
28+
fs.writeFileSync(fileName, result.output, 'utf8')
29+
}
30+
})
31+
}

scripts/update-meta.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import path from 'path'
2+
import { name, version } from '../package.json'
3+
import { getNewVersion } from './lib/changesets-util'
4+
import { writeAndFormat } from './lib/write'
5+
6+
const META_PATH = path.join(__dirname, '../lib/meta.ts')
7+
8+
void main()
9+
10+
/** main */
11+
async function main() {
12+
await writeAndFormat(
13+
META_PATH,
14+
`/*
15+
* IMPORTANT!
16+
* This file has been automatically generated,
17+
* in order to update its content execute "pnpm run update"
18+
*/
19+
export const name = ${JSON.stringify(name)} as const;
20+
export const version = ${JSON.stringify(await getVersion())} as const;
21+
`
22+
)
23+
}
24+
25+
/** Get version */
26+
function getVersion() {
27+
// eslint-disable-next-line no-process-env -- ignore
28+
if (process.env.IN_VERSION_CI_SCRIPT) {
29+
return getNewVersion()
30+
}
31+
return version
32+
}

0 commit comments

Comments
 (0)