mirror of
https://github.com/garraflavatra/yeslint.git
synced 2025-04-10 18:51:03 +00:00
Compare commits
9 Commits
75ab0a8c07
...
32393d68b1
Author | SHA1 | Date | |
---|---|---|---|
32393d68b1 | |||
473a541083 | |||
3931d47b23 | |||
ffc6b55166 | |||
db88b2164f | |||
e03f402952 | |||
5d5d224d25 | |||
27d8247ad0 | |||
ffc8867fce |
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2023 Romein van Buren
|
||||
Copyright (c) 2023-2024 Romein van Buren
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
26
README.md
26
README.md
@ -1,36 +1,40 @@
|
||||
# yeslint!
|
||||
|
||||
A sensible, modern collection of configuration files for [ESLint] that enforces beautiful and correct code. It contains both rules to ensure correct code (e.g. enforce `break` statements in each `switch` `case`), and rules to make your code beautiful (e.g. adding a trailing comma to array items that start on a newline).
|
||||
A sensible, modern collection of configuration files for [ESLint] 8.x that enforces beautiful and correct code. It contains both rules to ensure correct code (e.g. enforce `break` statements in each `switch` `case`), and rules to make your code beautiful (e.g. adding a trailing comma to array items that start on a newline).
|
||||
|
||||
TypeScript is supported out of the box! No configuration is required.
|
||||
|
||||
## What's included
|
||||
|
||||
Currently, the 3 following configuration files are available:
|
||||
|
||||
* `generic`: generic ESLint configuration for all modern JavaScript runtimes.
|
||||
* `node`: an extension on the generic config, with rules specific to Node.js.
|
||||
* `node`: an extension on the generic config, with rules specific to Node.js. Also works with [Bun]!
|
||||
* `svelte`: configuration for [Svelte] and JavaScript in browser environments.
|
||||
|
||||
## Examples
|
||||
|
||||
Please see [the `examples` directory](./examples) for some examples. Files that start with `wrong.` contain many errors, and the fixed version of those files is in their `correct.` equivalent.
|
||||
Please see [the `example` directory](./example) for some examples. Files that start with `wrong.` contain many errors, and the fixed version of those files is in their `correct.` equivalent.
|
||||
|
||||
## Installation
|
||||
|
||||
Install it together with ESLint using [npm], [pnpm], [Yarn], or whatever package manager you like to use:
|
||||
|
||||
```bash
|
||||
npm install --save-dev eslint @garraflavatra/yeslint
|
||||
npm install --save-dev eslint@^8.57 @garraflavatra/yeslint
|
||||
```
|
||||
|
||||
```bash
|
||||
yarn add --dev eslint @garraflavatra/yeslint
|
||||
pnpm add --save-dev eslint@^8.57 @garraflavatra/yeslint
|
||||
```
|
||||
|
||||
```bash
|
||||
pnpm add --save-dev eslint @garraflavatra/yeslint
|
||||
bun add --save-dev eslint@^8.57 @garraflavatra/yeslint
|
||||
```
|
||||
|
||||
Then, tell ESLint to extend this configuration. Add it either in `.eslintrc.json`, add it as the default export in `.eslintrc.js`, or add it in your `package.json` under the `"eslintConfig"` key.
|
||||
## Usage
|
||||
|
||||
After installing the package, tell ESLint to extend its configuration. Either add it to `.eslintrc.json`, set it as the default export in `.eslintrc.js`, or add it to your `package.json` under the `"eslintConfig"` key.
|
||||
|
||||
Please consider the following example. You should replace `<name>` with the name of the configuration you want to use.
|
||||
|
||||
@ -50,12 +54,16 @@ Or add this to your `package.json` file:
|
||||
|
||||
After installing, run `npx eslint .` to lint your code for the first time, or use `npx eslint --fix .` to lint while automatically fixing all auto-fixable problems ESLint finds in your codebase.
|
||||
|
||||
## Feedback
|
||||
|
||||
Please feel free to [report](https://github.com/garraflavatra/yeslint/issues/new) any issues and questions! Much appreciated :)
|
||||
|
||||
## Author & license
|
||||
|
||||
© [Romein van Buren](mailto:romein@vburen.nl) 2023. yeslint! is released under the MIT license — see LICENSE for the full license text.
|
||||
© [Romein van Buren](mailto:romein@vburen.nl) 2023-2024. yeslint! is released under the MIT license — see LICENSE for the full license text.
|
||||
|
||||
[ESLint]: https://eslint.org/
|
||||
[Svelte]: https://svelte.dev/
|
||||
[npm]: https://www.npmjs.com/
|
||||
[pnpm]: https://pnpm.io/
|
||||
[Yarn]: https://yarnpkg.com/
|
||||
[Bun]: https://bun.sh/
|
||||
|
@ -113,7 +113,22 @@ const generic = {
|
||||
ignoreRegExpLiterals: true,
|
||||
},
|
||||
],
|
||||
'no-unused-vars': 'warn',
|
||||
'no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'no-alert': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-confusing-arrow': [
|
||||
@ -123,10 +138,6 @@ const generic = {
|
||||
'no-console': 'off',
|
||||
'no-div-regex': 'error',
|
||||
'no-duplicate-imports': 'error',
|
||||
'import/extensions': [
|
||||
'warn',
|
||||
'ignorePackages',
|
||||
],
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-label': 'error',
|
||||
'no-fallthrough': 'off',
|
||||
|
@ -12,14 +12,11 @@ const generic = require('./generic.js');
|
||||
* @type {import('eslint').Linter.Config}
|
||||
*/
|
||||
const node = {
|
||||
parserOptions: { ...generic.parserOptions },
|
||||
...generic,
|
||||
env: {
|
||||
...generic.env,
|
||||
node: true,
|
||||
},
|
||||
extends: [ ...generic.extends ],
|
||||
plugins: [ ...generic.plugins ],
|
||||
rules: { ...generic.rules },
|
||||
};
|
||||
|
||||
module.exports = node;
|
||||
|
@ -2,6 +2,14 @@
|
||||
|
||||
const generic = require('./generic.js');
|
||||
|
||||
let typescriptInstalled = true;
|
||||
|
||||
try {
|
||||
require('typescript');
|
||||
typescriptInstalled = true;
|
||||
}
|
||||
catch { /* not installed */ }
|
||||
|
||||
/**
|
||||
* An extension on the default yeslint! generic config, with rules specific to
|
||||
* Svelte codebases and JavaScript source code for browser environments.
|
||||
@ -12,6 +20,7 @@ const generic = require('./generic.js');
|
||||
* @type {import('eslint').Linter.Config}
|
||||
*/
|
||||
const svelte = {
|
||||
...generic,
|
||||
parserOptions: {
|
||||
...generic.parserOptions,
|
||||
ecmaVersion: 2020,
|
||||
@ -31,73 +40,72 @@ const svelte = {
|
||||
...generic.plugins,
|
||||
'svelte',
|
||||
],
|
||||
overrides: [ {
|
||||
files: '*.svelte',
|
||||
parser: 'svelte-eslint-parser',
|
||||
rules: {
|
||||
'no-inner-declarations': 0,
|
||||
'max-len': [
|
||||
'warn',
|
||||
{
|
||||
...generic.rules['max-len'][1],
|
||||
code: 200,
|
||||
},
|
||||
],
|
||||
'svelte/no-inner-declarations': [
|
||||
'error',
|
||||
'functions',
|
||||
],
|
||||
'svelte/html-quotes': [
|
||||
'error',
|
||||
{
|
||||
prefer: 'double',
|
||||
dynamic: {
|
||||
quoted: false,
|
||||
avoidInvalidUnquotedInHTML: false,
|
||||
overrides: [
|
||||
...generic.overrides,
|
||||
{
|
||||
files: '*.svelte',
|
||||
parser: 'svelte-eslint-parser',
|
||||
parserOptions: typescriptInstalled ? {
|
||||
parser: '@typescript-eslint/parser',
|
||||
} : undefined,
|
||||
rules: {
|
||||
'no-inner-declarations': 0,
|
||||
'svelte/no-inner-declarations': [
|
||||
'error',
|
||||
'functions',
|
||||
],
|
||||
'svelte/html-quotes': [
|
||||
'error',
|
||||
{
|
||||
prefer: 'double',
|
||||
dynamic: {
|
||||
quoted: false,
|
||||
avoidInvalidUnquotedInHTML: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
'svelte/no-useless-mustaches': 'warn',
|
||||
'svelte/require-store-reactive-access': 'warn',
|
||||
'svelte/no-reactive-literals': 'error',
|
||||
'svelte/html-closing-bracket-spacing': 'warn',
|
||||
'svelte/indent': [
|
||||
'warn',
|
||||
{
|
||||
indent: 2,
|
||||
ignoredNodes: [],
|
||||
switchCase: 1,
|
||||
alignAttributesVertically: false,
|
||||
},
|
||||
],
|
||||
'svelte/max-attributes-per-line': [
|
||||
'warn',
|
||||
{
|
||||
multiline: 1,
|
||||
singleline: 4,
|
||||
},
|
||||
],
|
||||
'svelte/first-attribute-linebreak': [
|
||||
'warn',
|
||||
{
|
||||
multiline: 'below',
|
||||
singleline: 'beside',
|
||||
},
|
||||
],
|
||||
'svelte/mustache-spacing': 'warn',
|
||||
'svelte/no-extra-reactive-curlies': 'error',
|
||||
'svelte/no-spaces-around-equal-signs-in-attribute': 'warn',
|
||||
'svelte/prefer-class-directive': 'warn',
|
||||
'svelte/shorthand-attribute': 'warn',
|
||||
'svelte/shorthand-directive': 'warn',
|
||||
'svelte/spaced-html-comment': 'warn',
|
||||
'svelte/no-at-html-tags': 0,
|
||||
'svelte/html-self-closing': [
|
||||
'warn',
|
||||
'all',
|
||||
],
|
||||
],
|
||||
'svelte/no-useless-mustaches': 'warn',
|
||||
'svelte/require-store-reactive-access': 'warn',
|
||||
'svelte/no-reactive-literals': 'error',
|
||||
'svelte/html-closing-bracket-spacing': 'warn',
|
||||
'svelte/indent': [
|
||||
'warn',
|
||||
{
|
||||
indent: 2,
|
||||
ignoredNodes: [],
|
||||
switchCase: 1,
|
||||
alignAttributesVertically: false,
|
||||
},
|
||||
],
|
||||
'svelte/max-attributes-per-line': [
|
||||
'warn',
|
||||
{
|
||||
multiline: 1,
|
||||
singleline: 4,
|
||||
},
|
||||
],
|
||||
'svelte/first-attribute-linebreak': [
|
||||
'warn',
|
||||
{
|
||||
multiline: 'below',
|
||||
singleline: 'beside',
|
||||
},
|
||||
],
|
||||
'svelte/mustache-spacing': 'warn',
|
||||
'svelte/no-extra-reactive-curlies': 'error',
|
||||
'svelte/no-spaces-around-equal-signs-in-attribute': 'warn',
|
||||
'svelte/prefer-class-directive': 'warn',
|
||||
'svelte/shorthand-attribute': 'warn',
|
||||
'svelte/shorthand-directive': 'warn',
|
||||
'svelte/spaced-html-comment': 'warn',
|
||||
'svelte/no-at-html-tags': 0,
|
||||
'svelte/html-self-closing': [
|
||||
'warn',
|
||||
'all',
|
||||
],
|
||||
},
|
||||
},
|
||||
} ],
|
||||
],
|
||||
rules: {
|
||||
...generic.rules,
|
||||
strict: 0,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@garraflavatra/yeslint",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Sensible configuration for your ESLint installation",
|
||||
"main": "index.js",
|
||||
"author": "Romein van Buren <romein@vburen.nl>",
|
||||
|
Loading…
x
Reference in New Issue
Block a user