cli: switch existing eslint configs to use factory
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -14,90 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const globalRestrictedSyntax = [
|
||||
{
|
||||
message:
|
||||
'Default import from winston is not allowed, import `* as winston` instead.',
|
||||
selector:
|
||||
'ImportDeclaration[source.value="winston"] ImportDefaultSpecifier',
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@spotify/eslint-config-base',
|
||||
'@spotify/eslint-config-typescript',
|
||||
'prettier',
|
||||
'plugin:jest/recommended',
|
||||
'plugin:monorepo/recommended',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['import'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
globals: {
|
||||
__non_webpack_require__: 'readonly',
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
lib: require('./tsconfig.json').compilerOptions.lib,
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js', '**/dist/**', '**/dist-types/**'],
|
||||
rules: {
|
||||
'no-shadow': 'off',
|
||||
'no-redeclare': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'@typescript-eslint/no-redeclare': 'error',
|
||||
|
||||
'no-console': 0, // Permitted in console programs
|
||||
'new-cap': ['error', { capIsNew: false }], // Because Express constructs things e.g. like 'const r = express.Router()'
|
||||
'import/newline-after-import': 'error',
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: ['**/*.test.*', 'src/setupTests.*', 'dev/**'],
|
||||
optionalDependencies: true,
|
||||
peerDependencies: true,
|
||||
bundledDependencies: true,
|
||||
},
|
||||
],
|
||||
'no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'error',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
|
||||
],
|
||||
// Avoid cross-package imports
|
||||
'no-restricted-imports': [
|
||||
2,
|
||||
{ patterns: ['**/../../**/*/src/**', '**/../../**/*/src'] },
|
||||
],
|
||||
// Avoid default import from winston as it breaks at runtime
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
{
|
||||
message:
|
||||
"`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-common` instead.",
|
||||
selector: 'Identifier[name="__dirname"]',
|
||||
},
|
||||
...globalRestrictedSyntax,
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts?(x)'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'no-undef': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.test.*', 'src/setupTests.*', 'dev/**'],
|
||||
rules: {
|
||||
'no-restricted-syntax': ['error', ...globalRestrictedSyntax],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
module.exports = require('./eslint-factory').createConfigForRole(
|
||||
undefined,
|
||||
'node-library',
|
||||
);
|
||||
|
||||
@@ -14,96 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@spotify/eslint-config-base',
|
||||
'@spotify/eslint-config-react',
|
||||
'@spotify/eslint-config-typescript',
|
||||
'prettier',
|
||||
'plugin:jest/recommended',
|
||||
'plugin:monorepo/recommended',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['import'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
sourceType: 'module',
|
||||
lib: require('./tsconfig.json').compilerOptions.lib,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js', '**/dist/**', '**/dist-types/**'],
|
||||
rules: {
|
||||
'no-shadow': 'off',
|
||||
'no-redeclare': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'@typescript-eslint/no-redeclare': 'error',
|
||||
'no-undef': 'off',
|
||||
'import/newline-after-import': 'error',
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
devDependencies: [
|
||||
'**/*.test.*',
|
||||
'**/*.stories.*',
|
||||
'**/src/setupTests.*',
|
||||
'**/dev/**',
|
||||
],
|
||||
optionalDependencies: true,
|
||||
peerDependencies: true,
|
||||
bundledDependencies: true,
|
||||
},
|
||||
],
|
||||
'no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'error',
|
||||
'@typescript-eslint/consistent-type-assertions': 'error',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
vars: 'all',
|
||||
args: 'after-used',
|
||||
ignoreRestSiblings: true,
|
||||
argsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'no-restricted-imports': [
|
||||
2,
|
||||
{
|
||||
paths: [
|
||||
{
|
||||
// Importing the entire MUI icons packages kills build performance as the list of icons is huge.
|
||||
name: '@material-ui/icons',
|
||||
message: "Please import '@material-ui/icons/<Icon>' instead.",
|
||||
},
|
||||
{
|
||||
name: '@material-ui/icons/', // because this is possible too ._.
|
||||
message: "Please import '@material-ui/icons/<Icon>' instead.",
|
||||
},
|
||||
...require('module').builtinModules,
|
||||
],
|
||||
// Avoid cross-package imports
|
||||
patterns: ['**/../../**/*/src/**', '**/../../**/*/src'],
|
||||
},
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts?(x)'],
|
||||
rules: {
|
||||
// Default to not enforcing prop-types in typescript
|
||||
'react/prop-types': 0,
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'no-undef': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
module.exports = require('./eslint-factory').createConfigForRole(
|
||||
undefined,
|
||||
'web-library',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user