Skip to content
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

chore: use eslint v9 and flat config #221

Merged
merged 1 commit into from
Jun 23, 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
19 changes: 0 additions & 19 deletions .eslintignore

This file was deleted.

155 changes: 0 additions & 155 deletions .eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/GHPages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Packages
run: npm install
- name: Build
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -31,16 +31,22 @@ jobs:
run: npm install
- name: Test
run: npm test
test-with-eslint9:
test-with-eslint8:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Target Packages
run: |+
npm i -D eslint@^9.0.0-0 -f
npm i -D eslint@8
npx rimraf node_modules
npm install -f
npm install
- name: Test
run: npm test
test-with-eslint6:
Expand Down Expand Up @@ -70,8 +76,8 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Target Packages
run: |+
npm i -D eslint@^7 -f
npm i -D eslint@^7
npx rimraf node_modules
npm install -f
npm install
- name: Test
run: npm test
6 changes: 1 addition & 5 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 16
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 16

- name: Install Dependencies
run: npm install

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
package-lock=false
package-lock=false
force=true
94 changes: 54 additions & 40 deletions docs/.vitepress/theme/components/components/EslintPluginEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,54 +73,68 @@ export default {

computed: {
config() {
return {
globals: {
// ES2015 globals
ArrayBuffer: false,
DataView: false,
Float32Array: false,
Float64Array: false,
Int16Array: false,
Int32Array: false,
Int8Array: false,
Map: false,
Promise: false,
Proxy: false,
Reflect: false,
Set: false,
Symbol: false,
Uint16Array: false,
Uint32Array: false,
Uint8Array: false,
Uint8ClampedArray: false,
WeakMap: false,
WeakSet: false,
// ES2017 globals
Atomics: false,
SharedArrayBuffer: false,
return [
{
files: ["*.toml", "**/*.toml"],
languageOptions: {
parser: this.tomlESLintParser,
},
},
rules: this.rules,
parser: this.parser,
parserOptions: {
parser: this.espree,
sourceType: "module",
ecmaVersion: "latest",
{
files: ["*.vue", "**/*.vue"],
languageOptions: {
parser: this.vueESLintParser,
},
},
};
{
plugins: {
toml: {
rules: Object.fromEntries(
rules.map((rule) => [rule.meta.docs.ruleName, rule]),
),
},
},
rules: this.rules,
languageOptions: {
globals: {
// ES2015 globals
ArrayBuffer: false,
DataView: false,
Float32Array: false,
Float64Array: false,
Int16Array: false,
Int32Array: false,
Int8Array: false,
Map: false,
Promise: false,
Proxy: false,
Reflect: false,
Set: false,
Symbol: false,
Uint16Array: false,
Uint32Array: false,
Uint8Array: false,
Uint8ClampedArray: false,
WeakMap: false,
WeakSet: false,
// ES2017 globals
Atomics: false,
SharedArrayBuffer: false,
},
parserOptions: {
parser: this.espree,
sourceType: "module",
ecmaVersion: "latest",
},
},
},
];
},
linter() {
if (!this.tomlESLintParser || !this.vueESLintParser) {
return null;
}
const linter = new Linter();
linter.defineParser("toml-eslint-parser", this.tomlESLintParser);
linter.defineParser("vue-eslint-parser", this.vueESLintParser);

for (const k of Object.keys(rules)) {
const rule = rules[k];
linter.defineRule(rule.meta.docs.ruleId, rule);
}

return linter;
},
},
Expand Down
7 changes: 2 additions & 5 deletions docs/.vitepress/theme/components/rules/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Linter } from "eslint";
import { builtinRules } from "eslint/use-at-your-own-risk";
import { rules } from "../../../../../src/utils/rules.ts";

const coreRules = Object.fromEntries(new Linter().getRules());

const CATEGORY_TITLES = {
toml: "eslint-plugin-toml",
"eslint-core-rules@problem": "ESLint core rules(Possible Errors)",
Expand Down Expand Up @@ -37,8 +35,7 @@ for (const k of Object.keys(rules)) {
initChecked: CATEGORY_INDEX.toml <= 3,
});
}
for (const k of Object.keys(coreRules)) {
const rule = coreRules[k];
for (const [k, rule] of builtinRules.entries()) {
if (rule.meta.deprecated) {
continue;
}
Expand Down
Loading
Loading