eslint-config-gristow 2.0.20 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/eslint.config.js +33 -0
- package/index.js +121 -2
- package/package.json +43 -45
- package/readme.md +66 -56
- package/rules/airbnb-base-rules.js +34 -0
- package/rules/airbnb-best-practices.js +319 -0
- package/rules/airbnb-errors.js +141 -0
- package/rules/airbnb-es6.js +119 -0
- package/rules/airbnb-imports.js +185 -0
- package/rules/airbnb-style.js +350 -0
- package/rules/airbnb-variables.js +118 -0
- package/rules/import-rules.js +4 -1
- package/rules/{naming-convention.cjs → naming-convention.js} +4 -1
- package/rules/{shared-rules.cjs → shared-rules.js} +4 -2
- package/rules/{typescript-only-rules.cjs → typescript-only-rules.js} +4 -1
- package/.eslintrc.cjs +0 -44
- package/.eslintrc.cjs.recent.bak +0 -68
- package/.eslintrc.cjs.working.bak +0 -40
- package/.eslintrc.js.original.bak +0 -82
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -20
- package/rules/svelte-rules.cjs +0 -12
- package/svelte/svelte.eslintrc.cjs +0 -28
- package/svelte.js +0 -3
- package/test-js-export.js +0 -3
- package/test-ts-export.ts +0 -8
- package/test.js +0 -44
- package/test.ts +0 -64
- package/tsconfig.json +0 -17
package/.eslintrc.cjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const rules = require('./rules/shared-rules.cjs');
|
|
2
|
-
const importRules = require('./rules/import-rules.js');
|
|
3
|
-
const typescriptOnlyRules = require('./rules/typescript-only-rules.cjs');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
root: true,
|
|
7
|
-
extends: [
|
|
8
|
-
'eslint:recommended',
|
|
9
|
-
'plugin:@typescript-eslint/recommended',
|
|
10
|
-
'airbnb/base',
|
|
11
|
-
'prettier',
|
|
12
|
-
],
|
|
13
|
-
parser: '@typescript-eslint/parser',
|
|
14
|
-
plugins: ['@typescript-eslint', 'import'],
|
|
15
|
-
// plugins: ['@typescript-eslint'],
|
|
16
|
-
parserOptions: {
|
|
17
|
-
sourceType: 'module',
|
|
18
|
-
ecmaVersion: 2020,
|
|
19
|
-
project: './tsconfig.json',
|
|
20
|
-
},
|
|
21
|
-
settings: {
|
|
22
|
-
'import/parsers': {
|
|
23
|
-
'@typescript-eslint/parser': ['.ts'],
|
|
24
|
-
},
|
|
25
|
-
'import/resolver': {
|
|
26
|
-
typescript: true,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
rules: {
|
|
30
|
-
...rules,
|
|
31
|
-
...importRules,
|
|
32
|
-
},
|
|
33
|
-
env: {
|
|
34
|
-
browser: true,
|
|
35
|
-
es2017: true,
|
|
36
|
-
node: true,
|
|
37
|
-
},
|
|
38
|
-
overrides: [
|
|
39
|
-
{
|
|
40
|
-
files: ['*.ts'],
|
|
41
|
-
rules: typescriptOnlyRules,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
};
|
package/.eslintrc.cjs.recent.bak
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const rules = require('./shared-rules.js');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
root: true,
|
|
5
|
-
extends: [
|
|
6
|
-
'eslint:recommended',
|
|
7
|
-
'plugin:@typescript-eslint/recommended',
|
|
8
|
-
'prettier',
|
|
9
|
-
'plugin:svelte/recommended',
|
|
10
|
-
'plugin:import/recommended',
|
|
11
|
-
],
|
|
12
|
-
parser: '@typescript-eslint/parser',
|
|
13
|
-
plugins: ['@typescript-eslint', 'import'],
|
|
14
|
-
parserOptions: {
|
|
15
|
-
sourceType: 'module',
|
|
16
|
-
ecmaVersion: 2020,
|
|
17
|
-
extraFileExtensions: ['.svelte'],
|
|
18
|
-
},
|
|
19
|
-
env: {
|
|
20
|
-
browser: true,
|
|
21
|
-
es2017: true,
|
|
22
|
-
node: true,
|
|
23
|
-
},
|
|
24
|
-
settings: {
|
|
25
|
-
'import/parsers': {
|
|
26
|
-
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
27
|
-
},
|
|
28
|
-
'import/resolver': {
|
|
29
|
-
typescript: {
|
|
30
|
-
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
import: {
|
|
34
|
-
parsers: {
|
|
35
|
-
'@typescript-eslint/parser': ['.ts'],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
rules,
|
|
40
|
-
overrides: [
|
|
41
|
-
{
|
|
42
|
-
files: ['*.svelte'],
|
|
43
|
-
parser: 'svelte-eslint-parser',
|
|
44
|
-
parserOptions: {
|
|
45
|
-
parser: '@typescript-eslint/parser',
|
|
46
|
-
extraFileExtensions: ['.svelte'],
|
|
47
|
-
sourceType: 'module',
|
|
48
|
-
ecmaVersion: 2020,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
files: ['*.ts'],
|
|
53
|
-
parser: '@typescript-eslint/parser',
|
|
54
|
-
rules,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
files: ['*.js'],
|
|
58
|
-
rules,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
files: ['*.cjs'],
|
|
62
|
-
rules: {
|
|
63
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
64
|
-
...rules,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const sharedRules = require('./shared-rules.cjs');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
root: true,
|
|
5
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
|
|
6
|
-
parser: '@typescript-eslint/parser',
|
|
7
|
-
plugins: ['@typescript-eslint', 'import'],
|
|
8
|
-
// plugins: ['@typescript-eslint'],
|
|
9
|
-
parserOptions: {
|
|
10
|
-
sourceType: 'module',
|
|
11
|
-
ecmaVersion: 2020,
|
|
12
|
-
extraFileExtensions: ['.svelte'],
|
|
13
|
-
},
|
|
14
|
-
settings: {
|
|
15
|
-
'import/parsers': {
|
|
16
|
-
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
17
|
-
},
|
|
18
|
-
'import/resolver': {
|
|
19
|
-
typescript: true,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
rules: {
|
|
23
|
-
'no-throw-literal': 'error',
|
|
24
|
-
...sharedRules,
|
|
25
|
-
},
|
|
26
|
-
env: {
|
|
27
|
-
browser: true,
|
|
28
|
-
es2017: true,
|
|
29
|
-
node: true,
|
|
30
|
-
},
|
|
31
|
-
overrides: [
|
|
32
|
-
{
|
|
33
|
-
files: ['*.svelte'],
|
|
34
|
-
parser: 'svelte-eslint-parser',
|
|
35
|
-
parserOptions: {
|
|
36
|
-
parser: '@typescript-eslint/parser',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md for tslint-eslint rule migration
|
|
2
|
-
|
|
3
|
-
const rules = require('./shared-rules');
|
|
4
|
-
const prettierRules = require('./prettier-rules');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
parser: '@typescript-eslint/parser',
|
|
8
|
-
parserOptions: {
|
|
9
|
-
ecmaVersion: 2022,
|
|
10
|
-
project: ['./tsconfig.json'],
|
|
11
|
-
allowAutomaticSingleRunInference: true,
|
|
12
|
-
// Can I remove these now?
|
|
13
|
-
ecmaFeatures: {
|
|
14
|
-
impliedStrict: true,
|
|
15
|
-
classes: true,
|
|
16
|
-
},
|
|
17
|
-
requireConfigFile: false,
|
|
18
|
-
},
|
|
19
|
-
rules,
|
|
20
|
-
overrides: [
|
|
21
|
-
{
|
|
22
|
-
files: ['*.js'],
|
|
23
|
-
plugins: ['prettier', 'jsdoc'],
|
|
24
|
-
extends: ['airbnb/base', 'prettier'],
|
|
25
|
-
rules: {
|
|
26
|
-
...prettierRules,
|
|
27
|
-
'@typescript-eslint/indent': 'off',
|
|
28
|
-
'jsdoc/check-alignment': 1, // Recommended
|
|
29
|
-
'jsdoc/check-param-names': 1, // Recommended
|
|
30
|
-
'jsdoc/check-tag-names': 1, // Recommended
|
|
31
|
-
'jsdoc/check-types': 1, // Recommended
|
|
32
|
-
'jsdoc/implements-on-classes': 1, // Recommended
|
|
33
|
-
'jsdoc/newline-after-description': 1, // Recommended
|
|
34
|
-
'jsdoc/no-undefined-types': 1, // Recommended
|
|
35
|
-
'jsdoc/require-description': 'warn',
|
|
36
|
-
'jsdoc/require-param': 1, // Recommended
|
|
37
|
-
'jsdoc/require-param-description': 'warn', // Recommended
|
|
38
|
-
'jsdoc/require-param-name': 1, // Recommended
|
|
39
|
-
'jsdoc/require-param-type': 1, // Recommended
|
|
40
|
-
'jsdoc/require-returns': 'warn', // Recommended
|
|
41
|
-
'jsdoc/require-returns-check': 1, // Recommended
|
|
42
|
-
'jsdoc/require-returns-description': 'warn', // Recommended
|
|
43
|
-
'jsdoc/require-returns-type': 1, // Recommended
|
|
44
|
-
'jsdoc/valid-types': 1, // Recommended
|
|
45
|
-
'import/no-cycle': 'off',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
files: ['*.ts'],
|
|
50
|
-
plugins: ['prettier', 'eslint-plugin-tsdoc'],
|
|
51
|
-
parser: '@typescript-eslint/parser',
|
|
52
|
-
extends: ['airbnb-typescript/base', 'prettier'],
|
|
53
|
-
rules: {
|
|
54
|
-
...prettierRules,
|
|
55
|
-
'@typescript-eslint/indent': 'off',
|
|
56
|
-
'import/no-cycle': 'off', // otherwise captures cycles by type inclusion
|
|
57
|
-
'@typescript-eslint/no-var-requires': 'warn',
|
|
58
|
-
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
|
|
59
|
-
'import/no-unresolved': 0,
|
|
60
|
-
'no-use-before-define': 'off',
|
|
61
|
-
'no-useless-constructor': 'off',
|
|
62
|
-
// no-dupe-class-members should be removed when this PR lands:
|
|
63
|
-
// https://github.com/typescript-eslint/typescript-eslint/pull/1492
|
|
64
|
-
'no-dupe-class-members': 'off',
|
|
65
|
-
// So we can allow overloading, and list of class props defined
|
|
66
|
-
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
67
|
-
'@typescript-eslint/no-useless-constructor': 'error',
|
|
68
|
-
'tsdoc/syntax': 'warn',
|
|
69
|
-
'no-shadow': 'off',
|
|
70
|
-
// We get these via TS checking, and w/ import type we might have 2 entries,
|
|
71
|
-
// one for named, one for default, one for actual import.
|
|
72
|
-
'import/no-duplicates': 'off',
|
|
73
|
-
'no-duplicate-imports': 'off',
|
|
74
|
-
},
|
|
75
|
-
settings: {
|
|
76
|
-
jsdoc: {
|
|
77
|
-
mode: 'typescript',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
};
|
package/.prettierrc
DELETED
package/.vscode/settings.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"[javascript]": {
|
|
3
|
-
"editor.codeActionsOnSave": {
|
|
4
|
-
"source.fixAll.eslint": true
|
|
5
|
-
}
|
|
6
|
-
},
|
|
7
|
-
"[typescript]": {
|
|
8
|
-
"editor.codeActionsOnSave": {
|
|
9
|
-
"source.fixAll.eslint": true
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"eslint.validate": ["javascript", "typescript", "svelte"],
|
|
13
|
-
"eslint.probe": ["javascript", "typescript", "html", "svelte", "markdown"],
|
|
14
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
15
|
-
"editor.formatOnSave": true,
|
|
16
|
-
"typescript.tsdk": "node_modules/typescript/lib",
|
|
17
|
-
"prettier.disableLanguages": ["javascript", "javascriptreact", "typescript"],
|
|
18
|
-
"editor.tabSize": 2,
|
|
19
|
-
"editor.insertSpaces": true
|
|
20
|
-
}
|
package/rules/svelte-rules.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// Must disable to make 2-way data binding possible
|
|
3
|
-
'import/no-mutable-exports': 'off',
|
|
4
|
-
'no-labels': 'off',
|
|
5
|
-
'no-restricted-syntax': 'off',
|
|
6
|
-
// In svelte we often have to init an export ot undefined to mark it as an optional
|
|
7
|
-
// property:
|
|
8
|
-
'no-undef-init': 'off',
|
|
9
|
-
// Svelte checking will handle verifying resolved imports, and eslint is unfortunately
|
|
10
|
-
// unaware of vite paths:
|
|
11
|
-
'import/no-unresolved': 'off',
|
|
12
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const svelteRules = require('../rules/svelte-rules.cjs');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
extends: ['gristow', 'plugin:svelte/recommended'],
|
|
5
|
-
parserOptions: {
|
|
6
|
-
sourceType: 'module',
|
|
7
|
-
ecmaVersion: 2020,
|
|
8
|
-
extraFileExtensions: ['.svelte'],
|
|
9
|
-
},
|
|
10
|
-
settings: {
|
|
11
|
-
'import/parsers': {
|
|
12
|
-
'@typescript-eslint/parser': ['.ts', '.svelte'],
|
|
13
|
-
},
|
|
14
|
-
'import/resolver': {
|
|
15
|
-
typescript: true,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
overrides: [
|
|
19
|
-
{
|
|
20
|
-
files: ['*.svelte'],
|
|
21
|
-
parser: 'svelte-eslint-parser',
|
|
22
|
-
parserOptions: {
|
|
23
|
-
parser: '@typescript-eslint/parser',
|
|
24
|
-
},
|
|
25
|
-
rules: svelteRules,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
package/svelte.js
DELETED
package/test-js-export.js
DELETED
package/test-ts-export.ts
DELETED
package/test.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Import should work:
|
|
2
|
-
import { greetJS } from './test-js-export';
|
|
3
|
-
import { greet } from './test-ts-export.ts';
|
|
4
|
-
|
|
5
|
-
greetJS('Johnny', 'Appleseed');
|
|
6
|
-
greet('Jenny', 'Applesseed');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A person
|
|
10
|
-
*/
|
|
11
|
-
class Person {
|
|
12
|
-
name = 'Gregory Ristow';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Initialize and set the person's name
|
|
16
|
-
*
|
|
17
|
-
* @param {string} name
|
|
18
|
-
*/
|
|
19
|
-
constructor(name = 'Gregory Ristow') {
|
|
20
|
-
this.name = name;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param firstName
|
|
26
|
-
* @param lastName
|
|
27
|
-
*/
|
|
28
|
-
function userData(firstName, lastName) {
|
|
29
|
-
// Should show error
|
|
30
|
-
const a = 3;
|
|
31
|
-
const b = a > 3 ? 1 : a > 5 ? 2 : 3;
|
|
32
|
-
let c = 4;
|
|
33
|
-
c++;
|
|
34
|
-
addOne(c);
|
|
35
|
-
|
|
36
|
-
return `${firstName} ${lastName}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param n
|
|
41
|
-
*/
|
|
42
|
-
function addOne(n) {
|
|
43
|
-
return n + 1;
|
|
44
|
-
}
|
package/test.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { greetJS } from './test-js-export';
|
|
2
|
-
import { apple, snake_case_import, greet } from './test-ts-export';
|
|
3
|
-
import type { Apple } from './test-ts-export';
|
|
4
|
-
|
|
5
|
-
greetJS('Johnny', 'Appleseed');
|
|
6
|
-
greet('Jenny', 'Applesseed');
|
|
7
|
-
|
|
8
|
-
const a = {
|
|
9
|
-
this_pRop_is_ok: 3,
|
|
10
|
-
_this_prop_is_not: 4,
|
|
11
|
-
neither__is_this_one: 5,
|
|
12
|
-
};
|
|
13
|
-
console.log(a);
|
|
14
|
-
|
|
15
|
-
export function completeName(fullName);
|
|
16
|
-
export function completeName(firstName, lastName?) {
|
|
17
|
-
// Should show error, unused variable...
|
|
18
|
-
const a = 3;
|
|
19
|
-
const b = a > 3 ? 1 : a > 5 ? 2 : 3;
|
|
20
|
-
let c = 4;
|
|
21
|
-
c++;
|
|
22
|
-
addOne(c);
|
|
23
|
-
|
|
24
|
-
return `${firstName}${lastName ? ` ${lastName}` : ''}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Should NOT complain we haven't used an arrow callback:
|
|
28
|
-
setTimeout(function isNotAnArrowFunction() {
|
|
29
|
-
console.log('timeout');
|
|
30
|
-
}, 500);
|
|
31
|
-
|
|
32
|
-
function addOne(n) {
|
|
33
|
-
return n + 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// error because not PascalCase
|
|
37
|
-
export class myClassName {}
|
|
38
|
-
|
|
39
|
-
const SNAKE_CASE_VARIABLE = 'snake case variable';
|
|
40
|
-
console.log(SNAKE_CASE_VARIABLE);
|
|
41
|
-
|
|
42
|
-
const this_is_a_problem = 'snake case variable';
|
|
43
|
-
console.log(this_is_a_problem);
|
|
44
|
-
|
|
45
|
-
console.log(snake_case_import);
|
|
46
|
-
|
|
47
|
-
const coordinates = {
|
|
48
|
-
x_top: 0,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const { x_top } = coordinates;
|
|
52
|
-
|
|
53
|
-
const a: Apple = apple;
|
|
54
|
-
console.log(a);
|
|
55
|
-
|
|
56
|
-
throw 'hello';
|
|
57
|
-
|
|
58
|
-
console.log('unreachable code error!');
|
|
59
|
-
|
|
60
|
-
later();
|
|
61
|
-
|
|
62
|
-
function later() {
|
|
63
|
-
return 'later';
|
|
64
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "build",
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"sourceMap": true,
|
|
6
|
-
"target": "ESNext",
|
|
7
|
-
"noUnusedLocals": true,
|
|
8
|
-
"declaration": false,
|
|
9
|
-
"baseUrl": "./",
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
"exclude": [
|
|
15
|
-
"node_modules",
|
|
16
|
-
]
|
|
17
|
-
}
|