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'); 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 = { module.exports = {
root: true,
extends: './configs/node.js', extends: './configs/node.js',
ignorePatterns: [ '/example/wrong.*' ], ignorePatterns: [ '/example/wrong.*' ],
overrides: [ { overrides: [ {
files: [ './example/correct.svelte' ], files: [ './example/*.svelte' ],
overrides: svelteConfig.overrides, overrides: svelteConfig.overrides,
parserOptions: svelteConfig.parserOptions, parserOptions: svelteConfig.parserOptions,
env: svelteConfig.env, env: svelteConfig.env,

View File

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

View File

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

View File

@ -36,6 +36,13 @@ const svelte = {
parser: 'svelte-eslint-parser', parser: 'svelte-eslint-parser',
rules: { rules: {
'no-inner-declarations': 0, 'no-inner-declarations': 0,
'max-len': [
'warn',
{
...generic.rules['max-len'][1],
code: 200,
},
],
'svelte/no-inner-declarations': [ 'svelte/no-inner-declarations': [
'error', 'error',
'functions', 'functions',

View File

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

View File

@ -5,5 +5,7 @@ module.exports = {
object:{spacing:'required!'}, 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" "eslint-plugin-import": "^2.27.5"
}, },
"peerDependencies": { "peerDependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.1",
"eslint": "^7.9.0 || ^8.0.0", "eslint": "^7.9.0 || ^8.0.0",
"eslint-plugin-svelte": "^2.32.4" "eslint-plugin-svelte": "^2.32.4",
"typescript": "^5.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@typescript-eslint/parser": {
"optional": true
},
"@typescript-eslint/eslint-plugin": {
"optional": true
},
"eslint-plugin-svelte": { "eslint-plugin-svelte": {
"optional": true "optional": true
},
"typescript": {
"optional": true
} }
}, },
"devDependencies": { "devDependencies": {