Compare commits

7 Commits

8 changed files with 1013 additions and 24 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,

View File

@ -1,6 +1,6 @@
# 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] 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).
## What's included
@ -36,7 +36,7 @@ Please consider the following example. You should replace `<name>` with the name
```javascript
module.exports = {
extends: './node_modules/yeslint/config/<name>.js',
extends: './node_modules/@garraflavatra/yeslint/configs/<name>.js',
};
```
@ -44,7 +44,7 @@ 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"
}
```

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',
@ -194,7 +194,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 +211,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

@ -36,6 +36,13 @@ const 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',

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]
}

960
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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.32.4",
"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": {