Compare commits

..

25 Commits
v1.0.0 ... main

Author SHA1 Message Date
03223d8a54
Version 1.3.0
Some checks failed
CI / build (16.x) (push) Has been cancelled
CI / build (18.x) (push) Has been cancelled
2024-10-26 17:17:20 +02:00
f32cbbc8a6
Support Svelte 5 2024-10-26 17:15:13 +02:00
0cf77aab4e
Version 1.2.0
All checks were successful
CI / build (16.x) (push) Successful in 2m16s
CI / build (18.x) (push) Successful in 1m18s
2024-08-02 10:51:41 +02:00
8ffa9a4e51
Update Bun reference in readme 2024-07-29 17:04:52 +02:00
3010f2ef8c
Oops, correct CI config mistake 2024-07-29 16:30:33 +02:00
83f56649b7
Remove Node.js 14.x from CI 2024-07-29 16:29:47 +02:00
7cc88995f6
Add Actions file 2024-07-29 16:01:42 +02:00
cf34d32dfa
Add Smart Yellow logo 2024-07-29 15:57:04 +02:00
cf9a09d194
Upgrade vulnerable dependencies 2024-07-29 15:54:37 +02:00
32393d68b1
Allow unused underscore-prefixed variables 2024-07-25 13:58:21 +02:00
473a541083
Allow underscore variable to be unused 2024-07-25 13:53:59 +02:00
3931d47b23
Remove import/extensions rule as it is not practical in many cases 2024-07-25 13:48:25 +02:00
ffc6b55166
Version 1.1.0 2024-07-25 13:28:44 +02:00
db88b2164f
Update readme once again 2024-07-25 13:28:19 +02:00
e03f402952
It is 2024 2024-07-25 13:18:23 +02:00
5d5d224d25
Add parserOptions for Svelte + TypeScript 2024-07-25 13:17:28 +02:00
27d8247ad0
Node config: extend all generic properties 2024-07-25 13:08:11 +02:00
ffc8867fce
Add required ESLint version (8.x) to readme 2024-07-25 12:58:12 +02:00
75ab0a8c07
Overwrite max line length for Svelte files 2023-08-07 18:22:30 +02:00
945a539178
Disabled array-element-newline 2023-08-07 18:12:46 +02:00
9055dde0ae
Replaced 2 with 'error' for clarity 2023-08-07 17:54:33 +02:00
b5b3ccac67
Added support for TypeScript codebases 2023-08-07 17:50:06 +02:00
c29b5c06cf
Patched config examples again... 2023-07-28 20:33:10 +02:00
ce45856c63
Updated config examples in readme 2023-07-28 20:31:58 +02:00
88facd931e
Updated first paragraph of readme 2023-07-27 22:22:36 +02:00
11 changed files with 1173 additions and 135 deletions

View File

@ -2,12 +2,18 @@
const svelteConfig = require('./configs/svelte.js');
/** @type {import('eslint').Linter.Config} */
/**
* Don't import this! It is the configuration for the yeslint! code and is not
* meant to be used elsewhere. Please refer to the readme.
*
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
extends: './configs/node.js',
ignorePatterns: [ '/example/wrong.*' ],
overrides: [ {
files: [ './example/correct.svelte' ],
files: [ './example/*.svelte' ],
overrides: svelteConfig.overrides,
parserOptions: svelteConfig.parserOptions,
env: svelteConfig.env,

26
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npx eslint .

View File

@ -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:

View File

@ -1,42 +1,46 @@
# yeslint!
A sensible, modern collection of configuration files for [ESLint] that enforces beautiful 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.
* `svelte`: configuration for [Svelte] and JavaScript in browser environments.
* `node`: an extension on the generic config, with rules specific to Node.js. Also works with [Bun]!
* `svelte`: configuration for [Svelte] (v4 & v5) 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:
Install it together with ESLint using [npm], [pnpm], [Bun], 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.
```javascript
module.exports = {
extends: './node_modules/yeslint/config/<name>.js',
extends: './node_modules/@garraflavatra/yeslint/configs/<name>.js',
};
```
@ -44,18 +48,24 @@ Or add this to your `package.json` file:
```json
"eslintConfig": {
"extends": "./node_modules/yeslint/config/<name>.js"
"extends": "./node_modules/@garraflavatra/yeslint/configs/<name>.js"
}
```
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.
[![Smart Yellow](https://code.smartyellow.net/smartyellow/meta/raw/branch/main/logo.png)](https://www.smartyellow.nl)
[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/

View File

@ -1,5 +1,13 @@
'use strict';
let typescriptInstalled = false;
try {
require('typescript');
typescriptInstalled = true;
}
catch { /* not installed */ }
/**
* Generic ESLint configuration for all modern JavaScript runtimes.
*
@ -20,9 +28,7 @@ const generic = {
rules: {
'no-undef': [
'error',
{
typeof: true,
},
{ typeof: true },
],
'require-atomic-updates': 0,
indent: [
@ -47,11 +53,7 @@ const generic = {
'error',
'always',
],
'array-element-newline': [ 'warn' ],
'array-bracket-newline': [
'warn',
{ minItems: 2 },
],
'array-element-newline': 'off',
'arrow-body-style': [
'error',
'as-needed',
@ -92,9 +94,7 @@ const generic = {
'keyword-spacing': 'error',
'key-spacing': [
'warn',
{
beforeColon: false,
},
{ beforeColon: false },
],
'linebreak-style': [
'error',
@ -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',
@ -194,7 +205,7 @@ const generic = {
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'template-curly-spacing': 'error',
curly: 2,
curly: 'error',
'brace-style': [
'error',
'stroustrup',
@ -211,6 +222,12 @@ const generic = {
'no-nested-ternary': 'error',
'no-lonely-if': 'error',
},
overrides: typescriptInstalled ? [ {
files: '**/*.ts',
parser: '@typescript-eslint/parser',
plugins: [ '@typescript-eslint' ],
extends: [ 'plugin:@typescript-eslint/recommended' ],
} ] : [],
};
module.exports = generic;

View File

@ -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;

View File

@ -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,66 +40,69 @@ const svelte = {
...generic.plugins,
'svelte',
],
overrides: [ {
files: '*.svelte',
parser: 'svelte-eslint-parser',
rules: {
'no-inner-declarations': 0,
'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,
'prefer-const': 0,
},
},
} ],
],
rules: {
...generic.rules,
strict: 0,

View File

@ -11,4 +11,10 @@ module.exports = {
console.log(password);
},
],
arrays: [
1,
2,
3,
],
};

View File

@ -5,5 +5,7 @@ module.exports = {
object:{spacing:'required!'},
functions: [( env )=> console.log(env.password),function ({password}) { console.log( password )}]
functions: [( env )=> console.log(env.password),function ({password}) { console.log( password )}],
arrays: [1,2,3]
}

1024
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@garraflavatra/yeslint",
"version": "1.0.0",
"version": "1.3.0",
"description": "Sensible configuration for your ESLint installation",
"main": "index.js",
"author": "Romein van Buren <romein@vburen.nl>",
@ -27,12 +27,24 @@
"eslint-plugin-import": "^2.27.5"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^7.9.0 || ^8.0.0",
"eslint-plugin-svelte": "^2.32.4"
"eslint-plugin-svelte": "^2.46.0",
"typescript": "^5.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/parser": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"eslint-plugin-svelte": {
"optional": true
},
"typescript": {
"optional": true
}
},
"devDependencies": {