-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: minor refactor and add integration test (#371)
* chore: minor refactor and add integration test * fix * fix
- Loading branch information
Showing
27 changed files
with
269 additions
and
72 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
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
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
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
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,55 @@ | ||
import flatBase from "./configs/flat/base" | ||
import flatRecommended from "./configs/flat/recommended" | ||
import flatAll from "./configs/flat/all" | ||
import { buildA11yFlatConfigs } from "./a11y" | ||
import type { Linter } from "eslint" | ||
|
||
type ESMConfigs = { | ||
base: Linter.FlatConfig[] | ||
recommended: Linter.FlatConfig[] | ||
all: Linter.FlatConfig[] | ||
"jsx-a11y-strict": Linter.FlatConfig[] | ||
"jsx-a11y-recommended": Linter.FlatConfig[] | ||
// For backward compatibility | ||
"flat/base": Linter.FlatConfig[] | ||
"flat/recommended": Linter.FlatConfig[] | ||
"flat/all": Linter.FlatConfig[] | ||
"flat/jsx-a11y-strict": Linter.FlatConfig[] | ||
"flat/jsx-a11y-recommended": Linter.FlatConfig[] | ||
} | ||
/** | ||
* Build configs for ESM Module | ||
*/ | ||
export function buildEsmConfigs(): ESMConfigs { | ||
const esmConfigs: ESMConfigs = { | ||
base: flatBase as Linter.FlatConfig[], | ||
recommended: flatRecommended as Linter.FlatConfig[], | ||
all: flatAll as Linter.FlatConfig[], | ||
"jsx-a11y-strict": null as never, | ||
"jsx-a11y-recommended": null as never, | ||
// For backward compatibility | ||
"flat/base": flatBase as Linter.FlatConfig[], | ||
"flat/recommended": flatRecommended as Linter.FlatConfig[], | ||
"flat/all": flatAll as Linter.FlatConfig[], | ||
"flat/jsx-a11y-strict": null as never, | ||
"flat/jsx-a11y-recommended": null as never, | ||
} | ||
|
||
const a11yFlatConfigs = buildA11yFlatConfigs() | ||
for (const configName of Object.keys(a11yFlatConfigs)) { | ||
Object.defineProperty(esmConfigs, configName, { | ||
enumerable: true, | ||
get() { | ||
return a11yFlatConfigs[configName] | ||
}, | ||
}) | ||
Object.defineProperty(esmConfigs, `flat/${configName}`, { | ||
enumerable: true, | ||
get() { | ||
return a11yFlatConfigs[configName] | ||
}, | ||
}) | ||
} | ||
|
||
return esmConfigs | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { buildCjsConfigs } from "./plugin-config-builder" | ||
import { meta, rules, processors, environments } from "./plugin-without-config" | ||
import { buildCjsConfigs } from "./cjs-config-builder" | ||
import { plugin } from "./plugin" | ||
const configs = buildCjsConfigs() | ||
export = { meta, configs, rules, processors, environments } | ||
export = Object.assign(plugin, { configs }) |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { buildEsmConfigs } from "./plugin-config-builder" | ||
import { meta, rules, processors, environments } from "./plugin-without-config" | ||
const configs = buildEsmConfigs() | ||
export default { meta, configs, rules, processors, environments } | ||
export { meta, configs, rules, processors, environments } | ||
import { buildEsmConfigs } from "./esm-config-builder" | ||
import { plugin } from "./plugin" | ||
export const configs = buildEsmConfigs() | ||
export default Object.assign(plugin, { configs }) | ||
export const { meta, rules, processors, environments } = plugin |
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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
import { rules as ruleList } from "./utils/rules" | ||
import * as processorsDefines from "./processor" | ||
import type { Rule } from "eslint" | ||
import * as meta from "./meta" | ||
import { environments } from "./environments" | ||
|
||
export * as meta from "./meta" | ||
export { environments } from "./environments" | ||
|
||
export const rules = ruleList.reduce( | ||
const rules = ruleList.reduce( | ||
(obj, r) => { | ||
obj[r.meta.docs.ruleName] = r as never | ||
return obj | ||
}, | ||
{} as { [key: string]: Rule.RuleModule }, | ||
) | ||
|
||
export const processors = { | ||
const processors = { | ||
".astro": processorsDefines.astroProcessor, | ||
astro: processorsDefines.astroProcessor, | ||
"client-side-ts": processorsDefines.clientSideTsProcessor, | ||
} | ||
export const plugin = { | ||
meta, | ||
environments, | ||
rules, | ||
processors, | ||
} |
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 @@ | ||
package-lock=false |
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,6 @@ | ||
import js from "@eslint/js" | ||
import eslintPluginAstro from "eslint-plugin-astro" | ||
export default [ | ||
js.configs.recommended, | ||
...eslintPluginAstro.configs.recommended, | ||
] |
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,26 @@ | ||
[ | ||
{ | ||
"filePath": "src/index.astro", | ||
"messages": [ | ||
{ | ||
"ruleId": "no-unused-vars", | ||
"severity": 2, | ||
"message": "'foo' is assigned a value but never used.", | ||
"line": 2, | ||
"column": 7, | ||
"nodeType": "Identifier", | ||
"messageId": "unusedVar", | ||
"endLine": 2, | ||
"endColumn": 10 | ||
} | ||
], | ||
"suppressedMessages": [], | ||
"errorCount": 1, | ||
"fatalErrorCount": 0, | ||
"warningCount": 0, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"source": "---\nconst foo = {}\n---\n\n<a></a>\n", | ||
"usedDeprecatedRules": [] | ||
} | ||
] |
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,15 @@ | ||
{ | ||
"name": "eslint-plugin-astro-integration-test-for-legacy-config", | ||
"version": "1.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"test": "eslint . --format json" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@eslint/js": "latest", | ||
"eslint": "^9.1.1", | ||
"eslint-plugin-astro": "file:../../../.." | ||
} | ||
} |
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,5 @@ | ||
--- | ||
const foo = {} | ||
--- | ||
|
||
<a></a> |
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,6 @@ | ||
"use strict" | ||
|
||
module.exports = { | ||
root: true, | ||
extends: ["eslint:recommended", "plugin:astro/recommended"], | ||
} |
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 @@ | ||
package-lock=false |
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,26 @@ | ||
[ | ||
{ | ||
"filePath": "src/index.astro", | ||
"messages": [ | ||
{ | ||
"ruleId": "no-unused-vars", | ||
"severity": 2, | ||
"message": "'foo' is assigned a value but never used.", | ||
"line": 2, | ||
"column": 7, | ||
"nodeType": "Identifier", | ||
"messageId": "unusedVar", | ||
"endLine": 2, | ||
"endColumn": 10 | ||
} | ||
], | ||
"suppressedMessages": [], | ||
"errorCount": 1, | ||
"fatalErrorCount": 0, | ||
"warningCount": 0, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"source": "---\nconst foo = {}\n---\n\n<a></a>\n", | ||
"usedDeprecatedRules": [] | ||
} | ||
] |
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,13 @@ | ||
{ | ||
"name": "eslint-plugin-astro-integration-test-for-legacy-config", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"test": "eslint . --format json" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^9.1.1", | ||
"eslint-plugin-astro": "file:../../../.." | ||
} | ||
} |
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,5 @@ | ||
--- | ||
const foo = {} | ||
--- | ||
|
||
<a></a> |
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,3 @@ | ||
{ | ||
"ESLINT_USE_FLAT_CONFIG": false | ||
} |
Oops, something went wrong.