Skip to content

Commit

Permalink
rename basic to eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
andreineculau committed Feb 4, 2022
1 parent b09be21 commit 890fe8a
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ JS_RULE_TEST_FILES := $(shell $(FIND_Q) test -type f -name "*.test.js" -print)
CONFIGS += \
async-await \
babel \
basic \
eslint \
eslint-comments \
fp \
import \
Expand Down
2 changes: 1 addition & 1 deletion bin/config.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ case ${CONFIG} in
PLUGIN=@babel/eslint-plugin
PLUGIN_RULE_PREFIX=@babel/
;;
basic)
eslint)
PLUGIN=
PLUGIN_RULE_PREFIX=
;;
Expand Down
2 changes: 1 addition & 1 deletion bin/list-configured-overrides-rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG=${1:-basic}
CONFIG=${1:-eslint}
# shellcheck disable=SC1091
source ${DIR}/config.inc.sh

Expand Down
2 changes: 1 addition & 1 deletion bin/list-configured-own-rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG=${1:-basic}
CONFIG=${1:-eslint}
# shellcheck disable=SC1091
source ${DIR}/config.inc.sh

Expand Down
2 changes: 1 addition & 1 deletion bin/list-configured-rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG=${1:-basic}
CONFIG=${1:-eslint}
# shellcheck disable=SC1091
source ${DIR}/config.inc.sh

Expand Down
4 changes: 2 additions & 2 deletions bin/list-own-rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG=${1:-basic}
CONFIG=${1:-eslint}
# shellcheck disable=SC1091
source ${DIR}/config.inc.sh

[[ "${CONFIG}" != "basic" ]] || {
[[ "${CONFIG}" != "eslint" ]] || {
SCRIPT="$(cat <<EOF
let {Linter} = require('eslint');
let rules = new Linter().getRules();
Expand Down
14 changes: 7 additions & 7 deletions configs/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ if (!_semver.satisfies(_pluginActualVsn.replace(/.*#semver:/, ''), _pluginVsn.re
}

let _ = require('lodash');
let _basic = require('./basic');
let _eslint = require('./eslint');

// see https://github.com/eslint/eslint/issues/12592
_basic = _.cloneDeep(_basic);
_eslint = _.cloneDeep(_eslint);

module.exports = {
parser: '@babel/eslint-parser',
Expand All @@ -29,18 +29,18 @@ module.exports = {

rules: {
'new-cap': 'off',
'@babel/new-cap': _basic.rules['new-cap'],
'@babel/new-cap': _eslint.rules['new-cap'],

'no-invalid-this': 'off',
'@babel/no-invalid-this': _basic.rules['no-invalid-this'],
'@babel/no-invalid-this': _eslint.rules['no-invalid-this'],

'no-unused-expressions': 'off',
'@babel/no-unused-expressions': _basic.rules['no-unused-expressions'],
'@babel/no-unused-expressions': _eslint.rules['no-unused-expressions'],

'object-curly-spacing': 'off',
'@babel/object-curly-spacing': _basic.rules['object-curly-spacing'],
'@babel/object-curly-spacing': _eslint.rules['object-curly-spacing'],

semi: 'off',
'@babel/semi': _basic.rules.semi
'@babel/semi': _eslint.rules.semi
}
};
2 changes: 1 addition & 1 deletion configs/basic.eslintrc.js → configs/eslint.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: true,
extends: [
'plugin:y/basic'
'plugin:y/eslint'
]
};
File renamed without changes.
2 changes: 1 addition & 1 deletion configs/basic.js → configs/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
plugins: [],

extends: [
'./basic.extends'
'./eslint.extends'
],

parser: 'espree',
Expand Down
18 changes: 6 additions & 12 deletions configs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ module.exports = {
]
},

'basic': {
extends: [
'./basic.js'
]
},

'env-browser': {
extends: [
'./env-browser.js'
Expand All @@ -36,6 +30,12 @@ module.exports = {
]
},

'eslint': {
extends: [
'./eslint.js'
]
},

'fp': {
extends: [
'./fp.js'
Expand Down Expand Up @@ -144,12 +144,6 @@ module.exports = {
]
},

'typescript-recommended-restore-basic': {
extends: [
'./typescript-recommended-restore-basic.js'
]
},

'typescript': {
extends: [
'./typescript.js'
Expand Down
1 change: 1 addition & 0 deletions configs/index.js.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let _configData = _.reduce(_configFiles, function(acc, configFile) {
if (_.includes([
'.eslintrc.js',
'index.js',
'typescript-recommended-restore-eslint.js',
'util.js'
], configFile)) {
return acc;
Expand Down
2 changes: 1 addition & 1 deletion configs/recommended.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: [
'./basic.js',
'./eslint.js',
'./babel.js',
'./async-await.js',
'./eslint-comments.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* eslint-disable lodash/prefer-lodash-method */

let _ = require('lodash');
let _basic = require('./basic');
let _eslint = require('./eslint');

let _prefix = '@typescript-eslint/eslint-plugin/dist/configs/';
let _base = require('./util').eslintRequire(`${_prefix}/base`);
let _eslintRecommended = require('./util').eslintRequire(`${_prefix}/eslint-recommended`).overrides[0];
let _recommended = require('./util').eslintRequire(`${_prefix}/recommended`);

// see https://github.com/eslint/eslint/issues/12592
_basic = _.cloneDeep(_basic);
_eslint = _.cloneDeep(_eslint);

let _restoreBasicOverrides = _.merge(
let _restoreEslintOverrides = _.merge(
{},
_base,
_eslintRecommended,
Expand All @@ -38,7 +38,7 @@ let mapObjectValues = function(obj, predicate) {
}));
};

_restoreBasicOverrides.rules = filterObject(_restoreBasicOverrides.rules, function(_value, key) {
_restoreEslintOverrides.rules = filterObject(_restoreEslintOverrides.rules, function(_value, key) {
// https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors // editorconfig-checker-disable-line
if (key === 'no-undef') {
return false;
Expand All @@ -49,11 +49,11 @@ _restoreBasicOverrides.rules = filterObject(_restoreBasicOverrides.rules, functi
return true;
});

_restoreBasicOverrides.rules = mapObjectValues(_restoreBasicOverrides.rules, function(_value, key) {
if (_.isEmpty(_basic.rules[key])) {
throw new Error(`Expected a ${key} rule in configs/basics. @typescript-eslint:recommended wants to override it.`);
_restoreEslintOverrides.rules = mapObjectValues(_restoreEslintOverrides.rules, function(_value, key) {
if (_.isEmpty(_eslint.rules[key])) {
throw new Error(`Expected a ${key} rule in configs/eslint. @typescript-eslint:recommended wants to override it.`);
}
return _basic.rules[key];
return _eslint.rules[key];
});

module.exports = _restoreBasicOverrides;
module.exports = _restoreEslintOverrides;
42 changes: 21 additions & 21 deletions configs/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ if (!_semver.satisfies(_typescriptActualVsn.replace(/.*#semver:/, ''), _typescri
}

let _ = require('lodash');
let _basic = require('./basic');
let _typescriptRestoreBasic = require('./typescript-recommended-restore-basic');
let _eslint = require('./eslint');
let _typescriptRestoreEslint = require('./typescript-recommended-restore-eslint');

// see https://github.com/eslint/eslint/issues/12592
_basic = _.cloneDeep(_basic);
_eslint = _.cloneDeep(_eslint);

let isIde = process.env.VSCODE_PID !== undefined;

Expand All @@ -44,8 +44,8 @@ module.exports = {
},

rules: {
// restore all rules in @typescript-eslint/recommended that are not @typescript-eslint i.e. basic
..._typescriptRestoreBasic.rules,
// restore all rules in @typescript-eslint/recommended that are not @typescript-eslint i.e. eslint
..._typescriptRestoreEslint.rules,

// -------------------------------------------------------------------------

Expand Down Expand Up @@ -110,17 +110,17 @@ module.exports = {
// rules in tslint (overriding eslint rules)

'consistent-this': 'off',
'@typescript-eslint/no-this-alias': _basic.rules['consistent-this'], // tslint:no-this-assignment
'@typescript-eslint/no-this-alias': _eslint.rules['consistent-this'], // tslint:no-this-assignment

// marked as, but not really typescriptOnly
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': _basic.rules['no-use-before-define'], // tslint:no-use-before-declare
'@typescript-eslint/no-use-before-define': _eslint.rules['no-use-before-define'], // tslint:no-use-before-declare

'@typescript-eslint/no-extraneous-class': 'error', // tslint: no-unnecessary-class

// marked as, but not really typescriptOnly
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': _basic.rules['no-unused-vars'], // tslint:no-unused-variable
'@typescript-eslint/no-unused-vars': _eslint.rules['no-unused-vars'], // tslint:no-unused-variable

// -------------------------------------------------------------------------

Expand Down Expand Up @@ -150,11 +150,11 @@ module.exports = {
// rules not in tslint, not specific to the typescript plugin

'brace-style': 'off',
'@typescript-eslint/brace-style': _basic.rules['brace-style'],
'@typescript-eslint/brace-style': _eslint.rules['brace-style'],

// replaced by @typescript-eslint/naming-convention
// camelcase: 'off',
// '@typescript-eslint/camelcase': _basic.rules.camelcase,
// '@typescript-eslint/camelcase': _eslint.rules.camelcase,

'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
Expand All @@ -163,7 +163,7 @@ module.exports = {
}],

'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': _basic.rules['func-call-spacing'],
'@typescript-eslint/func-call-spacing': _eslint.rules['func-call-spacing'],

camelcase: 'off',
'@typescript-eslint/naming-convention': ['warn', {
Expand All @@ -173,7 +173,7 @@ module.exports = {
leadingUnderscore: 'allow',
trailingUnderscore: 'forbid'
}, {
// camelcase.properties set to never in basic.js
// camelcase.properties set to never in eslint.js
selector: 'property',
// eslint-disable-next-line no-null/no-null
format: null
Expand Down Expand Up @@ -215,27 +215,27 @@ module.exports = {
}],

'global-require': 'off',
'@typescript-eslint/no-require-imports': _basic.rules['global-require'],
'@typescript-eslint/no-require-imports': _eslint.rules['global-require'],

indent: 'off',
// eslint-disable-next-line no-sparse-arrays
'@typescript-eslint/indent': _.merge([,, {
// maintain eslint defaults
SwitchCase: 0,
flatTernaryExpressions: false
}], _basic.rules.indent),
}], _eslint.rules.indent),

'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': _basic.rules['no-array-constructor'],
'@typescript-eslint/no-array-constructor': _eslint.rules['no-array-constructor'],

'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': _basic.rules['no-empty-function'],
'@typescript-eslint/no-empty-function': _eslint.rules['no-empty-function'],

'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': _basic.rules['no-extra-parens'],
'@typescript-eslint/no-extra-parens': _eslint.rules['no-extra-parens'],

'no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': _basic.rules['no-magic-numbers'],
'@typescript-eslint/no-magic-numbers': _eslint.rules['no-magic-numbers'],

'@typescript-eslint/no-misused-promises': ['error', {
// NOTE this may hide serious problem if NodeJS will terminate the process on unhandled rejections.
Expand All @@ -247,16 +247,16 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'error',

'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': _basic.rules['no-useless-constructor'],
'@typescript-eslint/no-useless-constructor': _eslint.rules['no-useless-constructor'],

'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',

'require-await': 'off',
'@typescript-eslint/require-await': _basic.rules['require-await'],
'@typescript-eslint/require-await': _eslint.rules['require-await'],

semi: 'off',
'@typescript-eslint/semi': _basic.rules.semi
'@typescript-eslint/semi': _eslint.rules.semi
}
};

0 comments on commit 890fe8a

Please sign in to comment.