cli: add and use app:lint + include default eslint config in cli
This commit is contained in:
+4
-31
@@ -16,39 +16,12 @@ const copyrightTemplate = `/*
|
||||
|
||||
`;
|
||||
|
||||
const base = require('@spotify-backstage/cli/config/eslint');
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@spotify/eslint-config-base',
|
||||
'@spotify/eslint-config-react',
|
||||
'@spotify/eslint-config-typescript',
|
||||
'prettier',
|
||||
'prettier/react',
|
||||
'prettier/@typescript-eslint',
|
||||
'plugin:jest/recommended',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['notice'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
// Adding this to .eslintignore just doesn't even, let me know if you can make it work ._.
|
||||
ignorePatterns: [
|
||||
'**/*_pb.js',
|
||||
'**/*_pb.d.ts',
|
||||
'**/dist/**',
|
||||
'**/cjs/**',
|
||||
'**/esm/**',
|
||||
],
|
||||
...base,
|
||||
rules: {
|
||||
...base.rules,
|
||||
'notice/notice': [
|
||||
'error',
|
||||
{
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
||||
extends: [
|
||||
// Extend on the config used in `react-scripts`
|
||||
require.resolve('react-scripts/node_modules/eslint-config-react-app'),
|
||||
// If you want extra rules/extensions, it can be added here:
|
||||
// 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
|
||||
// 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
||||
sourceType: 'module', // Allows for the use of imports
|
||||
ecmaFeatures: {
|
||||
jsx: true, // Allows for the parsing of JSX
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
|
||||
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
|
||||
},
|
||||
},
|
||||
// Adding this to .eslintignore just doesn't even, let me know if you can make it work ._.
|
||||
ignorePatterns: ['**/*_pb.js', '**/*_pb.d.ts'],
|
||||
};
|
||||
@@ -28,10 +28,7 @@
|
||||
"start": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true backstage-cli watch-deps -- react-scripts start",
|
||||
"build": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts build",
|
||||
"test": "cross-env EXTEND_ESLINT=true SKIP_PREFLIGHT_CHECK=true react-scripts test",
|
||||
"lint": "cross-env EXTEND_ESLINT=true eslint ./src/**/*.{ts,tsx} --max-warnings=0 --format=codeframe"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
"lint": "backstage-cli app:lint"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'@spotify/eslint-config-base',
|
||||
'@spotify/eslint-config-react',
|
||||
'@spotify/eslint-config-typescript',
|
||||
'prettier',
|
||||
'prettier/react',
|
||||
'prettier/@typescript-eslint',
|
||||
'plugin:jest/recommended',
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['notice'],
|
||||
env: {
|
||||
jest: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
ignorePatterns: ['**/dist/**', '**/build/**'],
|
||||
};
|
||||
@@ -50,6 +50,7 @@
|
||||
},
|
||||
"files": [
|
||||
"templates",
|
||||
"config",
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Command } from 'commander';
|
||||
import { run } from '../../helpers/run';
|
||||
|
||||
export default async (cmd: Command) => {
|
||||
const args = ['lint'];
|
||||
if (cmd.fix) {
|
||||
args.push('--fix');
|
||||
}
|
||||
|
||||
await run('web-scripts', args);
|
||||
};
|
||||
@@ -19,6 +19,7 @@ import chalk from 'chalk';
|
||||
import fs from 'fs';
|
||||
import createPluginCommand from './commands/createPlugin';
|
||||
import watch from './commands/watch-deps';
|
||||
import appLint from './commands/app/lint';
|
||||
import pluginBuild from './commands/plugin/build';
|
||||
import pluginLint from './commands/plugin/lint';
|
||||
import pluginServe from './commands/plugin/serve';
|
||||
@@ -30,6 +31,12 @@ const main = (argv: string[]) => {
|
||||
|
||||
program.name('backstage-cli').version(packageJson.version ?? '0.0.0');
|
||||
|
||||
program
|
||||
.command('app:lint')
|
||||
.option('--fix', 'Attempt to automatically fix violations')
|
||||
.description('Lint an app')
|
||||
.action(actionHandler(appLint));
|
||||
|
||||
program
|
||||
.command('create-plugin')
|
||||
.description('Creates a new plugin in the current repository')
|
||||
|
||||
Reference in New Issue
Block a user