Skip to content

Commit

Permalink
feat: astro and vue support; fix some bugs and refactor all configs
Browse files Browse the repository at this point in the history
  • Loading branch information
espimarisa committed Mar 22, 2024
1 parent 59decbe commit c2b3232
Show file tree
Hide file tree
Showing 25 changed files with 633 additions and 177 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Dependabot Auto-Merge"

on:
pull_request:

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ahmadnassri/action-dependabot-auto-merge@v2.6.6
with:
target: minor
github-token: ${{ github.token }}
75 changes: 75 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["develop"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["develop"]
schedule:
- cron: "0 9 * * 2"

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
29 changes: 29 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Push Testing"

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
steps:
# Checks out git
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Sets Bun.js up
- name: Use Bun.js
uses: oven-sh/setup-bun@v1.2.0
with:
bun-version: latest

# Runs any test scripts
- name: Unit Tests
run: |
bun install
bun run test
env:
CI: true
97 changes: 86 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# [eslint-config-ks][package]

A strict and customizable "kitchen sink" ESLint config featuring support for ESM, TypeScript, JSON, React, and more.
eslint-config-ks is a strict and customizable "kitchen sink" ESLint config featuring support for ESM, TypeScript, React, Svelte, Astro, Vue, and more. It is designed to be easily configurable and deployable to most types of projects with little effort to get working.

eslint-config-ks is a "kitchen sink" ESLint config designed to be easily configurable and deployable regardless of the type of project you are working on.

eslint-config-ks deploys strict but sane rules for ESM, TypeScript, React, Svelte, JSON, Markdown, TOML, and YAML currently.
Currently, eslint-config-ks supports ESM, TypeScript, React, Svelte, Astro, Vue, JSON, Markdown, TOML, and YAML.

## Install

```sh
# be sure you are installing the latest version of ESLint!
# pnpm, replace with your package manager of choice
# if you are using react or svelte, don't miss the below documentation!
# if you are using react, svelte, astro, or vue, read below!
pnpm add -D eslint eslint-config-ks

# bun
Expand Down Expand Up @@ -42,7 +40,7 @@ module.exports = ks();

## Options

eslint-config-ks is designed to be plug-and-play for most forms of projects, and operates on an "opt in" design. By default, it only enables support for JavaScript and TypeScript linting. You can easily enable support for additional languages and libraries by configuring it, however.
By default, eslint-plugin-ks only enables support for JavaScript and TypeScript linting. You can easily enable support for additional languages and libraries by configuring it, as eslint-plugin-ks operates on an "opt in" design. Some supported libraries/languages require the installation of additional dependencies. More information is provided below.

```js
// eslint.config.js
Expand All @@ -67,6 +65,12 @@ export default ks({
// Enables Svelte support. Requires eslint-plugin-svelte, svelte-eslint-parser, and svelte to be installed. Defaults to false.
svelte: false,

// Enables Astro support. Requires eslint-plugin-astro, eslint-plugin-jsx-a11y, and astro-eslint-parser to be installed. Defaults to false.
astro: false,

// Enables Vue support. Requires eslint-plugin-vue and vue-eslint-parser to be installed. Defaults to false.
vue: false,

// Enables linting JSON, JSONC, and JSON5 files. Defaults to false.
json: false,

Expand All @@ -81,6 +85,30 @@ export default ks({
});
```

## Prettier Support

You can enable prettier support by setting `prettier` to `true`. You will need to supply your own `.prettierrc`, and for Svelte, Svelte, and TOML, setup prettier plugins to function with them. You can then override the prettier rule, as this config disables it to prevent parsing errors.

```js
export default ks(
{
prettier: true,
},
[
{
// Example: Enabling Svelte prettier support
// Be sure you install prettier-plugin-svelte,
// and that you configure it in your .prettierc.
// https://github.com/sveltejs/prettier-plugin-svelte
files: ["**/*.svelte"],
rules: {
"prettier/prettier": "warn",
},
},
],
);
```

## React Support

`eslint-plugin-react`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y` must be installed to enable React support. You will also need `react` and `@types/react` if you are using TSX.
Expand All @@ -104,6 +132,8 @@ import ks from "eslint-config-ks";

export default ks({
react: true,
// Enable if you want to typecheck
// typescript: true
});
```

Expand All @@ -122,6 +152,48 @@ import ks from "eslint-config-ks";

export default ks({
svelte: true,
// Enable if you want to typecheck
// typescript: true,
});
```

## Astro Support

`eslint-plugin-astro`, `eslint-plugin-jsx-a11y`, and `astro-eslint-parser` must be installed to enable Astro support.

```sh
bun add -D eslint-plugin-astro eslint-plugin-jsx-a11y astro-eslint-parser
pnpm add -D eslint-plugin-astro eslint-plugin-jsx-a11y astro-eslint-parser
```

```js
// eslint.config.js
import ks from "eslint-config-ks";

export default ks({
astro: true,
// Enable if you want to typecheck
// typescript: true,
});
```

## Vue Support

`eslint-plugin-vue` and `vue-eslint-parser` must be installed to enable Vue support.

```sh
bun add -D eslint-plugin-vue eslint-plugin-vue-eslint-parser
pnpm add -D eslint-plugin-vue eslint-plugin-vue-eslint-parser
```

```js
// eslint.config.js
import ks from "eslint-config-ks";

export default ks({
vue: true,
// Enable if you want to typecheck
// typescript: true,
});
```

Expand All @@ -136,12 +208,13 @@ import ks from "eslint-config-ks";
export default ks(
{
// Additional options go here, if left blank the defaults are loaded
// See above for all options
},
[
{
files: ["**/*.tsx"],
files: ["**/*.{jsx,tsx}"],
rules: {
example: "off",
exampleRule: "off",
},
// ....so on, and so forth
},
Expand All @@ -163,21 +236,23 @@ You may need to add the following options to `.vscode/settings.json` or your VSC

// Auto fix support
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.eslint": "explicit"
},

// Validate supported languages
"eslint.validate": [
"astro",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"markdown",
"json",
"jsonc",
"yaml",
"svelte",
"toml",
"svelte"
"vue",
"yaml"
]
}
```
Expand Down
Binary file modified bun.lockb
Binary file not shown.
65 changes: 40 additions & 25 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import eslintConfig from "./src/index.mjs";

export default eslintConfig(
{
prettier: true,

json: true,

yml: true,

markdown: true,
typescript: true,
toml: true,

svelte: true,
react: false,
},
[
{
rules: {
"n/no-missing-import": "off",
},
},
],
);
// eslint.config.js
import ks from "./src/index.mjs";

export default ks({
// An array of paths to ignore. Defaults to ignoring node_modules and dist.
ignores: ["**/node_modules/*", "**/dist/*"],

// Enables Prettier support and ties to the linter. Defaults to false. You need to provide your own .prettierrc.
prettier: false,

// Toggles TypeScript support. Defaults to true.
typescript: true,

// A path pointing to a tsconfig file for TypeScript support. Defaults to true to enable default behavior.
project: ["tsconfig.json"],

// Enables React support. Requires eslint-plugin-react, eslint-plugin-react-hooks, and eslint-plugin-jsx-a11y to be installed. Defaults to false.
react: false,

// Enables Svelte support. Requires eslint-plugin-svelte, svelte-eslint-parser, and svelte to be installed. Defaults to false.
svelte: false,

// Enables Astro support. Requires eslint-plugin-astro, eslint-plugin-jsx-a11y, and astro-eslint-parser to be installed. Defaults to false.
astro: false,

// Enables Vue support. Requires eslint-plugin-vue and vue-eslint-parser to be installed. Defaults to false.
vue: false,

// Enables linting JSON, JSONC, and JSON5 files. Defaults to false.
json: false,

// Enables linting code snippets inside of Markdown/MD files. Defaults to false.
markdown: false,

// Enables linting TOML files. Defaults to false.
toml: false,

// Enables linting YAML/YML files. Defaults to false.
yml: false,
});
Loading

0 comments on commit c2b3232

Please sign in to comment.