Compare commits

..

No commits in common. "main" and "v1.0.0" have entirely different histories.
main ... v1.0.0

11 changed files with 135 additions and 1173 deletions

View File

@ -2,18 +2,12 @@
const svelteConfig = require('./configs/svelte.js');
/**
* 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}
*/
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
extends: './configs/node.js',
ignorePatterns: [ '/example/wrong.*' ],
overrides: [ {
files: [ './example/*.svelte' ],
files: [ './example/correct.svelte' ],
overrides: svelteConfig.overrides,
parserOptions: svelteConfig.parserOptions,
env: svelteConfig.env,

View File

@ -1,26 +0,0 @@
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-2024 Romein van Buren
Copyright (c) 2023 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,46 +1,42 @@
# yeslint!
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.
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).
## 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. Also works with [Bun]!
* `svelte`: configuration for [Svelte] (v4 & v5) and JavaScript in browser environments.
* `node`: an extension on the generic config, with rules specific to Node.js.
* `svelte`: configuration for [Svelte] and JavaScript in browser environments.
## Examples
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.
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.
## Installation
Install it together with ESLint using [npm], [pnpm], [Bun], or whatever package manager you like to use:
Install it together with ESLint using [npm], [pnpm], [Yarn], or whatever package manager you like to use:
```bash
npm install --save-dev eslint@^8.57 @garraflavatra/yeslint
npm install --save-dev eslint @garraflavatra/yeslint
```
```bash
pnpm add --save-dev eslint@^8.57 @garraflavatra/yeslint
yarn add --dev eslint @garraflavatra/yeslint
```
```bash
bun add --save-dev eslint@^8.57 @garraflavatra/yeslint
pnpm add --save-dev eslint @garraflavatra/yeslint
```
## 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.
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.
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/@garraflavatra/yeslint/configs/<name>.js',
extends: './node_modules/yeslint/config/<name>.js',
};
```
@ -48,24 +44,18 @@ Or add this to your `package.json` file:
```json
"eslintConfig": {
"extends": "./node_modules/@garraflavatra/yeslint/configs/<name>.js"
"extends": "./node_modules/yeslint/config/<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-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)
© [Romein van Buren](mailto:romein@vburen.nl) 2023. 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/
[Bun]: https://bun.sh/
[Yarn]: https://yarnpkg.com/

View File

@ -1,13 +1,5 @@
'use strict';
let typescriptInstalled = false;
try {
require('typescript');
typescriptInstalled = true;
}
catch { /* not installed */ }
/**
* Generic ESLint configuration for all modern JavaScript runtimes.
*
@ -28,7 +20,9 @@ const generic = {
rules: {
'no-undef': [
'error',
{ typeof: true },
{
typeof: true,
},
],
'require-atomic-updates': 0,
indent: [
@ -53,7 +47,11 @@ const generic = {
'error',
'always',
],
'array-element-newline': 'off',
'array-element-newline': [ 'warn' ],
'array-bracket-newline': [
'warn',
{ minItems: 2 },
],
'arrow-body-style': [
'error',
'as-needed',
@ -94,7 +92,9 @@ const generic = {
'keyword-spacing': 'error',
'key-spacing': [
'warn',
{ beforeColon: false },
{
beforeColon: false,
},
],
'linebreak-style': [
'error',
@ -113,22 +113,7 @@ const generic = {
ignoreRegExpLiterals: true,
},
],
'no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-unused-vars': 'warn',
'no-alert': 'error',
'no-caller': 'error',
'no-confusing-arrow': [
@ -138,6 +123,10 @@ 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',
@ -205,7 +194,7 @@ const generic = {
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'template-curly-spacing': 'error',
curly: 'error',
curly: 2,
'brace-style': [
'error',
'stroustrup',
@ -222,12 +211,6 @@ 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,11 +12,14 @@ const generic = require('./generic.js');
* @type {import('eslint').Linter.Config}
*/
const node = {
...generic,
parserOptions: { ...generic.parserOptions },
env: {
...generic.env,
node: true,
},
extends: [ ...generic.extends ],
plugins: [ ...generic.plugins ],
rules: { ...generic.rules },
};
module.exports = node;

View File

@ -2,14 +2,6 @@
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.
@ -20,7 +12,6 @@ catch { /* not installed */ }
* @type {import('eslint').Linter.Config}
*/
const svelte = {
...generic,
parserOptions: {
...generic.parserOptions,
ecmaVersion: 2020,
@ -40,69 +31,66 @@ const svelte = {
...generic.plugins,
'svelte',
],
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,
},
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,
},
],
'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,
},
},
],
'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,

View File

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

View File

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

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.3.0",
"version": "1.0.0",
"description": "Sensible configuration for your ESLint installation",
"main": "index.js",
"author": "Romein van Buren <romein@vburen.nl>",
@ -27,24 +27,12 @@
"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.46.0",
"typescript": "^5.0.0"
"eslint-plugin-svelte": "^2.32.4"
},
"peerDependenciesMeta": {
"@typescript-eslint/parser": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"eslint-plugin-svelte": {
"optional": true
},
"typescript": {
"optional": true
}
},
"devDependencies": {