Skip to content

use changesets #10

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 9 commits into from
Jan 13, 2024
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
16 changes: 16 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "@intlify/eslint-plugin-svelte"
}
],
"commit": false,
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"bumpVersionsWithWorkspaceProtocolOnly": true,
"ignore": []
}
7 changes: 7 additions & 0 deletions .env-cmdrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

module.exports = {
'version-ci': {
IN_VERSION_CI_SCRIPT: 'true'
}
}
27 changes: 0 additions & 27 deletions .github/workflows/NpmPublish.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write
issues: write
pull-requests: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Install Dependencies
run: yarn install

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
version: yarn version:ci
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
commit: 'chore: release @intlify/eslint-plugin-svelte'
title: 'chore: release @intlify/eslint-plugin-svelte'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
29 changes: 0 additions & 29 deletions .github/workflows/release.yml

This file was deleted.

38 changes: 31 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Test
on:
push:
branches-ignore:
- gh-pages
branches: [main]
pull_request:
branches: [main]
env:
CI: true

Expand All @@ -14,10 +14,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js 14
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install
run: yarn install
- name: Lint
Expand All @@ -30,8 +28,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [12, 14, 16]
eslint: [7, ^8.0.0-0]
node: [18, 20]
eslint: [8]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -50,3 +48,29 @@ jobs:
run: |
yarn build
yarn test:integrations
test-for-old:
name: 'Test for ESLint ${{ matrix.eslint }} on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [12, 14, 16]
eslint: [7]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Install
run: yarn install --ignore-engines
- name: Install ESLint ${{ matrix.eslint }}
run: yarn add -D eslint@${{ matrix.eslint }} --ignore-engines
if: matrix.eslint != 7
- name: Test
run: yarn test
- name: Integration Test
run: |
yarn build
yarn test:integrations
15 changes: 6 additions & 9 deletions docs/.vuepress/components/eslint-code-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,12 @@ export default {
this.height = `${Math.max(120, 19 * lines)}px`

// Load linter.
const [
{ default: Linter },
{ default: coreRules },
svelteESLintParser
] = await Promise.all([
import('eslint4b/dist/linter'),
import('eslint4b/dist/core-rules'),
import('espree').then(() => import('svelte-eslint-parser'))
])
const [{ default: Linter }, { default: coreRules }, svelteESLintParser] =
await Promise.all([
import('eslint4b/dist/linter'),
import('eslint4b/dist/core-rules'),
import('espree').then(() => import('svelte-eslint-parser'))
])

const linter = (this.linter = new Linter({ cwd: '/path' }))

Expand Down
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*/
import configs from './configs'
import rules from './rules'
import * as meta from './meta'

export = {
meta,
configs,
rules
}
7 changes: 7 additions & 0 deletions lib/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update its content execute "pnpm run update"
*/
export const name = '@intlify/eslint-plugin-svelte' as const
export const version = '0.2.0' as const
4 changes: 3 additions & 1 deletion lib/rules/no-raw-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { defineRule } from '../utils'
type LiteralValue = ESTree.Literal['value']
type StaticTemplateLiteral = ESTree.TemplateLiteral & {
quasis: [ESTree.TemplateElement]
expressions: [/* empty */]
expressions: [
/* empty */
]
}
type TargetAttrs = { name: RegExp; attrs: Set<string> }
type Config = {
Expand Down
7 changes: 4 additions & 3 deletions lib/types/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ export interface SourceCode extends TokenStore {
getText(node?: NodeWithLoc, beforeCount?: number, afterCount?: number): string
getLines(): string[]
getAllComments(): TokenWithLoc[]
getComments(
node: NodeWithLoc
): { leading: TokenWithLoc[]; trailing: TokenWithLoc[] }
getComments(node: NodeWithLoc): {
leading: TokenWithLoc[]
trailing: TokenWithLoc[]
}
getJSDocComment(node: NodeWithLoc): TokenWithLoc | null
getNodeByRangeIndex(index: number): NodeWithLoc
isSpaceBetweenTokens(first: TokenWithLoc, second: TokenWithLoc): boolean
Expand Down
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,29 @@
}
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.24.2",
"@changesets/get-release-plan": "^4.0.0",
"@types/debug": "^4.1.5",
"@types/eslint": "^7.2.10",
"@types/eslint-scope": "^3.7.0",
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"eslint": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"env-cmd": "^10.1.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^8.0.0",
"eslint-plugin-markdown": "^2.0.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-prettier": "^5.0.0",
"eslint4b": "^7.16.0",
"lerna-changelog": "^1.0.1",
"mocha": "^8.0.0",
"nyc": "^15.0.0",
"opener": "^1.5.1",
"prettier": "^2.0.5",
"prettier": "^3.0.0",
"rimraf": "^3.0.0",
"svelte": "^3.37.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.0",
"typescript": "~5.0.0",
"vue-eslint-editor": "^1.1.0",
"vue-eslint-parser": "^7.6.0",
"vue-github-button": "^1.2.0",
Expand Down Expand Up @@ -93,10 +96,14 @@
"generate": "ts-node --transpile-only scripts/update.ts && prettier . --write",
"lint": "eslint . --ext js,ts,vue,md --ignore-pattern \"/tests/fixtures\"",
"lint:docs": "prettier docs --check",
"format": "yarn lint --fix && yarn format:docs",
"format:docs": "prettier docs --write",
"test": "mocha --require ts-node/register \"./tests/**/*.ts\"",
"test:debug": "mocha --require ts-node/register/transpile-only \"./tests/**/*.ts\"",
"test:coverage": "nyc mocha --require ts-node/register \"./tests/**/*.ts\" --timeout 60000",
"test:integrations": "mocha ./tests-integrations/*.js --timeout 60000"
"test:integrations": "mocha ./tests-integrations/*.js --timeout 60000",
"prerelease": "yarn build",
"release": "changeset publish",
"version:ci": "env-cmd -e version-ci yarn generate && changeset version"
}
}
11 changes: 11 additions & 0 deletions scripts/lib/changesets-util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import getReleasePlan from '@changesets/get-release-plan'
import path from 'path'

/** Get new version string from changesets */
export async function getNewVersion(): Promise<string> {
const releasePlan = await getReleasePlan(path.resolve(__dirname, '../..'))

return releasePlan.releases.find(
({ name }) => name === '@intlify/eslint-plugin-svelte'
)!.newVersion
}
31 changes: 31 additions & 0 deletions scripts/lib/write.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fs from 'fs'
import { ESLint } from 'eslint'
import prettier from 'prettier'

/**
* Write file and format it with ESLint
*/
export function writeAndFormat(
fileName: string,
content: string
): Promise<void> {
fs.writeFileSync(fileName, content, 'utf8')
return prettier
.resolveConfig(fileName)
.then(prettierrc => {
if (!prettierrc) {
return content
}
return prettier.format(content, { filepath: fileName, ...prettierrc })
})
.then(formatted => {
fs.writeFileSync(fileName, formatted, 'utf8')
const eslint = new ESLint({ fix: true })
return eslint.lintText(formatted, { filePath: fileName })
})
.then(([result]) => {
if (result.output) {
fs.writeFileSync(fileName, result.output, 'utf8')
}
})
}
32 changes: 32 additions & 0 deletions scripts/update-meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'path'
import { name, version } from '../package.json'
import { getNewVersion } from './lib/changesets-util'
import { writeAndFormat } from './lib/write'

const META_PATH = path.join(__dirname, '../lib/meta.ts')

void main()

/** main */
async function main() {
await writeAndFormat(
META_PATH,
`/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update its content execute "pnpm run update"
*/
export const name = ${JSON.stringify(name)} as const;
export const version = ${JSON.stringify(await getVersion())} as const;
`
)
}

/** Get version */
function getVersion() {
// eslint-disable-next-line no-process-env -- ignore
if (process.env.IN_VERSION_CI_SCRIPT) {
return getNewVersion()
}
return version
}
Loading