tslint removed and initial eslint configuration setup (#22)

This commit is contained in:
tkamireh 2019-09-09 14:23:06 -07:00 коммит произвёл Jason Morse
Родитель 35e5b9c16c
Коммит 0366b96533
58 изменённых файлов: 459 добавлений и 1862 удалений

1
apps/demo/.eslintignore Normal file
Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

5
apps/demo/.eslintrc.js Normal file
Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -1,6 +0,0 @@
{
"extends": ["../../.eslintrc.json"],
"env": {
"browser": true
}
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -31,6 +31,7 @@
"react-app-polyfill": "~1.0.1",
"react-dom": "16.8.3",
"ts-loader": "6.0.4",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -42,26 +42,6 @@
"beachball": "^1.11.7",
"lerna": "^3.16.4"
},
"lint-staged": {
"linters": {
"*.{ts,tsx,js,jsx}": [
"node ./scripts/lint-staged/prettier",
"node ./scripts/lint-staged/tslint",
"git add"
],
"*.{js,jsx,json,scss,html,md}": [
"node ./scripts/lint-staged/prettier",
"git add"
]
},
"ignore": [
"common/scripts/*.js",
"packages/tslint-rules/tslint.json",
"**/CHANGELOG.*",
"**/*.api.md",
"**/_*.scss"
]
},
"workspaces": {
"packages": [
"apps/*",

Просмотреть файл

@ -0,0 +1,13 @@
node_modules
.gitignore
.gitattributes
.editorconfig
config.js
jest.config.js
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js
webpack.serve.config.js
*.build.log

Просмотреть файл

@ -0,0 +1,46 @@
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
rules: {
"@typescript-eslint/adjacent-overload-signatures": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-types": "off",
"camelcase": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/class-name-casing": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": "off",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-misused-new": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-this-alias": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/type-annotation-spacing": "off",
"no-var": "off",
"prefer-const": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"no-undef": "off",
"no-prototype-builtins": "off"
}
}

Просмотреть файл

@ -0,0 +1,21 @@
{
"name": "@uifabric/eslint-config-rules",
"version": "0.1.0",
"description": "ESLint ruleset for UI Fabric React Native",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/ui-fabric-react-native"
},
"main": "./eslintrc.js",
"license": "MIT",
"peerDependencies": {
"eslint": ">= 6",
"@typescript-eslint/eslint-plugin": "^2.1.0",
"@typescript-eslint/parser": "^2.1.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1"
}
}

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -31,6 +31,7 @@
"@types/jest": "^19.2.2",
"react": "16.8.3",
"react-dom": "16.8.3",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -133,6 +133,5 @@ export interface IStackStatics {
Item: React.FunctionComponent<IStackItemProps>;
}
/* tslint:disable:no-any */
export type IStackComponent = IComponent<IStackProps, IStackSettings, IStackProps, any, IStackStatics>;
export type IStackRenderData = IRenderData<IStackProps, IStackSettings>;

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -23,6 +23,7 @@
"devDependencies": {
"@types/jest": "^19.2.2",
"react": "16.8.3",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -27,7 +27,7 @@ export type IResolvedSlot<
TProps extends object = IGenericProps,
TSlotProps = ISlotProps,
TAdditional extends object = object
> = IAsResolved<IProcessResult<TProps, TSlotProps, TAdditional>>;
> = IAsResolved<IProcessResult<TProps, TSlotProps, TAdditional>>;
/**
* a collection of resolved slots
@ -64,7 +64,6 @@ export type IWithComposable<T extends object = object> = T & {
* Generally a slot can be defined as a standard input to createElement or as an object with a __composable value
* set on it
*/
/* tslint:disable-next-line no-any */
export type INativeSlotType = React.ElementType<any> | string;
export type ISlotType = INativeSlotType | IWithComposable<object>;

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -27,6 +27,7 @@
},
"devDependencies": {
"@types/jest": "^19.2.2",
"json5": "2.1.0"
"json5": "2.1.0",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -219,7 +219,6 @@ export function renderComponent<TComponent extends IComponent>(
result: IResolvedSlot,
...children: React.ReactNode[]
): JSX.Element | null {
/* tslint:disable-next-line no-any */
return component.view
? component.view(result as any, ...children)
: (result.slots && result.slots.root && renderSlot(result.slots.root, ...children)) || null;

Просмотреть файл

@ -3,13 +3,11 @@ import { ISlotTypes, IResolvedSlotData, IComposable } from '@uifabric/foundation
import { IComponentSettings } from '@uifabric/theme-settings';
import { ICustomizedSettings, ICustomizedValueType } from './Customize.types';
/* tslint:disable no-any */
export interface IRenderData<
TProps extends object = object,
TSlotProps extends IComponentSettings = IComponentSettings,
TState extends object = any
> {
> {
props: TProps;
theme: INativeTheme;
state: TState;
@ -56,7 +54,7 @@ export interface IComponent<
TCustomizeableProps extends TProps = TProps,
TState extends object = any,
TStatics extends object = object
> {
> {
className: string;
/**

Просмотреть файл

@ -2,8 +2,6 @@ import { ICustomizedSettings, ICustomizedValueType, IPropFunction, IWithTheme, I
import { IComponentSettings } from '@uifabric/theme-settings';
const JSON5 = require('json5');
/* tslint:disable:no-any */
export function customize<TSettings extends IComponentSettings, TProps extends object>(
inputParts: TemplateStringsArray,
...inputKeys: ICustomizedValueType<TProps>[]
@ -15,20 +13,20 @@ export function customize<TSettings extends IComponentSettings, TProps extends o
return keys.length === 0
? []
: keys.map((fn: IPropFunction<TProps>) => {
const val = fn(props);
return _stringifyValue(val);
});
const val = fn(props);
return _stringifyValue(val);
});
},
getSettings: settings
? () => settings
: (keysParam: string[]) => {
const settingsString: string = parts
.map((part: string, index: number) => {
return index < keysParam.length ? part + keysParam[index] : part;
})
.join();
return _toSettings(settingsString);
},
const settingsString: string = parts
.map((part: string, index: number) => {
return index < keysParam.length ? part + keysParam[index] : part;
})
.join();
return _toSettings(settingsString);
},
settings
};
}

Просмотреть файл

@ -24,7 +24,6 @@ function getComponentOptions<TComponent extends IComponent>(inputComponent: TCom
const tokenProcessors = [].concat(parent.tokenProcessors, inputComponent.tokenProcessors).filter(v => v);
if (baseRoot) {
/* tslint:disable-next-line no-any */
slots.root = baseRoot as any;
}
return {

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -22,6 +22,8 @@
"license": "MIT",
"devDependencies": {
"@types/jest": "^19.2.2",
"@uifabric/build-native": "^0.1.1"
"@types/node": "^10.3.5",
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -195,7 +195,6 @@ describe('Component settings unit tests', () => {
const merged = immutableMerge({ depth: -1, processSingles: true, recurse: { changeMe: changeMeHandler } }, singleToChange);
expect(merged).toEqual(singleWithChanges);
expect(merged).not.toBe(singleToChange);
/* tslint:disable-next-line no-any */
expect((merged as any).b).toBe(singleToChange.b);
});
});

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -23,6 +23,7 @@
"devDependencies": {
"@types/jest": "^19.2.2",
"@uifabric/immutable-merge": "0.1.1",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -25,6 +25,7 @@
},
"devDependencies": {
"@types/jest": "^19.2.2",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
}
}

Просмотреть файл

@ -19,6 +19,5 @@ export type IComponentSettingsCollection<TSettings extends IComponentSettings =
* the override will be applied.
*/
export interface IOverrideLookup {
/* tslint:disable-next-line no-any */
[key: string]: any;
}

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -25,7 +25,10 @@
"@types/jest": "^19.2.2",
"@types/react": "16.8.15",
"react": "16.8.3",
"typescript": "3.3.3"
"typescript": "3.3.3",
"@uifabric/theme-registry": "0.1.1",
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
},
"peerDependencies": {
"react": "16.8.3"

Просмотреть файл

@ -0,0 +1 @@
# As this package grows it's likely we'll want to voluntarily ignore some packages

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
extends: [
"@uifabric/eslint-config-rules"
]
}

Просмотреть файл

@ -5,7 +5,8 @@ node_modules
.editorconfig
config.js
jest.config.js
tslint.json
.eslintrc.js
.eslintignore
tsconfig.json
jsconfig.json
webpack.config.js

Просмотреть файл

@ -28,7 +28,8 @@
"@types/jest": "^19.2.2",
"@types/react": "16.8.15",
"react": "16.8.3",
"@uifabric/build-native": "^0.1.1"
"@uifabric/build-native": "^0.1.1",
"@uifabric/eslint-config-rules": "^0.1.0"
},
"peerDependencies": {
"react": "16.8.3"

45
scripts/eslintrc.js Normal file
Просмотреть файл

@ -0,0 +1,45 @@
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
rules: {
"@typescript-eslint/adjacent-overload-signatures": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-types": "off",
"camelcase": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/class-name-casing": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": "off",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-misused-new": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-this-alias": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/type-annotation-spacing": "off",
"no-var": "off",
"prefer-const": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"no-undef": "error"
}
}

Просмотреть файл

@ -1,4 +1,5 @@
module.exports = {
preset: require('./just.config'),
just: require('just-scripts')
just: require('just-scripts'),
eslintPreset: require('./eslintrc')
};

Просмотреть файл

@ -10,7 +10,7 @@ const { copy } = require('./tasks/copy');
const { jest, jestWatch } = require('./tasks/jest');
const { sass } = require('./tasks/sass');
const { ts } = require('./tasks/ts');
const { tslint } = require('./tasks/tslint');
const { eslint } = require('./tasks/eslint');
const { webpack, webpackDevServer } = require('./tasks/webpack');
const { verifyApiExtractor, updateApiExtractor } = require('./tasks/api-extractor');
const prettier = require('./tasks/prettier');
@ -41,7 +41,7 @@ module.exports = function preset() {
task('ts:commonjs', ts.commonjs);
task('ts:esm', ts.esm);
task('ts:amd', ts.amd);
task('tslint', tslint);
task('eslint', eslint);
task('ts:commonjs-only', ts.commonjsOnly);
task('webpack', webpack);
task('webpack-dev-server', webpackDevServer);
@ -58,8 +58,8 @@ module.exports = function preset() {
: parallel('ts:commonjs', 'ts:esm', condition('ts:amd', () => argv().production && !argv().min));
});
task('validate', fs.existsSync(path.join(process.cwd(), 'jest.config.js')) ? series('tslint', 'jest') : 'tslint');
task('code-style', series('prettier', 'tslint'));
task('validate', fs.existsSync(path.join(process.cwd(), 'jest.config.js')) ? series('eslint', 'jest') : 'eslint');
task('code-style', series('prettier', 'eslint'));
task('update-api', series('clean', 'copy', 'sass', 'ts', 'update-api-extractor'));
task('dev', series('clean', 'copy', 'sass', 'webpack-dev-server'));
@ -75,5 +75,5 @@ module.exports = function preset() {
)
).cached();
task('no-op', () => {}).cached();
task('no-op', () => { }).cached();
};

Просмотреть файл

@ -1,71 +0,0 @@
// @ts-check
const { spawnSync } = require('child_process');
const path = require('path');
const msCustomRulesMain = require.resolve('tslint-microsoft-contrib');
const rulesPath = path.dirname(msCustomRulesMain);
const tslintPath = require.resolve('tslint/lib/tslintCli.js');
const files = process.argv.slice(2);
runTsLintOnFilesGroupedPerPackage(groupFilesByPackage(files));
/**
* Since we have a tslint.json config file per package we need to respect this when running
* tslint for staged files. To do this we group the files per package name. This function takes
* a list of package names and returns an object with the package name as the key and the files
* in that package as the value.
*
* @param {string[]} files
* @returns {{[packageName: string]: string[]}}
*/
function groupFilesByPackage(files) {
const rootDirectory = path.join(path.resolve(__dirname, '..', '..'), path.sep);
return files
.map(fileName => {
const parts = fileName.replace(rootDirectory, '').split(path.sep);
const packageRoot = [parts[0], parts[1]].join(path.sep);
return [packageRoot, fileName];
})
.reduce((filesByPackage, [package, file]) => {
if (path.dirname(package) === 'typings') {
return filesByPackage; // ignore custom typings package
}
if (!filesByPackage[package]) {
filesByPackage[package] = [];
}
filesByPackage[package].push(file);
return filesByPackage;
}, {});
}
/**
* Runs tslint for the staged files in the packages that require it.
* Excludes all API extractor files.
*
* @param {{[packageName: string]: string[]}} filesGroupedByPackage
*/
function runTsLintOnFilesGroupedPerPackage(filesGroupedByPackage) {
// Log an empty line on error to make the tslint output look better
console.log('');
/** @type {[string, string[]][]} */
// prettier-ignore
const fileEntries = (/** @type {any} */ Object.keys(filesGroupedByPackage)
.map(package => [package, filesGroupedByPackage[package]]));
for (let [package, files] of fileEntries) {
const tslintConfig = path.join(path.resolve(__dirname, '..', '..'), package, 'tslint.json');
const filteredFiles = files.filter(f => !f.endsWith('.api.ts'));
if (filteredFiles.length === 0) {
continue;
}
spawnSync(process.execPath, [tslintPath, '--config', tslintConfig, '-t', 'stylish', '-r', rulesPath, ...filteredFiles], {
stdio: 'inherit'
});
}
}

Просмотреть файл

@ -34,7 +34,6 @@
"command-line-args": "^4.0.7",
"cpx": "^1.5.0",
"css-loader": "^0.28.7",
"eslint": "^6.2.1",
"find-free-port": "~2.0.0",
"fork-ts-checker-webpack-plugin": "^0.4.1",
"fs-extra": "^7.0.1",
@ -71,7 +70,16 @@
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.1.14",
"webpack-notifier": "^1.6.0",
"yargs": "^13.2.4"
"yargs": "^13.2.4",
"@typescript-eslint/eslint-plugin": "^2.1.0",
"@typescript-eslint/parser": "^2.1.0",
"@uifabric/build-native": "^0.1.1",
"eslint": "^6.3.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1"
},
"bundlesize": [
{

8
scripts/tasks/eslint.js Normal file
Просмотреть файл

@ -0,0 +1,8 @@
// @ts-check
const { eslintTask } = require('just-scripts');
exports.eslint = eslintTask(
{
files: ['src/.',]
}
);

Просмотреть файл

@ -15,7 +15,6 @@ function createTypeScriptModule(fileName, css) {
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];

Просмотреть файл

@ -1,4 +0,0 @@
// @ts-check
const { tslintTask } = require('just-scripts');
exports.tslint = tslintTask();

1914
yarn.lock

Разница между файлами не показана из-за своего большого размера Загрузить разницу