-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into migrationForumUpdates
# Conflicts: # astro/src/content/docs/apis/users.mdx # astro/src/content/docs/lifecycle/migrate-users/general-migration.mdx # astro/src/content/docs/lifecycle/migrate-users/index.mdx # astro/src/content/docs/lifecycle/migrate-users/provider-specific/cognito.mdx
- Loading branch information
Showing
458 changed files
with
15,251 additions
and
14,961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Runs the linter on the changed files in the PR | ||
name: Run ESLint on changed files | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run_lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# I want to lint only the files that have changed in the PR | ||
# This is a bit tricky because we need to fetch the main branch to compare against | ||
# Instead I am using the GitHub cli to fetch the changes in the PR | ||
- name: Install GitHub CLI | ||
run: sudo apt-get install gh | ||
|
||
- name: Authenticate GitHub CLI | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | ||
|
||
- name: Set Pull Request Number | ||
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | ||
|
||
- name: NPM Install | ||
run: | | ||
cd astro | ||
npm ci | ||
shell: bash | ||
|
||
- name: ESLint | ||
run: | | ||
cd astro | ||
npm run lint-pr | ||
shell: /usr/bin/bash -e -o pipefail {0} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import remarkLint from 'remark-lint'; | ||
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'; | ||
import { lintRule } from 'unified-lint-rule'; | ||
import { visitParents } from 'unist-util-visit-parents'; | ||
|
||
const htmlTagsWithMarkdownEquivalents = [ | ||
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', // Headings | ||
'p', // Paragraphs | ||
'br', // Line Breaks | ||
'strong', 'b', // Bold | ||
'em', 'i', // Italic | ||
'blockquote', // Blockquote | ||
'ol', 'ul', 'li', // Lists | ||
'code', // Inline Code | ||
'pre', // Code Block | ||
'hr', // Horizontal Rule | ||
'a', // Links | ||
'img' // Images | ||
]; | ||
|
||
const invalidAnchorAttributes = ['href', 'title']; | ||
const invalidImageAttributes = ['src', 'alt', 'title']; | ||
const checkIfHtml = (node, parents, file) => { | ||
if (!node.position) return | ||
|
||
// Is this html-ish? | ||
if (/^[\t ]*<!--/.test(node.value)) return | ||
|
||
const name = node.name; | ||
// check if name starts with a capital letter | ||
const isComponent = /^[A-Z]/.test(name); | ||
// check if the tag has no markdown equivalent | ||
const tagHasNoMarkdownEquivalent = !htmlTagsWithMarkdownEquivalents.includes(name); | ||
if (isComponent || tagHasNoMarkdownEquivalent) return; | ||
|
||
// check for attributes on the tags a and img | ||
if (name === 'a' && node.attributes.find(attr => !invalidAnchorAttributes.includes(attr.name))) { | ||
return; | ||
} | ||
|
||
if (name === 'img' && node.attributes.find(attr => !invalidImageAttributes.includes(attr.name))) { | ||
return; | ||
} | ||
|
||
file.message(`Unexpected HTML tag [${name}], use markdown instead`, { | ||
ancestors: [...parents, node], | ||
place: node.position | ||
}); | ||
} | ||
|
||
// this is the lint rule definition | ||
const noHtml = lintRule( | ||
{ | ||
origin: 'remark-lint:no-html', | ||
}, | ||
|
||
function (tree, file) { | ||
//console.log(tree); | ||
visitParents(tree, 'mdxJsxFlowElement', function (node, parents) { | ||
checkIfHtml(node, parents, file); | ||
}) | ||
|
||
visitParents(tree, 'paragraph', function (node, parents) { | ||
[...node.children].forEach((child) => { | ||
if (child.type === 'mdxJsxTextElement') { | ||
checkIfHtml(child, parents, file); | ||
} | ||
}); | ||
}) | ||
} | ||
) | ||
|
||
const remarkConfig = { | ||
plugins: [ | ||
remarkLint, | ||
remarkPresetLintRecommended, | ||
noHtml | ||
] | ||
}; | ||
|
||
export default remarkConfig; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import * as mdx from 'eslint-plugin-mdx'; | ||
import eslintPluginAstro from 'eslint-plugin-astro'; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import astroParser from 'astro-eslint-parser'; | ||
|
||
export default [ | ||
{files: ["**/*.{js,mjs,cjs,ts,md,mdx}"]}, | ||
{languageOptions: { globals: globals.browser }}, | ||
{ | ||
...pluginJs.configs.recommended, | ||
files: ["**/*.{js,mjs,cjs}"] | ||
}, | ||
...(tseslint.configs.recommended.map(config => ({ | ||
...config, | ||
files: ["**/*.ts"] | ||
}))), | ||
{ | ||
name: 'ts-overrides', | ||
rules: { | ||
} | ||
}, | ||
...(eslintPluginAstro.configs['flat/base'].map(config => { | ||
return { | ||
...config, | ||
files: ["**/*.astro"], | ||
languageOptions: { | ||
parser: astroParser, | ||
parserOptions: { | ||
parser: tsParser, | ||
extraFileExtensions: ['.astro'], | ||
project: './tsconfig.json', | ||
sourceType: 'module', | ||
} | ||
} | ||
}})), | ||
{ | ||
...mdx.flat, | ||
// optional, if you want to lint code blocks at the same | ||
processor: mdx.createRemarkProcessor({ | ||
lintCodeBlocks: false, | ||
// optional, if you want to disable language mapper, set it to `false` | ||
// if you want to override the default language mapper inside, you can provide your own | ||
languageMapper: {}, | ||
}), | ||
rules: { | ||
...mdx.flat.rules, | ||
// if you want to override some rules for md/mdx files | ||
'mdx/remark': 'error', | ||
'no-unused-expressions': 'off', | ||
'remark-lint-no-undefined-references': 'off', | ||
'no-undef': 'off', | ||
} | ||
}, | ||
{ | ||
files: ['**/*.astro'], | ||
languageOptions: { | ||
parser: astroParser, | ||
parserOptions: { | ||
parser: tsParser, | ||
extraFileExtensions: ['.astro'], | ||
project: './tsconfig.json', | ||
sourceType: 'module', | ||
} | ||
} | ||
} | ||
]; |
Oops, something went wrong.